Render Prawn pdf and rqrcode display QR with Ruby on rails -
creating ruby on rails web application qrcode display qr code in pdf
iam using
gem 'rqrcode-with-patches', require: 'rqrcode' gem 'prawn'
my post controller show pdf view
def show @qr=rqrcode::qrcode.new(request.url) respond_to |format| format.html format.pdf pdf = postpdf.new(@post) send_data pdf.render, filename: "post#{@post.id}.pdf", type: "application/pdf", disposition: "inline" end end end
post_pdf
class postpdf < prawn::document def initialize(post) super({top_margin: 30, page_size: 'a4', page_layout: :landscape }) @post = post post_id post_title qr_code end def post_id move_down 10 text "post id: #{@post.id}" end def post_title move_down 10 text "post title: #{@post.title}" end def qr_code move_down 10 @qr=rqrcode::qrcode.new(request.url) end end
i got error on display pdf, it's show
undefined local variable or method `request' #
there gem called prawn-qrcodes single use.
require 'prawn/qrcodes' prawn::document.generate("qr-big.pdf") msg = "hello world, qr code" text msg qrcode msg, :position => :center, :fit => [bounds.height, bounds.width] end
i think work better ** rqrcode-with-patches** because build prawn
Comments
Post a Comment