我試圖生成具有不同QRcodes一個PDF文檔,並使用下面的寶石的Rails:在蝦PDF生成QR碼
gem 'prawn'
gem 'prawn-qrcode'
問題是,我似乎無法打印出與QR碼以下方法:
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
任何幫助將不勝感激!謝謝!
編輯:附加信息
對不起,我忘了指出的PDF實際上是被編譯。但QRCode部分是空白的。 所以它只是在循環中打印QR碼的文本。
此外,我已經打印出@ deal.id.to_s中的字符串......它確實包含我想要的數據,所以我不確定是哪裏出了問題。
我也在使用部分中提到https://github.com/jabbrwcky/prawn-qrcode。
您應該添加你做了什麼錯誤。發佈說明「這不起作用」的代碼對我們試圖幫助您沒有幫助。 – Deekor
Hi @Deekor,對不起,我對問題進行了必要的更改 – user5296896
如何將QR碼放在表格中? –