Class | Ruport::Formatter::PDF |
In: |
lib/ruport/formatter/pdf.rb
|
Parent: | Formatter |
This class provides PDF output for Ruport‘s Table, Group, and Grouping renderers. It wraps Austin Ziegler‘s PDF::Writer to provide a higher level interface and provides a number of helpers designed to make generating PDF reports much easier. You will typically want to build subclasses of this formatter to customize it as needed.
Many methods forward options to PDF::Writer, so you may wish to consult its API docs.
General: * paper_size #=> "LETTER" * paper_orientation #=> :portrait Text: * text_format (sets options to be passed to add_text by default) Table: * table_format (a hash that can take any of the options available to PDF::SimpleTable) * table_format[:maximum_width] #=> 500 Grouping: * style (:inline,:justified,:separated,:offset)
pdf_writer | [W] |
Call PDF::Writer#text with the given arguments, using text_format defaults, if they are defined.
Example:
options.text_format { :font_size => 14 } add_text("Hello Joe") #renders at 14pt add_text("Hello Mike",:font_size => 16) # renders at 16pt
Hook for setting available options using a template. See the template documentation for the available options and their format.
Determines which style to use and renders the main body for Renderer::Grouping.
options:
Draws a PDF::SimpleTable using the given data (usually a Data::Table). Takes all the options you can set on a PDF::SimpleTable object, see the PDF::Writer API docs for details, or check our quick reference at:
stonecode.svnrepository.com/ruport/trac.cgi/wiki/PdfWriterQuickRef
Adds a specified amount of whitespace above and below the code in your block. For example, if you want to surround the top and bottom of a line of text with 5 pixels of whitespace:
pad(5) { add_text "This will be padded top and bottom" }
Adds a specified amount of whitespace below the code in your block. For example, if you want to add a 10 pixel buffer to the bottom of a line of text:
pad_bottom(10) { add_text "This will be padded on bottom" }
Adds a specified amount of whitespace above the code in your block. For example, if you want to add a 10 pixel buffer to the top of a line of text:
pad_top(10) { add_text "This will be padded on top" }
Returns the current PDF::Writer object or creates a new one if it has not been set yet.
Draws some text on the canvas, surrounded by a box with rounded corners.
Yields an OpenStruct which options can be defined on.
Example:
rounded_text_box(options.text) do |o| o.radius = 5 o.width = options.width || 400 o.height = options.height || 130 o.font_size = options.font_size || 12 o.heading = options.heading o.x = pdf_writer.absolute_x_middle - o.width/2 o.y = 300 end