Internal data structures and methods

phppdflib uses several data structures and methods that are hidden from the average programmer who is using the library. That does not mean that these structures and methods are of no use to the average implementer, it's mainly that accessing them violates the design goal of "simplicity" and abstracting the PDF format from the implementer.

In the interest of documentation completeness, as well as the possibility that these structures and methods were made private by some error of the developers, they are documented briefly here. If you find something that you feel should be made a public method and more fully documented, don't hesitate to email your case to me.

Data Structures

->objects

The most interesting data structure is the ->objects array. This is where all PDF objects are stored prior to ->generate() being called.

While the library methods that access this (most all of them) use it in an "append-only/read-only" fashon, it is possible to modify the attributes of pre-existing library objects by directly altering its contents.

The array is arranged such that the first index is the ID of the object, and the next is the parameter of that object to access. The array may have additional indicies for certain parameters (color, for example, which is an array of red, green, and blue values). Thus $pdf->objects[4]['type'] will return the type of object #4 ('rectangle', for example) and $pdf->objects[4]['width'] will return the line width with which that rectange will be drawn.

Prior to calling ->generate() it is possible to alter the ->objects array to change how objects occur. Doing so without understing ->objects is liable to create a corrupt PDF or cause ->generate() to fail. See the source.

Private Methods

->_resolve_mode ( array parameters, string type )

Returns a mode number suitable for inserting directly into the final PDF stream from the applicable part of the array parameters. type indicates the type of element that will be using this mode (i.e. text or shape)

->_adjust_margin ( float &x, float &y, int page )

Adjusts the cordinates for the margins on the specified page

->_resolve_param ( array parameters[, bool textmode] )

Takes a parameters array and returns a complete parameters array with default values substituted where needed. textmode controls how the painting modes are interpreted.

->_push_error ( int errornumber, string errormessage )

Pushes an error onto the message stack.

->_push_std_error ( int errornumber )

Pushes an error onto the message stack as defined by errornumber. Use to debloat the code by having common error message stored centrally.

->_resolve_colors ( array colors, array parameters )

Oddly, I'm not sure what this does. Could be code bloat.

->_use_font ( int fontid )

Check to see if a requested font is already in the list, if not add it. Either way, return the libid of the font.

->_int_val ( string binaryvalue )

Convert a big-endian byte stream into an integer.

->_make_raw_image ( int libraryID )

Returns the binary data to embed into the PDF for the given image.

->_place_raw_image ( int libraryID )

Returns the binary data to embed into the PDF for the given image placement.

->_rotate ( float angle )

Returns proper PDF code to specify a rotation angle.

->_get_operator ( int libraryID )

Returns the proper character to tell PDF to perform an operation on a shape (i.e. stroke, fill, whatever)

->_make_line ( int libraryID )

Returns code appropriate for the PDF to create a line from the library object.

->_make_rect ( int libraryID )

Returns code appropriate for the PDF to create a rectangle from the library object.

->_make_circle ( int libraryID )

Returns code appropriate for the PDF to create a circle from the library object.

->_make_text ( int libraryID )

Returns code appropriate for the PDF to create a text object from the library object.

->_colorset ( int libraryID )

Returns a string to set the apropriate stroke and fill colors for an object.

->_becomes_object ( int libraryID )

Returns true if the library object converts to a PDF object. (this is almost definately code bloat that needs cleaned up)

->_get_kids ( int libraryID )

Creates a PDF array of child objects of the given object.

->_order_pages ( int pagenodeID )

Builds an array of pages for the given pagenode in the correct order.

->_addnewoid ()

simple helper function to return the current oid and increment it by one.

->_addtoxreftable ( int offset, int gennum )

Add an object to the xref table data structure with the given offset and generation number.

->_makedictionary ( array entries )

Returns a properly formatted pdf dictionary containing entries specified by the array $entries.

->_makearray ( array entries )

Returns a properly formatted pdf array.

->_stringify ( string string )

Returns a properly formatted string, with any special characters escaped.

->_streamify ( string data[, array entries] )

Creates a properly formatted PDF "stream" object. If specified, the items in entries are added to the dictionary part of the stream.

->_makepagenode ( array kids[, array options] )

Returns a properly formatted page node.

_makepage ( int parent, array contents, int libraryID )

Creates a PDF page. The calling syntax is a bit bloated, it could probably work with just the libraryID.