Skip to content

Instantly share code, notes, and snippets.

@maeda-m
Last active December 10, 2015 06:28
Show Gist options
  • Save maeda-m/4394712 to your computer and use it in GitHub Desktop.
Save maeda-m/4394712 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment