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

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -