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.

Rendering Options

    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)

Methods

Included Modules

DrawingHelpers

Classes and Modules

Module Ruport::Formatter::PDF::DrawingHelpers

Attributes

pdf_writer  [W] 

Public Class methods

Public Instance methods

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.

Renders the group as a table for Renderer::Group.

Generates a header with the group name for Renderer::Group.

Determines which style to use and renders the main body for Renderer::Grouping.

  • If the image is bigger than the box, it will be scaled down until it fits.
  • If the image is smaller than the box, it won‘t be resized.

options:

  • :x: left bound of box
  • :y: bottom bound of box
  • :width: width of box
  • :height: height of box

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

Appends the results of PDF::Writer#render to output for your pdf_writer object.

Adds n to pdf_writer.y, moving the vertical drawing position in the document.

Moves the cursor to a specific y coordinate in the document.

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.

Calls PDF::Writer#render and appends to output.

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

Save the output to a file.

Adds an image to every page. The color and size won‘t be modified, but it will be centered.

[Validate]