0

プログラミングが初めてで、これが私の2番目の質問です。prawn-qrcode は私のソリューションのように見えますが、インストール手順はコードをどこに置くべきかについて少し曖昧です。ここでのヘルプに感謝します。私のコードにはいくつかの間違いがあるかもしれません。

**Gem File**

gem 'devise'
gem 'linkedin'
gem 'omniauth'
gem 'omniauth-linkedin'
gem 'haml'
gem 'carrierwave'
gem 'rmagick'
gem 'rqrcode', "~> 0.4.2"
gem 'prawn-qrcode', "~> 0.2.0"
gem 'will_paginate', '> 3.0'
gem 'ransack'
gem 'omniauth-google-oauth2'
gem 'prawn'
gem 'hirb'

Relevant section of the controller 

def show
@property = Property.find(params[:id])
@qr = RQRCode::QRCode.new(property_path, :size => 6, :level => :h )
@prospect = Prospect.new

respond_to do |format|
     format.html # show.html.erb
     format.json { render json: @property }
     format.pdf do
           pdf = PropertyPdf.new(@property)
           send_data pdf.render, type: "application/pdf",
                                 disposition: "inline"
     end
end
end

Prawn PDF View

class PropertyPdf < Prawn::Document

def initialize(property)
    super(top_margin: 70)
    @property = property
    @qrcode_content = 'http://tbd.com'
    qrcode
    building_heading

end

def qrcode
 print_qr_code(@qrcode_content, :dot=>2.8)
end

ありがとう

4

1 に答える 1

0

あなたがする必要がある唯一のことは次のとおりです。

require 'prawn/qrcode'

自動的に拡張機能として Prawn に登録され、PDF 生成で使用できます。

github プロジェクトの例も、ほとんどのユース ケースをカバーする必要があります。

https://github.com/jabbrwcky/prawn-qrcode/tree/master/examples

乾杯、 イェンス

于 2013-06-14T08:33:12.910 に答える