简体   繁体   English

如何获取使用 PyQRCode 处理的 QR 码?

[英]How can I get my QR code, processed with PyQRCode?

I am trying to append an image to my pdf.我正在尝试将 append 映像到我的 pdf。 I have successfully appended a barcode but I am having troubles with the QRCode.我已成功附加条形码,但 QRCode 出现问题。 I am using PyQrCode and ReportLab我正在使用 PyQrCode 和 ReportLab

Here is my code snippers:这是我的代码截图:

Where I append:我在哪里 append:

parts.append(Image(self.qrCode, width=.3* 0.7 *inch, height=.4*.56*inch))`

Where I create the QRCode:我在哪里创建 QRCode:

qrCode = pyqrcode.create(str("252525"), error='L', version=27, mode='binary')
qrCode.svg(sys.stdout, scale=1)
qrCode.svg('uca-url.svg', scale=4)

number = pyqrcode.create(123456789012345)
number.png('big-number.png')

and the error that I am getting:以及我得到的错误:

AttributeError at /inventories/download_tag/2525/
QRCode instance has no attribute 'rfind'

Is there a better library or method to achieve my goal here?有没有更好的库或方法来实现我的目标?

pip install pyqrcode

then然后

cd a_path_you_want
nano  make_qr.py

#!/usr/bin/python
import sys
import pyqrcode
text = sys.argv[1]
scale = sys.argv[2] # 1 to 8
err_prt = sys.argv[3] # error_protection in ['L','M','H']
url = pyqrcode.create(text,err_prt)
url.svg(sys.stdout, scale, module_color="brown") #this returns svg to caller script
exit(0)

be sure to务必

chmod +x make_qr.py

call from php来自 php 的电话

<?php
  $text = ".... your data here ....";
  echo shell_exec("path_to_script/make_qr.py '$text' 4 'L' 2>&1");
 ?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM