Class PDF::QuickRef
In: lib/pdf/quickref.rb
Parent: Object

QuickRef

A formatting language to create a quick reference sheet. This is a multi-column page in landscape mode that generally has three or four columns. This format may also be used for brochures, but brochure creation requires a bit of management to create properly.

Reference Sheets

A three-column reference sheet is generally in the form of:

Page 1:

  column 1 | column 2 | column 3

Page 2:

  column 4 | column 5 | column 6

The formatting language provided in QuickRef is based around this text flow. The title of the quick reference sheet is in column 1. The two pages are intended to be printed on both sides of pieces of paper so that columns 1 and 6 are matched. This will use a Z-fold that places columns 5 and 6 face to face and columns 2 and 3 face to face. In the folded reference sheet, columns 1 and 4 will be facing out.

Brochures

In contrast, brochures differ vastly in their design, although the common brochure is also three columns and either follows the same layout as a reference sheet or uses an overlapping fold.

When an overlapping fold is used, the title is typically on column 6 (assuming a left-to-right reading order). A short summary will appear on column 4. Contact information about the maker of the brochure is typically in column 5. Columns 1, 2, and 3 will contain the main body of the brochure. The brochure will be folded so that columns 2 and 3 are face to face. After this, column 1 will face column 4 (exposed by the first fold). In the folded brochure, columns 5 and 6 are facing out.

Usage

 qr = PDF::QuickRef.new # 3-column LETTER
 qr.title "My QuickRef"
 qr.h1 "H1 Text"
 qr.lines "Text to put after the header."
 qr.save_as "MyQuickRef.pdf"

Methods

body   codelines   codepairs   h1   h2   h3   h4   hline   lines   make   new   pairs   pre   render   save_as   title   to_s   use_body_font   use_code_font   use_heading_font   use_title_font  

Attributes

body_font  [RW]  The name of the font that will be used for body, lines, and pairs text. The default is ‘Times-Roman’.
body_font_encoding  [RW]  The font encoding for body, lines, and pairs text.
body_font_size  [RW]  The size body and code text. The default is 7 points.
code_font  [RW]  The name of the font that will be used for code, codelines, and codepairs text; this is generally a fixed-pitch font. The default is ‘Courier’.
code_font_encoding  [RW]  The font encoding for code, codelines, and codepairs text.
h1_font_size  [RW]  The size h1 text. The default is 11 points.
h2_font_size  [RW]  The size h2 text. The default is 9 points.
h3_font_size  [RW]  The size h3 text. The default is 8 points.
h4_font_size  [RW]  The size h4 text. The default is 7 points.
heading_font  [RW]  The name of the font that will be used for h1, h2, h3, and h4 text. The default is Times-Roman.
heading_font_encoding  [RW]  The font encoding for h1, h2, h3, and h4 text.
pdf  [R]  Access to the raw PDF canvas for normal PDF::Writer configuration.
title_font  [RW]  The name of the font that will be used for title text. The default font is Times-Roman.
title_font_encoding  [RW]  The font encoding for title text.
title_font_size  [RW]  The size title text. The default is 14 points.

Public Class methods

Creates a QuickRef document and then calls instance_eval on the document. This allows for a more natural use of the QuickRef class as a DSL for creating these documents.

Using make

 PDF::QuickRef.make do # 3-column LETTER
   title "My QuickRef"
   h1 "H1 Text"
   lines "Text to put after the header."
   save_as "MyQuickRef.pdf"
 end

Create the quick reference document. paper is passed unchanged to the PDF::Writer.new; the page is always created landscape. Margins are initialized to 18 points. After some additional initialization is performed, the quick reference document is yielded to an optional block for further configuration. All of this is done before the columns are started.

After the columns are started, lines will be drawn between column positions.

Public Instance methods

Writes body text. Paragraphs will be reflowed for optimal placement of text. Text separated by two line separators (e.g., \n\n, although the separator is platform dependent). The text will be placed with full justification.

Creates a one-column zebra-striped table using the code font. Each line of the text is a separate row.

Creates a two-column zebra-striped table using the code font. Each line of the text is a separate row; the two columns are separated by tab characters.

Writes the text with the heading_font and h1_font_size left justified in the column. The font is set to body_font after the heading is drawn.

Writes the text with the heading_font and h2_font_size left justified in the column. The font is set to body_font after the heading is drawn.

Writes the text with the heading_font and h3_font_size left justified in the column. The font is set to body_font after the heading is drawn.

Writes the text with the heading_font and h4_font_size left justified in the column. The font is set to body_font after the heading is drawn.

Draws a horizontal line with the specified style and colour.

Creates a one-column zebra-striped table using the body font. Each line of the text is a separate row.

Creates a two-column zebra-striped table using the body font. Each line of the text is a separate row; the two columns are separated by tab characters.

Writes code text. Newlines and spaces will be preserved.

Generates the PDF document as a string.

Writes the Quick Reference to disk.

Writes the text with the title_font and title_font_size centered in the column. After the title has been written, an hline will be drawn under the title. The font is set to body_font after the title is drawn.

to_s()

Alias for render

Change the current font to the body font.

Change the current font to the code font.

Change the current font to the heading font (used normally by h1, h2, h3, and h4|).

Change the current font to the title font.

[Validate]