You are here: Browse Railsplugins Rfpdf
= RFPDF Template Plugin
A template plugin allowing the inclusion of ERB-enabled RFPDF template files.
Example .rb method Usage
In the controller, something like:
def mypdf
pdf = FPDF.new()
end
#
In the controller, something like:
def mypdf
@options_for_rfpdf ||= {}
@options_for_rfpdf[:file_name] = "nice_looking.pdf"
end
In the layout (make sure this is the only item in the layout): <%= @content_for_layout %>
In the view (mypdf.rfpdf):
<% pdf = FPDF.new() # # Chinese # pdf.extend(PDF_Chinese) pdf.AddPage pdf.AddBig5Font pdf.SetFont(‘Big5’,’’,18) pdf.Write(5, ‘²{®É®ð·Å 18 C Àã«× 83 %‘) icBig5 = Iconv.new(‘Big5’, ‘UTF-8’) pdf.Write(15, icBig5.iconv(“宋体 should be working”)) %> <%= pdf.Output() %>
#You can configure Rfpdf by using an @options_for_rfpdf hash in your controllers.
Here are a few options:
:filename (default: action_name.pdf) Filename of PDF to generate
Note: If you're using the same settings for @options_for_rfpdf often, you might want to put your assignment in a before_filter (perhaps overriding :filename, etc in your actions).
ProblemsLayouts and partials are currently not supported; just need to wrap the PDF generation differently.
NOTE: This description has been extracted from the Plugin README and so the formatting may need updating to make browser friendly