Skip to content

Instantly share code, notes, and snippets.

@hidakatsuya
Forked from maeda-m/visitor_pass
Last active December 10, 2015 06:29
Show Gist options
  • Save hidakatsuya/4394875 to your computer and use it in GitHub Desktop.
Save hidakatsuya/4394875 to your computer and use it in GitHub Desktop.
# 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
@hidakatsuya
Copy link
Author

あとはこんな文章を追加する感じ?

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment