Class

Writer

There's no documentation for this item.

Modules
Graphics This module contains graphics primitives. Objects that include this module must respond to #add_content.
Lang
OffsetReader
Classes
ARC4 ARC4 methods A series of function to implement ARC4 encoding in Ruby
Complex
External
FontMetrics
OHash Based on [ruby-talk:20551]. Updated to (hopefully) be 1.8 friendly.
Object
PolygonPoint Points for use in the drawing of polygons.
State
StateStack
StrokeStyle A class that represents a style with which lines will be drawn.
TagAlink A callback to support the formation of clickable links to external locations.
TagBullet A callback function to support drawing of a solid bullet style. Use with <c:bullet>.</c:bullet>
TagDisc A callback function to support drawing of a disc bullet style.
TagIlink A callback for creating and managing links internal to the document.
TagUline A callback to support underlining.
Constants
ENCRYPT_OPTIONS Standard encryption/DRM options.
FONT_PATH The system font path. The sytem font path will be determined differently for each operating system.
MATCH_TAG_DRAW_ONE_RE
MATCH_TAG_DRAW_PAIR_RE
MATCH_TAG_REPLACE_RE Matches tags.
PAGE_SIZES Standard page size names. One of these may be provided to PDF::Writer.new as the :paper parameter.
PDF_VERSION_13
PDF_VERSION_14
PDF_VERSION_15
PDF_VERSION_16
TAGS Callback tag relationships. All relationships are of the form "tagname" => CallbackClass.
TAG_PARAM_RE
VERSION The version of PDF::Writer.
Public Attributes
absolute_bottom_margin Returns the absolute y position of the bottom margin.
absolute_left_margin The absolute x position of the left margin.
absolute_right_margin The absolute x position of the right margin.
absolute_top_margin Returns the absolute y position of the top margin.
absolute_x_middle The absolute x middle position.
absolute_y_middle The absolute y middle position.
arc4 The ARC4 encryption object. This is of no interest to external consumers.
bottom_margin
catalog The document catalog object (PDF::Writer::Object::Catalog). The options in the catalog should be set with PDF::Writer#open_here, PDF::Writer#viewer_preferences, and PDF::Writer#page_mode.
column_count The total number of columns. Returns zero (0) if columns are off.
column_gutter The gutter between columns. This will return zero (0) if columns are off.
column_number The current column number. Returns zero (0) if columns are off.
column_width The width of the currently active column. This will return zero (0) if columns are off.
compressed Sets the document to compressed (true) or uncompressed (false). Defaults to uncompressed. This can ONLY be set once and should be set as early as possible in the document creation process.
current_base_font
current_contents Returns the current contents object to which raw PDF instructions may be written.
current_font
current_page The current page for writing. This is of little interest to external clients.
destinations The set of known labelled destinations. All destinations are of class PDF::Writer::Object::Destination. This is of little interest to external clients.
encryption_key The string that will be used to encrypt this PDF document.
first_page Allows the user to find out what the ID is of the first page that was created during startup - useful if they wish to add something to it later.
font_families Add a new translation table for a font family. A font family will be used to associate a single name and font styles with multiple fonts. A style will be identified with a single-character style identifier or a series of style identifiers. The only styles currently recognised are:
font_size
info The PDF::Writer::Object::Info info object. This is used to provide certain metadata.
left_margin
margin_height The height of the margin area.
margin_width The width of the margin area.
margin_x_middle The middle of the writing area between the left and right margins.
margin_y_middle The middle of the writing area between the top and bottom margins.
objects Contains all of the PDF objects, ready for final assembly. This is of no interest to external consumers.
outlines The PDF::Writer::Object::Outlines object. This is currently used very little. This is of little interest to external clients.
page_height
page_width
pages The PDF::Writer::Object::Pages object. This is of little interest to external clients.
pageset The complete set of page objects. This is of little interest to external consumers.
pointer The vertical position of the writing point. If the vertical position is outside of the bottom margin, a new page will be created.
procset The PDF::Writer::Object::Procset object. This is of little interest to external clients.
right_margin
top_margin
version The version of PDF to which this document conforms. Should be one of PDF_VERSION_13, PDF_VERSION_14, PDF_VERSION_15, or PDF_VERSION_16.
y The vertical position of the writing point. The vertical position is constrained between the top and bottom margins. Any attempt to set it outside of those margins will cause the y pointer to be placed absolutely at the margins.
Public Methods
_post_transaction_rewind memory improvement for transaction-simple
absolute_bottom_margin
absolute_left_margin
absolute_right_margin
absolute_top_margin
absolute_x_middle
absolute_y_middle
add_content add content to the currently active object
add_destination Create a labelled destination within the document. The label is the name which will be used for <c:ilink> destinations.
add_info Add content to the documents info object.
add_internal_link Add a link in the document to an internal destination (ie. within the document)
add_link Add a link in the document to an external URL.
add_object After an object has been created, it will only show if it has been added, using this method.
add_outline_item Add an outline item (Bookmark).
add_text Add text to the document at (x, y) location at size and angle. The word_space_adjust parameter is an internal parameter that should not be used.
add_text_wrap Add text to the page, but ensure that it fits within a certain width. If it does not fit then put in as much as possible, breaking at word boundaries; return the remainder. justification and angle can also be specified for the text.
append_page Changes the #insert_page property to append to the page set.
bleed_box Sets the bleed box area.
check_all_here should be used for internal checks, not implemented as yet
close_object Close an object for writing.
cm2pts Convert a measurement in centimetres to points, which are the default PDF userspace units.
cm2pts Convert a measurement in centimetres to points, which are the default PDF userspace units.
column_count
column_gutter
column_number
column_width
columns? Indicates if columns are currently on.
compressed=
compressed? Returns true if the document is compressed.
current_font! Selects the current font based on defined font families and the current text state. As noted in #font_families, a "bi" font can be defined differently than an "ib" font. It should not be possible to have a "bb" text state, but if one were to show up, an entry for the #font_families would have to be defined to select anything other than the default font. This function is to be called whenever the current text state is changed; it will update the current font to whatever the appropriate font defined in the font family.
current_page_number Returns the current generic page number. This is based exclusively on the size of the page set.
escape Escape the text so that it’s safe for insertion into the PDF document.
font_descender Return the font descender, this will normally return a negative number. If you add this number to the baseline, you get the level of the bottom of the font it is in the PDF user units. Uses the current #font_size if size is not provided.
font_height Return the height in units of the current font in the given size. Uses the current #font_size if size is not provided.
in2pts Convert a measurement in inches to points, which are the default PDF userspace units.
in2pts Convert a measurement in inches to points, which are the default PDF userspace units.
insert_mode Changes page insert mode. May be called as follows:
insert_page Returns or changes the insert page property.
insert_position Returns or changes the insert position to be before or after the specified page.
lines_remaining Returns the estimated number of lines remaining given the default or specified font size.
margin_height
margin_width
margin_x_middle
margin_y_middle
margins_cm Define the margins in centimetres.
margins_in Define the margins in inches.
margins_mm Define the margins in millimetres.
margins_pt Define the margins in points. This will move the #y pointer
mm2pts Convert a measurement in millimetres to points, which are the default PDF userspace units.
mm2pts Convert a measurement in millimetres to points, which are the default PDF userspace units.
move_pointer Used to change the vertical position of the writing point. The pointer is moved down the page by dy (that is, #y is reduced by dy), so if the pointer is to be moved up, a negative number must be used. Moving up the page will not move to the previous page because of limitations in the way that PDF::Writer works. The writing point will be limited to the top margin position.
new Creates a new PDF document as a writing canvas. It accepts three named parameters:
new_page Add a new page to the document. This also makes the new page the current active object. This allows for mandatory page creation regardless of multi-column output.
open_at Specify the Destination object where the document should open when it first starts. style must be one of the following values. The value of style affects the interpretation of params. Uses page as the starting location.
open_here Specify the Destination object where the document should open when it first starts. style must be one of the values detailed for #destinations. The value of style affects the interpretation of params. Uses the current page as the starting location.
open_new_object Opens a new PDF object for operating against. Returns the object’s identifier. To close the object, you’ll need to do:
open_object Make a loose object. The output will go into this object, until it is closed, then will revert to the current one. This object will not appear until it is included within a page. The function will return the object reference.
page_mode= Set the page mode of the catalog. Must be one of the following:
pointer=
prepress Create the document with prepress options. Uses the same options as PDF::Writer.new (:paper, :orientation, and :version). It also supports the following options:
prepress_center_mark
prepress_clip_mark
render Return the PDF stream as a string.
reopen_object Opens an existing object for editing.
restore_state Restore a previously saved state.
save_as Save the PDF as a file to disk.
save_state Saves the state.
select_font If the named font is not loaded, then load it and make the required PDF objects to represent the font. If the font is already loaded, then make it the current font.
size The number of PDF objects in the document
start_columns Starts multi-column output. Creates size number of columns with a gutter PDF unit space between each column.
start_new_page Creates a new page. If multi-column output is turned on, this will change the column to the next greater or create a new page as necessary. If force is true, then a new page will be created even if multi-column output is on.
start_page_numbering Put page numbers on the pages from the current page. Place them relative to the coordinates (x, y) with the text horizontally relative according to pos, which may be :left, :right, or :center. The page numbers will be written on each page using pattern.
stop_columns Turns off multi-column output. If we are in the first column, or the lowest point at which columns were written is higher than the bottom of the page, then the writing pointer will be placed at the lowest point. Otherwise, a new page will be started.
stop_object Stop an object from appearing on pages from this point on.
stop_page_numbering Stop page numbering. Returns false if page numbering is off.
text This will add a string of text to the document, starting at the current drawing position. It will wrap to keep within the margins, including optional offsets from the left and the right. The text will go to the start of the next line when a return code "\n" is found.
text_line_width Calculate how wide a given text string will be on a page, at a given size. This may be called externally, but is alse used by #text_width. If size is not specified, PDF::Writer will use the current #font_size.
text_width Calculate how wide a given text string will be on a page, at a given size. If size is not specified, PDF::Writer will use the current #font_size. The difference between this method and #text_line_width is that this method will iterate over lines separated with newline characters.
to_s Alias for #render
trim_box Sets the trim box area.
viewer_preferences set the viewer preferences of the document, it is up to the browser to obey these.
which_page_number Given a particular generic page number page_num (numbered sequentially from the beginning of the page set), return the page number under a particular page numbering scheme (defaults to the first scheme turned on). Returns nil if page numbering is not turned on or if the page is not under the current numbering scheme.
y=
Private Methods
add_page_numbers
adjust_wrapped_text Partially calculate the values necessary to sort out the justification of text.
char_width
find_font
font_file
generate_font_id Generate a new font ID.
generate_id Generate an ID for a new PDF object.
init_font_families Initialize the font families for the default fonts.
load_font
load_font_metrics Loads the font metrics. This is now thread-safe.
page_number_search
parse_fonts_conf Parse the fonts.conf XML file.
parse_tag_params
preprocess_text
quick_text_tags Wrapper function for #text_tags
reset_state_at_page_finish Restore the state at the end of a page.
reset_state_at_page_start This will be called at a new page to return the state to what it was on the end of the previous page, before the stack was closed down. This is to get around not being able to have open ‘q’ across pages.
restore_margins_after_columns
text_end_position Given a start position and information about how text is to be laid out, calculate where on the page the text will end.
text_tags Checks if text contains a control tag at pos. Control tags are XML-like tags that contain tag information.
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.