Last active
December 10, 2015 06:28
-
-
Save maeda-m/4394712 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