Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
Cpdf Class Reference
PDF generator library

Cpdf provides. More...

## Public Member Functions
| __construct ( $pageSize=array(0, 0, 612, 792))
| o_destination ( $id, $action, $options='')
| o_viewerPreferences ( $id, $action, $options='')
| o_catalog ( $id, $action, $options='')
| o_pages ( $id, $action, $options='')
| o_outlines ( $id, $action, $options='')
| o_function ( $id, $action, $options='')
| o_pattern ( $id, $action, $options='')
| o_shading ( $id, $action, $options='')
| o_font ( $id, $action, $options='')
| o_fontDescriptor ( $id, $action, $options='')
| o_fontEncoding ( $id, $action, $options='')
| o_procset ( $id, $action, $options='')
| o_info ( $id, $action, $options='')
| o_action ( $id, $action, $options='')
| o_annotation ( $id, $action, $options='')
| o_page ($id, $action, $options='')
| o_contents ($id, $action, $options='')
| o_image ($id, $action, $options='')
| o_encryption ($id, $action, $options='')
| md5_16 ($string)
| encryptInit ($id)
| ARC4_init ($key='')
| ARC4 ($text)
| addLink ($url, $x0, $y0, $x1, $y1)
| addInternalLink ($label, $x0, $y0, $x1, $y1)
| setEncryption ($userPass='', $ownerPass='', $pc=array())
| checkAllHere ()
| output ($debug=0)
| newDocument ($pageSize=array(0, 0, 612, 792))
| openFont ( $font)
| selectFont ( $fontName, $encoding='', $set=1)
| currentFont ()
| setCurrentFont ()
| getFirstPageId ()
| addContent ( $content)
| setColorRGB ( $r, $g, $b, $force=0)
| setColor ( $cmykArray, $force=0)
| setStrokeColorRGB ( $r, $g, $b, $force=0)
| setStrokeColor ( $cmykArray, $force=0)
| line ( $x1, $y1, $x2, $y2)
| curve ( $x0, $y0, $x1, $y1, $x2, $y2, $x3, $y3)
| partEllipse ( $x0, $y0, $astart, $afinish, $r1, $r2=0, $angle=0, $nSeg=8)
| filledEllipse ( $x0, $y0, $r1, $r2=0, $angle=0, $nSeg=8, $astart=0, $afinish=360)
| ellipse ( $x0, $y0, $r1, $r2=0, $angle=0, $nSeg=8, $astart=0, $afinish=360, $close=1, $fill=0)
| setLineStyle ( $width=1, $cap='', $join='', $dash='', $phase=0)
| polygon ( $p, $np, $f=0)
| shadedRectangle ( $x1, $y1, $width, $height, $options)
| filledRectangle ( $x1, $y1, $width, $height)
| rectangle ( $x1, $y1, $width, $height)
| newPage ( $insert=0, $id=0, $pos='after')
| stream ( $options='')
| getFontHeight ( $size=false)
| getFontDecender ( $size=false)
| filterText ( $text)
| PRVTgetTextPosition ( $x, $y, $angle, $size, $wa, $text)
| PRVTcheckTextDirective (&$text, $i, &$f, $final=0)
| PRVTcheckTextDirective1 (&$text, $i, &$f, $final, &$x, &$y, $size=0, $angle=0, $wordSpaceAdjust=0)
| addText ( $x, $y, $size, $text, $angle=0, $wordSpaceAdjust=0)
| getTextWidth ( $size, $text)
| PRVTadjustWrapText ( $text, $actual, $width, &$x, &$adjust, $justification)
| addTextWrap ( $x, $y, $width, $size, $text, $justification='left', $angle=0, $test=0)
| saveState ( $pageEnd=0)
| restoreState ( $pageEnd=0)
| openObject ()
| reopenObject ( $id)
| closeObject ()
| stopObject ( $id)
| addObject ( $id, $options='add')
| addInfo ( $label, $value=0)
| setPreferences ( $label, $value=0)
| PRVT_getBytes (&$data, $pos, $num)
| addPngFromFile ( $file, $x, $y, $w=0, $h=0)
| addJpegFromFile ( $img, $x, $y, $w=0, $h=0)
| addImage (&$img, $x, $y, $w=0, $h=0, $quality=75)
| addJpegImage_common (&$data, $x, $y, $w=0, $h=0, $imageWidth, $imageHeight, $channels=3)
| openHere ( $style, $a=0, $b=0, $c=0)
| addDestination ($label, $style, $a=0, $b=0, $c=0)
| setFontFamily ($family, $options='')
| addMessage ( $message)
| transaction ( $action)
| pushTextState ( $newState)
| popTextState ()

## Static Public Member Functions
| compareCMYK ( $cmykArray1, $cmykArray2)

## Public Attributes
| $ez
| $nCallBack
| $numObj = 0
| $objects = array()
| $catalogId
| $fonts = array()
| $currentFont = ''
| $currentBaseFont = ''
| $currentFontNum = 0
| $currentNode
| $currentPage
| $currentContents
| $numFonts = 0
| $currentColour
| $currentStrokeColour
| $currentLineStyle = ''
| $stateStack = array()
| $nStateStack = 0
| $numPages = 0
| $stack = array()
| $nStack = 0
| $looseObjects = array()
| $addLooseObjects = array()
| $infoObject = 0
| $numImages = 0
| $options = array( 'compression' => 1 )
| $firstPageId
| $wordSpaceAdjust = 0
| $procsetObjectId
| $fontFamilies = array()
| $currentTextState = ''
| $messages = ''
| $arc4 = ''
| $arc4_objnum = 0
| $fileIdentifier = ''
| $encrypted = 0
| $encryptionKey = ''
| $callback = array()
| $nCallback = 0
| $destinations = array()
| $checkpoint = ''
| $textStateStack = array( '' )

## Detailed Description

Cpdf provides.

Definition at line 17 of file class.pdf.php.

## Constructor & Destructor Documentation

## ◆ __construct()

Cpdf::__construct | ( |  | $pageSize = `array( 0, 0, 612, 792 )` | ) |

Constructor

Parameters

  array | $pageSize | array of 4 numbers, defining the bottom left and upper right corner of the page. first two are normally zero.

Definition at line 236 of file class.pdf.php.

References newDocument(), eZMath\rgbToCMYK(), and setFontFamily().

## Member Function Documentation

## ◆ addContent()

Cpdf::addContent | ( |  | $content | ) |

add content to the currently active object

@access private

Definition at line 2197 of file class.pdf.php.

References $currentContents.

## ◆ addDestination()

Cpdf::addDestination | ( |  | $label,
|  |  | $style,
|  |  | $a = `0`,
|  |  | $b = `0`,
|  |  | $c = `0`
| ) |  |

create a labelled destination within the document

Definition at line 3956 of file class.pdf.php.

References $numObj, and o_destination().

## ◆ addImage()

Cpdf::addImage | ( | & | $img,
|  |  | $x,
|  |  | $y,
|  |  | $w = `0`,
|  |  | $h = `0`,
|  |  | $quality = `75`
| ) |  |

add an image into the document, from a GD object this function is not all that reliable, and I would probably encourage people to use the file based functions

Definition at line 3846 of file class.pdf.php.

References addJpegImage_common().

## ◆ addInfo()

Cpdf::addInfo | ( |  | $label,
|  |  | $value = `0`
| ) |  |

add content to the documents info object

Definition at line 3504 of file class.pdf.php.

References o_info().

## ◆ addInternalLink()

Cpdf::addInternalLink | ( |  | $label,
|  |  | $x0,
|  |  | $y0,
|  |  | $x1,
|  |  | $y1
| ) |  |

add a link in the document to an internal destination (ie. within the document)

Definition at line 1627 of file class.pdf.php.

References o_annotation().

## ◆ addJpegFromFile()

Cpdf::addJpegFromFile | ( |  | $img,
|  |  | $x,
|  |  | $y,
|  |  | $w = `0`,
|  |  | $h = `0`
| ) |  |

add a JPEG image into the document, from a file

Definition at line 3795 of file class.pdf.php.

References addJpegImage_common().

## ◆ addJpegImage_common()

Cpdf::addJpegImage_common | ( | & | $data,
|  |  | $x,
|  |  | $y,
|  |  | $w = `0`,
|  |  | $h = `0`,
|  |  | $imageWidth,
|  |  | $imageHeight,
|  |  | $channels = `3`
| ) |  |

common code used by the two JPEG adding functions

@access private

Definition at line 3910 of file class.pdf.php.

References $currentContents, $numImages, and o_image().

Referenced by addImage(), and addJpegFromFile().

## ◆ addLink()

Cpdf::addLink | ( |  | $url,
|  |  | $x0,
|  |  | $y0,
|  |  | $x1,
|  |  | $y1
| ) |  |

functions which can be called to adjust or add to the document add a link in the document to an external URL

Definition at line 1618 of file class.pdf.php.

References o_annotation().

## ◆ addMessage()

Cpdf::addMessage | ( |  | $message | ) |

used to add messages for use in debugging

Definition at line 4018 of file class.pdf.php.

Referenced by addPngFromFile(), o_font(), openFont(), and selectFont().

## ◆ addObject()

Cpdf::addObject | ( |  | $id,
|  |  | $options = `'add'`
| ) |  |

after an object has been created, it wil only show if it has been added, using this function.

Definition at line 3452 of file class.pdf.php.

References $currentContents, $options, and o_page().

## ◆ addPngFromFile()

Cpdf::addPngFromFile | ( |  | $file,
|  |  | $x,
|  |  | $y,
|  |  | $w = `0`,
|  |  | $h = `0`
| ) |  |

add a PNG image into the document, from a file this should work with remote files

Returns
  true if adding image succeded

Definition at line 3565 of file class.pdf.php.

References $currentContents, $numImages, $options, addMessage(), o_image(), PRVT_getBytes(), and eZDebug\writeError().

## ◆ addText()

Cpdf::addText | ( |  | $x,
|  |  | $y,
|  |  | $size,
|  |  | $text,
|  |  | $angle = `0`,
|  |  | $wordSpaceAdjust = `0`
| ) |  |

add text to the document, at a specified location, size and angle on the page

Returns
  array( 'height' => <used height if more than normal text, -1 if not> )

Definition at line 2909 of file class.pdf.php.

References $currentContents, $wordSpaceAdjust, PRVTcheckTextDirective(), PRVTcheckTextDirective1(), PRVTgetTextPosition(), selectFont(), and setCurrentFont().

Referenced by addTextWrap().

## ◆ addTextWrap()

Cpdf::addTextWrap | ( |  | $x,
|  |  | $y,
|  |  | $width,
|  |  | $size,
|  |  | $text,
|  |  | $justification = `'left'`,
|  |  | $angle = `0`,
|  |  | $test = `0`
| ) |  |

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, splitting at word boundaries and return the remainder. justification and angle can also be specified for the text

return array ('text' => <text for new line>, 'width' => <width of added text, 0 i more text>, 'height' => <height of added text, -1 if none/default> )

Definition at line 3153 of file class.pdf.php.

References $currentFont, $currentTextState, addText(), getFontHeight(), PRVTadjustWrapText(), PRVTcheckTextDirective(), selectFont(), and setCurrentFont().

## ◆ ARC4()

Cpdf::ARC4 | ( |  | $text | ) |

ARC4 encrypt a text string

Definition at line 1592 of file class.pdf.php.

References $arc4.

Referenced by o_action(), o_contents(), o_encryption(), o_image(), and o_info().

## ◆ ARC4_init()

Cpdf::ARC4_init | ( |  | $key = `''` | ) |

initialize the ARC4 encryption

Definition at line 1566 of file class.pdf.php.

Referenced by encryptInit(), o_encryption(), and output().

## ◆ checkAllHere()

Cpdf::checkAllHere | ( |  | ) |

should be used for internal checks, not implemented as yet

Definition at line 1668 of file class.pdf.php.

Referenced by output().

## ◆ closeObject()

Cpdf::closeObject | ( |  | ) |

close an object

Definition at line 3422 of file class.pdf.php.

References $nStack.

## ◆ compareCMYK()

Cpdf::compareCMYK | ( |  | $cmykArray1,
|  |  | $cmykArray2
| ) |  |
| static

Parameters

  new | cmyk array 1
  new | cmyk array 2

Returns
  true if equal, false if not

Definition at line 4088 of file class.pdf.php.

Referenced by setColor(), and setStrokeColor().

## ◆ currentFont()

Cpdf::currentFont | ( |  | ) |

Get current font

Returns
  current font name

Definition at line 2136 of file class.pdf.php.

References $currentBaseFont.

Referenced by setCurrentFont().

## ◆ curve()

Cpdf::curve | ( |  | $x0,
|  |  | $y0,
|  |  | $x1,
|  |  | $y1,
|  |  | $x2,
|  |  | $y2,
|  |  | $x3,
|  |  | $y3
| ) |  |

draw a bezier curve based on 4 control points

Definition at line 2262 of file class.pdf.php.

References $currentContents.

## ◆ ellipse()

Cpdf::ellipse | ( |  | $x0,
|  |  | $y0,
|  |  | $r1,
|  |  | $r2 = `0`,
|  |  | $angle = `0`,
|  |  | $nSeg = `8`,
|  |  | $astart = `0`,
|  |  | $afinish = `360`,
|  |  | $close = `1`,
|  |  | $fill = `0`
| ) |  |

draw an ellipse note that the part and filled ellipse are just special cases of this function

