I'm trying to generate a pdf document with different QRcodes and am using the following gems
我正在尝试用不同的qrcode生成一个pdf文档,并使用下面的gems
gem 'prawn'
gem 'prawn-qrcode'
Issue is, I can't seem to print out the QRcode with the following method:
问题是,我似乎无法用以下方法打印出QRcode:
require 'prawn/qrcode'
class QrcodePdf < Prawn::Document
def initialize (deal)
super()
@deal = deal
title
@deal.venues.each do |venue|
text "QR Code for: #{venue.name}"
qrcode = RQRCode::QRCode.new(@deal.id.to_s + "_" + venue.id.to_s + "_" + @deal.created_at.to_s)
render_qr_code(qrcode)
end
end
def title
text "Title of deal: #{@deal.title}", size: 16, style: :bold
end
end
Any help will be appreciated! Thank you!
任何帮助都将被感激!谢谢你!
Edit: Additional Info
编辑:附加信息
Sorry, i forgot to state that the pdf is actually being compiled. But the QRCode section is blank. So it just print the text of QR Code for ... in the loop.
对不起,我忘了说明pdf实际上正在编译。但是QRCode部分是空白的。所以它只是打印二维码的文本。在循环。
Also, I've printed out the string in @deal.id.to_s ... and it does contain the data I want, so I'm not sure what went wrong.
另外,我已经打印了@deal.id中的字符串。to_s……它确实包含了我想要的数据,所以我不确定哪里出错了。
I've also refereed to https://github.com/jabbrwcky/prawn-qrcode in the usage section.
我还在usage部分中引用了https://github.com/jabbrwcky/prawn-qrcode。
1 个解决方案
#1
4
It's probably bug with prawn-qrcode
, but render_qr_code
is not working. At least for Ruby 2.2.3
(I didn't tested if for older versions).
prawn-qrcode可能有问题,但是render_qr_code不能工作。至少在Ruby 2.2.3中是这样(我没有对旧版本进行测试)。
Still you can use print_qr_code
method and it's functional:
您仍然可以使用print_qr_code方法,它是功能性的:
pdf = Prawn::Document.new(:page_size => "A4") do
print_qr_code("some-text", extent: 96, stroke: false)
end
#1
4
It's probably bug with prawn-qrcode
, but render_qr_code
is not working. At least for Ruby 2.2.3
(I didn't tested if for older versions).
prawn-qrcode可能有问题,但是render_qr_code不能工作。至少在Ruby 2.2.3中是这样(我没有对旧版本进行测试)。
Still you can use print_qr_code
method and it's functional:
您仍然可以使用print_qr_code方法,它是功能性的:
pdf = Prawn::Document.new(:page_size => "A4") do
print_qr_code("some-text", extent: 96, stroke: false)
end