-
-
Save hidakatsuya/4394875 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
class VisitorPassController < ApplicationController | |
def create_pass | |
visitor = Visitor.find(params[:id]) | |
report = ThinReports::Report.new layout: File.join(Rails.root, 'app', 'reports', 'visitor_pass.tlf') | |
report.start_new_page do |page| | |
# jpg_filepath method will return the path of JPEG file. | |
# e.g. "Rails.root/photos/visitor_001.jpg" | |
page.item(:photo).src(visitor.jpg_filepath) | |
page.values name: visitor.name | |
end | |
send_data report.generate, filename: 'visitor_pass.pdf', type: 'application/pdf', disposition: 'attachment' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
あとはこんな文章を追加する感じ?
In addition, see also the following links:
http://prawn.majesticseacreature.com/docs/0.11.1/Prawn/Images.html#method-i-image
Prawn is a library that is used internally to generate the PDF in thinreports.
So, item#src method of thinreports is almost the same as method of that.