draws an ellipse in the current line style centered at $x0,$y0, radii $r1,$r2 if $r2 is not set, then a circle is drawn nSeg is not allowed to be less than 2, as this will simply draw a line (and will even draw a pretty crappy shape at 2, as we are approximating with bezier curves.

Definition at line 2296 of file class.pdf.php.

References $currentContents.

Referenced by filledEllipse(), and partEllipse().

## ◆ encryptInit()

Cpdf::encryptInit | ( |  | $id | ) |

initialize the encryption for processing a particular object

Definition at line 1552 of file class.pdf.php.

References $encryptionKey, ARC4_init(), and md5_16().

Referenced by o_action(), o_contents(), o_image(), and o_info().

## ◆ filledEllipse()

Cpdf::filledEllipse | ( |  | $x0,
|  |  | $y0,
|  |  | $r1,
|  |  | $r2 = `0`,
|  |  | $angle = `0`,
|  |  | $nSeg = `8`,
|  |  | $astart = `0`,
|  |  | $afinish = `360`
| ) |  |

draw a filled ellipse

Definition at line 2281 of file class.pdf.php.

References ellipse().

## ◆ filledRectangle()

Cpdf::filledRectangle | ( |  | $x1,
|  |  | $y1,
|  |  | $width,
|  |  | $height
| ) |  |

a filled rectangle, note that it is the width and height of the rectangle which are the secondary paramaters, not the coordinates of the upper-right corner

Definition at line 2470 of file class.pdf.php.

References $currentContents.

## ◆ filterText()

Cpdf::filterText | ( |  | $text | ) |

filter the text, this is applied to all text just before being inserted into the pdf document it escapes the various things that need to be escaped, and so on

@access private

Definition at line 2634 of file class.pdf.php.

Referenced by o_action(), and o_info().

## ◆ getFirstPageId()

Cpdf::getFirstPageId | ( |  | ) |

function for 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.

Definition at line 2187 of file class.pdf.php.

References $firstPageId.

## ◆ getFontDecender()

Cpdf::getFontDecender | ( |  | $size = `false` | ) |

return the font decender, 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

Definition at line 2613 of file class.pdf.php.

References $currentFont, and selectFont().

Referenced by PRVTcheckTextDirective1().

## ◆ getFontHeight()

Cpdf::getFontHeight | ( |  | $size = `false` | ) |

return the height in units of the current font in the given size

Definition at line 2593 of file class.pdf.php.

References $currentFont, and selectFont().

Referenced by addTextWrap(), and PRVTcheckTextDirective1().

## ◆ getTextWidth()

Cpdf::getTextWidth | ( |  | $size,
|  |  | $text
| ) |  |

calculate how wide a given text string will be on a page, at a given size. this can be called externally, but is alse used by the other class functions

Definition at line 3046 of file class.pdf.php.

References $currentFont, popTextState(), PRVTcheckTextDirective(), pushTextState(), selectFont(), and setCurrentFont().

Referenced by PRVTgetTextPosition().

## ◆ line()

Cpdf::line | ( |  | $x1,
|  |  | $y1,
|  |  | $x2,
|  |  | $y2
| ) |  |

draw a line from one set of coordinates to another

Definition at line 2254 of file class.pdf.php.

References $currentContents.

## ◆ md5_16()

Cpdf::md5_16 | ( |  | $string | ) |

ARC4 functions A series of function to implement ARC4 encoding in PHP calculate the 16 byte version of the 128 bit md5 digest of the string

Definition at line 1540 of file class.pdf.php.

Referenced by encryptInit(), and o_encryption().

## ◆ newDocument()

Cpdf::newDocument | ( |  | $pageSize = `array(0,0,612,792)` | ) |

intialize a new document if this is called on an existing document results may be unpredictable, but the existing document would be lost at minimum this function is called automatically by the constructor function

@access private

Definition at line 1723 of file class.pdf.php.

References $currentContents, o_catalog(), o_info(), o_outlines(), o_page(), o_pages(), and o_procset().

Referenced by __construct().

## ◆ newPage()

Cpdf::newPage | ( |  | $insert = `0`,
|  |  | $id = `0`,
|  |  | $pos = `'after'`
| ) |  |

add a new page to the document this also makes the new page the current active object

Definition at line 2488 of file class.pdf.php.

References $currentContents, $nStateStack, o_page(), restoreState(), saveState(), setColor(), and setStrokeColor().

## ◆ o_action()

Cpdf::o_action | ( |  | $id,
|  |  | $action,
|  |  | $options = `''`
| ) |  |

an action object, used to link to URLS initially

Definition at line 1156 of file class.pdf.php.

References $options, ARC4(), encryptInit(), and filterText().

Referenced by o_annotation().

## ◆ o_annotation()

Cpdf::o_annotation | ( |  | $id,
|  |  | $action,
|  |  | $options = `''`
| ) |  |

an annotation object, this will add an annotation to the current page. initially will support just link annotations

Definition at line 1216 of file class.pdf.php.

References $currentPage, $numObj, $options, o_action(), and o_page().

Referenced by addInternalLink(), and addLink().

## ◆ o_catalog()

Cpdf::o_catalog | ( |  | $id,
|  |  | $action,
|  |  | $options = `''`
| ) |  |

define the document catalog, the overall controller for the document

Definition at line 353 of file class.pdf.php.

References $numObj, $options, and o_viewerPreferences().

Referenced by newDocument(), o_outlines(), o_pages(), openHere(), and setPreferences().

## ◆ o_contents()

Cpdf::o_contents | ( |  | $id,
|  |  | $action,
|  |  | $options = `''`
| ) |  |

the contents objects hold all of the content which appears on pages

Definition at line 1344 of file class.pdf.php.

References $options, ARC4(), and encryptInit().

Referenced by o_image(), o_page(), openObject(), and selectFont().

## ◆ o_destination()

Cpdf::o_destination | ( |  | $id,
|  |  | $action,
|  |  | $options = `''`
| ) |  |

Document object methods (internal use only)

There is about one object method for each type of object in the pdf document Each function has the same call list ($id,$action,$options). $id = the object ID of the object, or what it is to be if it is being created $action = a string specifying the action to be performed, though ALL must support: 'new' - create the object with the id $id 'out' - produce the output for the pdf object $options = optional, a string or array containing the various parameters for the object

These, in conjunction with the output function are the ONLY way for output to be produced within the pdf 'file'. destination object, used to specify the location for the user to jump to, presently on opening

Definition at line 271 of file class.pdf.php.

References $options.

Referenced by addDestination(), and openHere().

## ◆ o_encryption()

Cpdf::o_encryption | ( |  | $id,
|  |  | $action,
|  |  | $options = `''`
| ) |  |

encryption object.

Definition at line 1469 of file class.pdf.php.

References $options, ARC4(), ARC4_init(), and md5_16().

Referenced by setEncryption().

## ◆ o_font()

Cpdf::o_font | ( |  | $id,
|  |  | $action,
|  |  | $options = `''`
| ) |  |

an object to hold the font description

Definition at line 851 of file class.pdf.php.

References $numFonts, $numObj, $options, addMessage(), o_fontEncoding(), and o_pages().

Referenced by selectFont().

## ◆ o_fontDescriptor()

Cpdf::o_fontDescriptor | ( |  | $id,
|  |  | $action,
|  |  | $options = `''`
| ) |  |

a font descriptor, needed for including additional fonts

Definition at line 957 of file class.pdf.php.

References $options.

Referenced by selectFont().

## ◆ o_fontEncoding()

Cpdf::o_fontEncoding | ( |  | $id,
|  |  | $action,
|  |  | $options = `''`
| ) |  |

the font encoding

Definition at line 1014 of file class.pdf.php.

References $options.

Referenced by o_font().

## ◆ o_function()

Cpdf::o_function | ( |  | $id,
|  |  | $action,
|  |  | $options = `''`
| ) |  |

Add object to hold Function properties Only partial support for type 0, 3 and 4

Parameters

  object | id.
  action |
  options |

Definition at line 585 of file class.pdf.php.

References $options.

Referenced by o_shading().

## ◆ o_image()

Cpdf::o_image | ( |  | $id,
|  |  | $action,
|  |  | $options = `''`
| ) |  |

an image object, will be an XObject in the document, includes description and data

Definition at line 1394 of file class.pdf.php.

References $numObj, $options, ARC4(), encryptInit(), o_contents(), o_pages(), and o_procset().

Referenced by addJpegImage_common(), and addPngFromFile().

## ◆ o_info()

Cpdf::o_info | ( |  | $id,
|  |  | $action,
|  |  | $options = `''`
| ) |  |

define the document information

Definition at line 1102 of file class.pdf.php.

References $options, ARC4(), encryptInit(), and filterText().

Referenced by addInfo(), and newDocument().

## ◆ o_outlines()

Cpdf::o_outlines | ( |  | $id,
|  |  | $action,
|  |  | $options = `''`
| ) |  |

define the outlines in the doc, empty for now

Definition at line 543 of file class.pdf.php.

References $options, and o_catalog().

Referenced by newDocument().

## ◆ o_page()

Cpdf::o_page | ( |  | $id,
|  |  | $action,
|  |  | $options = `''`
| ) |  |

a page object, it also creates a contents object to hold its contents

Definition at line 1275 of file class.pdf.php.

References $numObj, $options, o_contents(), and o_pages().

Referenced by addObject(), newDocument(), newPage(), and o_annotation().

## ◆ o_pages()

Cpdf::o_pages | ( |  | $id,
|  |  | $action,
|  |  | $options = `''`
| ) |  |

object which is a parent to the pages in the document

Definition at line 409 of file class.pdf.php.

References $options, and o_catalog().

Referenced by newDocument(), o_font(), o_image(), o_page(), o_procset(), and o_shading().

## ◆ o_pattern()

Cpdf::o_pattern | ( |  | $id,
|  |  | $action,
|  |  | $options = `''`
| ) |  |

Add object to hold pattern properties

Parameters

  object | id.
  action |
  options |

Returns
  action 'new' - dictionary name 'out' - pdf output

Definition at line 667 of file class.pdf.php.

References $options.

## ◆ o_procset()

Cpdf::o_procset | ( |  | $id,
|  |  | $action,
|  |  | $options = `''`
| ) |  |

the document procset, solves some problems with printing to old PS printers

Definition at line 1061 of file class.pdf.php.

References $options, and o_pages().

Referenced by newDocument(), and o_image().

## ◆ o_shading()

Cpdf::o_shading | ( |  | $id,
|  |  | $action,
|  |  | $options = `''`
| ) |  |

Add object to hold shading properties

Parameters

  object | id.
  action |
  options |

Returns
  action 'new' - dictionary name 'out' - pdf output

Definition at line 748 of file class.pdf.php.

References $numObj, $options, o_function(), o_pages(), eZMath\rgbToCMYK(), and eZMath\rgbToCMYK2().

Referenced by shadedRectangle().

## ◆ o_viewerPreferences()

Cpdf::o_viewerPreferences | ( |  | $id,
|  |  | $action,
|  |  | $options = `''`
| ) |  |

set the viewer preferences

Definition at line 311 of file class.pdf.php.

References $options.

Referenced by o_catalog().

## ◆ openFont()

Cpdf::openFont | ( |  | $font | ) |

open the font file and return a php structure containing it. first check if this one has been done before and saved in a form more suited to php note that if a php serialized version does not exist it will try and make one, but will require write access to the directory to do it... it is MUCH faster to have these serialized files.

@access private

Definition at line 1762 of file class.pdf.php.

References addMessage().

Referenced by selectFont().

## ◆ openHere()

Cpdf::openHere | ( |  | $style,
|  |  | $a = `0`,
|  |  | $b = `0`,
|  |  | $c = `0`
| ) |  |

specify where the document should open when it first starts

Definition at line 3933 of file class.pdf.php.

References $catalogId, o_catalog(), and o_destination().

## ◆ openObject()

Cpdf::openObject | ( |  | ) |

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 number

Definition at line 3389 of file class.pdf.php.

References $nStack, $numObj, and o_contents().

## ◆ output()

Cpdf::output | ( |  | $debug = `0` | ) |

return the pdf stream as a string returned from the function

Definition at line 1674 of file class.pdf.php.

References ARC4_init(), and checkAllHere().

Referenced by stream().

## ◆ partEllipse()

Cpdf::partEllipse | ( |  | $x0,
|  |  | $y0,
|  |  | $astart,
|  |  | $afinish,
|  |  | $r1,
|  |  | $r2 = `0`,
|  |  | $angle = `0`,
|  |  | $nSeg = `8`
| ) |  |

draw a part of an ellipse

Definition at line 2273 of file class.pdf.php.

References ellipse().

## ◆ polygon()

Cpdf::polygon | ( |  | $p,
|  |  | $np,
|  |  | $f = `0`
| ) |  |

draw a polygon, the syntax for this is similar to the GD polygon command

Definition at line 2420 of file class.pdf.php.

References $currentContents.

## ◆ popTextState()

Cpdf::popTextState | ( |  | ) |

Pop text stack, and set to previous state.

Definition at line 4111 of file class.pdf.php.

References setCurrentFont().

Referenced by getTextWidth().

## ◆ PRVT_getBytes()

Cpdf::PRVT_getBytes | ( | & | $data,
|  |  | $pos,
|  |  | $num
| ) |  |

extract an integer from a position in a byte stream

@access private

Definition at line 3547 of file class.pdf.php.

Referenced by addPngFromFile().

## ◆ PRVTadjustWrapText()

Cpdf::PRVTadjustWrapText | ( |  | $text,
|  |  | $actual,
|  |  | $width,
|  | & | $x,
|  | & | $adjust,
|  |  | $justification
| ) |  |

do a part of the calculation for sorting out the justification of the text

@access private

Definition at line 3113 of file class.pdf.php.

Referenced by addTextWrap().

## ◆ PRVTcheckTextDirective()

Cpdf::PRVTcheckTextDirective | ( | & | $text,
|  |  | $i,
|  | & | $f,
|  |  | $final = `0`
| ) |  |

wrapper function for PRVTcheckTextDirective1

@access private

Definition at line 2677 of file class.pdf.php.

References PRVTcheckTextDirective1().

Referenced by addText(), addTextWrap(), and getTextWidth().

## ◆ PRVTcheckTextDirective1()

Cpdf::PRVTcheckTextDirective1 | ( | & | $text,
|  |  | $i,
|  | & | $f,
|  |  | $final,
|  | & | $x,
|  | & | $y,
|  |  | $size = `0`,
|  |  | $angle = `0`,
|  |  | $wordSpaceAdjust = `0`
| ) |  |

checks if the text stream contains a control directive if so then makes some changes and returns the number of characters involved in the directive this has been re-worked to include everything neccesary to fins the current writing point, so that the location can be sent to the callback function if required if the directive does not require a font change, then $f should be set to 0

@access private

Definition at line 2693 of file class.pdf.php.

References $currentTextState, $nCallback, $wordSpaceAdjust, getFontDecender(), getFontHeight(), and PRVTgetTextPosition().

Referenced by addText(), and PRVTcheckTextDirective().

## ◆ PRVTgetTextPosition()

Cpdf::PRVTgetTextPosition | ( |  | $x,
|  |  | $y,
|  |  | $angle,
|  |  | $size,
|  |  | $wa,
|  |  | $text
| ) |  |

given a start position and information about how text is to be laid out, calculate where on the page the text will end

@access private

Definition at line 2654 of file class.pdf.php.

References getTextWidth().

Referenced by addText(), and PRVTcheckTextDirective1().

## ◆ pushTextState()

Cpdf::pushTextState | ( |  | $newState | ) |

Push current text state, and set specified to current

Parameters

  new | text state

Definition at line 4101 of file class.pdf.php.

References $currentTextState, and setCurrentFont().

Referenced by getTextWidth().

## ◆ rectangle()

Cpdf::rectangle | ( |  | $x1,
|  |  | $y1,
|  |  | $width,
|  |  | $height
| ) |  |

draw a rectangle, note that it is the width and height of the rectangle which are the secondary paramaters, not the coordinates of the upper-right corner

Definition at line 2479 of file class.pdf.php.

References $currentContents.

## ◆ reopenObject()

Cpdf::reopenObject | ( |  | $id | ) |

open an existing object for editing

Definition at line 3406 of file class.pdf.php.

References $nStack.

## ◆ restoreState()

Cpdf::restoreState | ( |  | $pageEnd = `0` | ) |

restore a previously saved state

Definition at line 3368 of file class.pdf.php.

References $currentContents, and $nStateStack.

Referenced by newPage(), and shadedRectangle().

## ◆ saveState()

Cpdf::saveState | ( |  | $pageEnd = `0` | ) |

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

Definition at line 3342 of file class.pdf.php.

References $currentContents, $nStateStack, setColor(), and setStrokeColor().

Referenced by newPage(), and shadedRectangle().

## ◆ selectFont()

Cpdf::selectFont | ( |  | $fontName,
|  |  | $encoding = `''`,
|  |  | $set = `1`
| ) |  |

if the font is not loaded then load it and make the required object else just make it the current font the encoding array can contain 'encoding'=> 'none','WinAnsiEncoding','MacRomanEncoding' or 'MacExpertEncoding' note that encoding='none' will need to be used for symbolic fonts and 'differences' => an array of mappings between numbers 0->255 and character names.

Definition at line 1897 of file class.pdf.php.

References $currentFontNum, $numFonts, $numObj, $options, addMessage(), o_contents(), o_font(), o_fontDescriptor(), openFont(), setCurrentFont(), and setFontFamily().

Referenced by addText(), addTextWrap(), getFontDecender(), getFontHeight(), getTextWidth(), and setCurrentFont().

## ◆ setColor()

Cpdf::setColor | ( |  | $cmykArray,
|  |  | $force = `0`
| ) |  |

sets the colour for fill operations

Parameters

  CMYK | array

Definition at line 2215 of file class.pdf.php.

References $currentContents, and compareCMYK().

Referenced by newPage(), saveState(), and setColorRGB().

## ◆ setColorRGB()

Cpdf::setColorRGB | ( |  | $r,
|  |  | $g,
|  |  | $b,
|  |  | $force = `0`
| ) |  |

sets the colour for fill operations

Definition at line 2205 of file class.pdf.php.

References eZMath\rgbToCMYK2(), and setColor().

## ◆ setCurrentFont()

Cpdf::setCurrentFont | ( |  | ) |

sets up the current font, based on the font families, and the current text state note that this system is quite flexible, a font can be completely different to a font, and even will have to be defined within the family to have meaning This function is to be called whenever the currentTextState is changed, it will update the currentFont setting to whatever the appropriatte family one is. If the user calls selectFont themselves then that will reset the currentBaseFont, and the currentFont This function will change the currentFont to whatever it should be, but will not change the currentBaseFont.

@access private

Definition at line 2153 of file class.pdf.php.

References $currentBaseFont, $currentFont, $currentTextState, currentFont(), and selectFont().

Referenced by addText(), addTextWrap(), getTextWidth(), popTextState(), pushTextState(), and selectFont().

## ◆ setEncryption()

Cpdf::setEncryption | ( |  | $userPass = `''`,
|  |  | $ownerPass = `''`,
|  |  | $pc = `array()`
| ) |  |

set the encryption of the document can be used to turn it on and/or set the passwords which it will have. also the functions that the user will have are set here, such as print, modify, add

Definition at line 1638 of file class.pdf.php.

References $options, and o_encryption().

## ◆ setFontFamily()

Cpdf::setFontFamily | ( |  | $family,
|  |  | $options = `''`
| ) |  |

define font families, this is used to initialize the font families for the default fonts and for the user to add new ones for their fonts. The default bahavious can be overridden should that be desired.

Definition at line 3975 of file class.pdf.php.

References $options.

Referenced by __construct(), and selectFont().

## ◆ setLineStyle()

Cpdf::setLineStyle | ( |  | $width = `1`,
|  |  | $cap = `''`,
|  |  | $join = `''`,
|  |  | $dash = `''`,
|  |  | $phase = `0`
| ) |  |

this sets the line drawing style. width, is the thickness of the line in user units cap is the type of cap to put on the line, values can be 'butt','round','square' where the diffference between 'square' and 'butt' is that 'square' projects a flat end past the end of the line. join can be 'miter', 'round', 'bevel' dash is an array which sets the dash pattern, is a series of length values, which are the lengths of the on and off dashes. (2) represents 2 on, 2 off, 2 on , 2 off ... (2,1) is 2 on, 1 off, 2 on, 1 off.. etc phase is a modifier on the dash pattern which is used to shift the point at which the pattern starts.

Definition at line 2385 of file class.pdf.php.

References $currentContents.

## ◆ setPreferences()

Cpdf::setPreferences | ( |  | $label,
|  |  | $value = `0`
| ) |  |

set the viewer preferences of the document, it is up to the browser to obey these.

Definition at line 3526 of file class.pdf.php.

References o_catalog().

## ◆ setStrokeColor()

Cpdf::setStrokeColor | ( |  | $cmykArray,
|  |  | $force = `0`
| ) |  |

sets the colour for stroke operations

Parameters

  cmyk | array
  force | color change

Definition at line 2240 of file class.pdf.php.

References $currentContents, and compareCMYK().

Referenced by newPage(), saveState(), and setStrokeColorRGB().

## ◆ setStrokeColorRGB()

Cpdf::setStrokeColorRGB | ( |  | $r,
|  |  | $g,
|  |  | $b,
|  |  | $force = `0`
| ) |  |

sets the colour for stroke operations

Definition at line 2229 of file class.pdf.php.

References eZMath\rgbToCMYK2(), and setStrokeColor().

## ◆ shadedRectangle()

Cpdf::shadedRectangle | ( |  | $x1,
|  |  | $y1,
|  |  | $width,
|  |  | $height,
|  |  | $options
| ) |  |

Create shaded rectangle area

Parameters

  x1 |
  x2 |
  width |
  height |
  options | array ( 'orientation' => <vertical|horizontal ( optianal )>, 'color0' => <CMYK color array>, 'color1' => <CMYK color array> )

Definition at line 2450 of file class.pdf.php.

References $currentContents, $options, o_shading(), restoreState(), and saveState().

## ◆ stopObject()

Cpdf::stopObject | ( |  | $id | ) |

stop an object from appearing on pages from this point on

Definition at line 3439 of file class.pdf.php.

## ◆ stream()

Cpdf::stream | ( |  | $options = `''` | ) |

output the pdf code, streaming it to the browser the relevant headers are set so that hopefully the browser will recognise it

Definition at line 2546 of file class.pdf.php.

References $options, eZExecution\cleanExit(), and output().

## ◆ transaction()

Cpdf::transaction | ( |  | $action | ) |

a few functions which should allow the document to be treated transactionally.

Definition at line 4026 of file class.pdf.php.

References $checkpoint.

## Member Data Documentation

## ◆ $addLooseObjects

Cpdf::$addLooseObjects = array()

array contains infomation about how the loose objects are to be added to the document

Definition at line 131 of file class.pdf.php.

## ◆ $arc4

Cpdf::$arc4 = ''

the ancryption array for the document encryption is stored here

Definition at line 186 of file class.pdf.php.

Referenced by ARC4().

## ◆ $arc4_objnum

Cpdf::$arc4_objnum = 0

the object Id of the encryption information

Definition at line 191 of file class.pdf.php.

## ◆ $callback

Cpdf::$callback = array()

array which forms a stack to keep track of nested callback functions

Definition at line 211 of file class.pdf.php.

## ◆ $catalogId

Cpdf::$catalogId

the objectId (number within the objects array) of the document catalog

Definition at line 38 of file class.pdf.php.

Referenced by openHere().

## ◆ $checkpoint

Cpdf::$checkpoint = ''

store the stack for the transaction commands, each item in here is a record of the values of all the variables within the class, so that the user can rollback at will (from each 'start' command) note that this includes the objects array, so these can be large.

Definition at line 229 of file class.pdf.php.

Referenced by transaction().

## ◆ $currentBaseFont

Cpdf::$currentBaseFont = ''

the current base font

Definition at line 54 of file class.pdf.php.

Referenced by currentFont(), and setCurrentFont().

## ◆ $currentColour

Cpdf::$currentColour

current colour for fill operations, defaults to inactive value, all three components should be between 0 and 1 inclusive when active

Definition at line 84 of file class.pdf.php.

## ◆ $currentContents

Cpdf::$currentContents

object number of the currently active contents block

Definition at line 74 of file class.pdf.php.

Referenced by addContent(), addJpegImage_common(), addObject(), addPngFromFile(), addText(), curve(), ellipse(), filledRectangle(), line(), newDocument(), newPage(), polygon(), rectangle(), restoreState(), saveState(), setColor(), setLineStyle(), setStrokeColor(), and shadedRectangle().

## ◆ $currentFont

Cpdf::$currentFont = ''

a record of the current font

Definition at line 49 of file class.pdf.php.

Referenced by addTextWrap(), getFontDecender(), getFontHeight(), getTextWidth(), and setCurrentFont().

## ◆ $currentFontNum

Cpdf::$currentFontNum = 0

the number of the current font within the font array

Definition at line 59 of file class.pdf.php.

Referenced by selectFont().

## ◆ $currentLineStyle

Cpdf::$currentLineStyle = ''

current style that lines are drawn in

Definition at line 94 of file class.pdf.php.

## ◆ $currentNode

Cpdf::$currentNode

Definition at line 64 of file class.pdf.php.

## ◆ $currentPage

Cpdf::$currentPage

object number of the current page

Definition at line 69 of file class.pdf.php.

Referenced by o_annotation().

## ◆ $currentStrokeColour

Cpdf::$currentStrokeColour

current colour for stroke operations (lines etc.)

Definition at line 89 of file class.pdf.php.

## ◆ $currentTextState

Cpdf::$currentTextState = ''

track if the current font is bolded or italicised

Definition at line 176 of file class.pdf.php.

Referenced by addTextWrap(), PRVTcheckTextDirective1(), pushTextState(), and setCurrentFont().

## ◆ $destinations

Cpdf::$destinations = array()

store label->id pairs for named destinations, these will be used to replace internal links done this way so that destinations can be defined after the location that links to them

Definition at line 222 of file class.pdf.php.

## ◆ $encrypted

Cpdf::$encrypted = 0

a flag to say if a document is to be encrypted or not

Definition at line 201 of file class.pdf.php.

## ◆ $encryptionKey

Cpdf::$encryptionKey = ''

the ancryption key for the encryption of all the document content (structure is not encrypted)

Definition at line 206 of file class.pdf.php.

Referenced by encryptInit().

## ◆ $ez

Cpdf::$ez

Definition at line 20 of file class.pdf.php.

## ◆ $fileIdentifier

Cpdf::$fileIdentifier = ''

the file identifier, used to uniquely identify a pdf document

Definition at line 196 of file class.pdf.php.

## ◆ $firstPageId

Cpdf::$firstPageId

the objectId of the first page of the document

Definition at line 153 of file class.pdf.php.

Referenced by getFirstPageId().

## ◆ $fontFamilies

Cpdf::$fontFamilies = array()

store the information about the relationship between font families this used so that the code knows which font is the bold version of another font, etc. the value of this array is initialised in the constuctor function.

Definition at line 171 of file class.pdf.php.

## ◆ $fonts

Cpdf::$fonts = array()

array carrying information about the fonts that the system currently knows about used to ensure that a font is not loaded twice, among other things

Definition at line 44 of file class.pdf.php.

## ◆ $infoObject

Cpdf::$infoObject = 0

the objectId of the information object for the document this contains authorship, title etc.

Definition at line 137 of file class.pdf.php.

## ◆ $looseObjects

Cpdf::$looseObjects = array()

an array which contains information about the objects which are not firmly attached to pages these have been added with the addObject function

Definition at line 126 of file class.pdf.php.

## ◆ $messages

Cpdf::$messages = ''

messages are stored here during processing, these can be selected afterwards to give some useful debug information

Definition at line 181 of file class.pdf.php.

## ◆ $nCallBack

Cpdf::$nCallBack

Definition at line 24 of file class.pdf.php.

## ◆ $nCallback

Cpdf::$nCallback = 0

the number of callback functions in the callback array

Definition at line 216 of file class.pdf.php.

Referenced by PRVTcheckTextDirective1().

## ◆ $nStack

Cpdf::$nStack = 0

number of elements within the object Id storage stack

Definition at line 120 of file class.pdf.php.

Referenced by closeObject(), openObject(), and reopenObject().

## ◆ $nStateStack

Cpdf::$nStateStack = 0

number of elements within the state stack

Definition at line 105 of file class.pdf.php.

Referenced by newPage(), restoreState(), and saveState().

## ◆ $numFonts

Cpdf::$numFonts = 0

number of fonts within the system

Definition at line 79 of file class.pdf.php.

Referenced by o_font(), and selectFont().

## ◆ $numImages

Cpdf::$numImages = 0

number of images being tracked within the document

Definition at line 142 of file class.pdf.php.

Referenced by addJpegImage_common(), and addPngFromFile().

## ◆ $numObj

Cpdf::$numObj = 0

the current number of pdf objects in the document

Definition at line 28 of file class.pdf.php.

Referenced by addDestination(), o_annotation(), o_catalog(), o_font(), o_image(), o_page(), o_shading(), openObject(), and selectFont().

## ◆ $numPages

Cpdf::$numPages = 0

number of page objects within the document

Definition at line 110 of file class.pdf.php.

## ◆ $objects

Cpdf::$objects = array()

this array contains all of the pdf objects, ready for final assembly

Definition at line 33 of file class.pdf.php.

## ◆ $options

Cpdf::$options = array( 'compression' => 1 )

an array containing options about the document it defaults to turning on the compression of the objects

Definition at line 148 of file class.pdf.php.

Referenced by addObject(), addPngFromFile(), o_action(), o_annotation(), o_catalog(), o_contents(), o_destination(), o_encryption(), o_font(), o_fontDescriptor(), o_fontEncoding(), o_function(), o_image(), o_info(), o_outlines(), o_page(), o_pages(), o_pattern(), o_procset(), o_shading(), o_viewerPreferences(), selectFont(), setEncryption(), setFontFamily(), shadedRectangle(), and stream().

## ◆ $procsetObjectId

Cpdf::$procsetObjectId

the object Id of the procset object

Definition at line 164 of file class.pdf.php.

## ◆ $stack

Cpdf::$stack = array()

object Id storage stack

Definition at line 115 of file class.pdf.php.

## ◆ $stateStack

Cpdf::$stateStack = array()

an array which is used to save the state of the document, mainly the colours and styles it is used to temporarily change to another state, the change back to what it was before

Definition at line 100 of file class.pdf.php.

## ◆ $textStateStack

Cpdf::$textStateStack = array( '' )

Definition at line 4117 of file class.pdf.php.

## ◆ $wordSpaceAdjust

Cpdf::$wordSpaceAdjust = 0

used to track the last used value of the inter-word spacing, this is so that it is known when the spacing is changed.

Definition at line 159 of file class.pdf.php.

Referenced by addText(), and PRVTcheckTextDirective1().

The documentation for this class was generated from the following file:

- class.pdf.php

Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.