Class: Cpdf
Source Location: /phpDocumentor/Converters/PDF/default/class.pdf.php
Class Details
Class Variables
$addLooseObjects = array()
[line 114]
array contains infomation about how the loose objects are to be added to the document
$arc4 = ''
[line 159]
the ancryption array for the document encryption is stored here
$arc4_objnum = 0
[line 163]
the object Id of the encryption information
$callback = array()
[line 179]
array which forms a stack to keep track of nested callback functions
$catalogId =
[line 39]
the objectId (number within the objects array) of the document catalog
$checkpoint = ''
[line 194]
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.
$currentBaseFont = ''
[line 52]
the current base font
$currentColour = array('r'=>-1,'g'=>-1,'b'=>-1)
[line 76]
current colour for fill operations, defaults to inactive value, all three components should be between 0 and 1 inclusive when active
$currentContents =
[line 68]
object number of the currently active contents block
$currentFont = ''
[line 48]
a record of the current font
$currentFontNum = 0
[line 56]
the number of the current font within the font array
$currentLineStyle = ''
[line 84]
current style that lines are drawn in
$currentNode =
[line 60]
$currentPage =
[line 64]
object number of the current page
$currentStrokeColour = array('r'=>-1,'g'=>-1,'b'=>-1)
[line 80]
current colour for stroke operations (lines etc.)
$currentTextState = ''
[line 151]
track if the current font is bolded or italicised
$destinations = array()
[line 188]
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
$encrypted = 0
[line 171]
a flag to say if a document is to be encrypted or not
$encryptionKey = ''
[line 175]
the ancryption key for the encryption of all the document content (structure is not encrypted)
$fileIdentifier = ''
[line 167]
the file identifier, used to uniquely identify a pdf document
$firstPageId =
[line 132]
the objectId of the first page of the document
$fontFamilies = array()
[line 147]
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.
$fonts = array()
[line 44]
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
$infoObject = 0
[line 119]
the objectId of the information object for the document this contains authorship, title etc.
$looseObjects = array()
[line 110]
an array which contains information about the objects which are not firmly attached to pages these have been added with the addObject function
$messages = ''
[line 155]
messages are stored here during processing, these can be selected afterwards to give some useful debug information
$nCallback = 0
[line 183]
the number of callback functions in the callback array
$nStack = 0
[line 105]
number of elements within the object Id storage stack
$nStateStack = 0
[line 93]
number of elements within the state stack
$numFonts = 0
[line 72]
number of fonts within the system
$numImages = 0
[line 123]
number of images being tracked within the document
$numObj = 0
[line 31]
the current number of pdf objects in the document
$numPages = 0
[line 97]
number of page objects within the document
$objects = array()
[line 35]
this array contains all of the pdf objects, ready for final assembly
$options = array('compression'=>1)
[line 128]
an array containing options about the document it defaults to turning on the compression of the objects
$procsetObjectId =
[line 141]
the object Id of the procset object
$stack = array()
[line 101]
object Id storage stack
$stateStack = array()
[line 89]
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
$wordSpaceAdjust = 0
[line 137]
used to track the last used value of the inter-word spacing, this is so that it is known when the spacing is changed.
Class Methods
constructor Cpdf [line 200]
Cpdf Cpdf(
[
$pageSize = array(0,0,612,792)])
|
|
class constructor this will start a new document
Tags:
Parameters:
method addDestination [line 2972]
void addDestination(
$label,
$style, [
$a = 0], [
$b = 0], [
$c = 0])
|
|
create a labelled destination within the document
Parameters:
method addImage [line 2873]
void 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
Parameters:
method addInfo [line 2593]
void addInfo(
$label, [
$value = 0])
|
|
add content to the documents info object
Parameters:
method addInternalLink [line 1176]
void addInternalLink(
$label,
$x0,
$y0,
$x1,
$y1)
|
|
add a link in the document to an internal destination (ie. within the document)
Parameters:
method addJpegFromFile [line 2828]
void addJpegFromFile(
$img,
$x,
$y, [
$w = 0], [
$h = 0])
|
|
add a JPEG image into the document, from a file
Parameters:
method addLink [line 1167]
void addLink(
$url,
$x0,
$y0,
$x1,
$y1)
|
|
add a link in the document to an external URL
Parameters:
method addMessage [line 3025]
void addMessage(
$message)
|
|
used to add messages for use in debugging
Overridden in child classes as:
- phpdocpdf::addMessage()
Parameters:
method addObject [line 2547]
void addObject(
$id, [
$options = 'add'])
|
|
after an object has been created, it wil only show if it has been added, using this function.
Parameters:
method addPngFromFile [line 2640]
void addPngFromFile(
$file,
$x,
$y, [
$w = 0], [
$h = 0])
|
|
add a PNG image into the document, from a file this should work with remote files
Parameters:
method addText [line 2159]
void addText(
$x,
$y,
$size,
$text, [
$angle = 0], [
$wordSpaceAdjust = 0])
|
|
add text to the document, at a specified location, size and angle on the page
Parameters:
method addTextWrap [line 2334]
void 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
Parameters:
method ARC4 [line 1141]
ARC4 encrypt a text string
Parameters:
method ARC4_init [line 1115]
void ARC4_init(
[
$key = ''])
|
|
initialize the ARC4 encryption
Parameters:
method checkAllHere [line 1217]
should be used for internal checks, not implemented as yet
method closeObject [line 2521]
method curve [line 1685]
void curve(
$x0,
$y0,
$x1,
$y1,
$x2,
$y2,
$x3,
$y3)
|
|
draw a bezier curve based on 4 control points
Parameters:
method ellipse [line 1716]
void 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.
Parameters:
method encryptInit [line 1101]
initialize the encryption for processing a particular object
Parameters:
method filledEllipse [line 1702]
void filledEllipse(
$x0,
$y0,
$r1, [
$r2 = 0], [
$angle = 0], [
$nSeg = 8], [
$astart = 0], [
$afinish = 360])
|
|
draw a filled ellipse
Parameters:
method filledRectangle [line 1838]
void 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
Parameters:
method getFirstPageId [line 1642]
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.
method getFontDecender [line 1946]
void getFontDecender(
$size)
|
|
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
Parameters:
method getFontHeight [line 1932]
void getFontHeight(
$size)
|
|
return the height in units of the current font in the given size
Parameters:
method getTextWidth [line 2251]
void 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
Parameters:
method line [line 1678]
void line(
$x1,
$y1,
$x2,
$y2)
|
|
draw a line from one set of coordinates to another
Parameters:
method md5_16 [line 1089]
calculate the 16 byte version of the 128 bit md5 digest of the string
Parameters:
method newPage [line 1854]
void newPage(
[
$insert = 0], [
$id = 0], [
$pos = 'after'])
|
|
add a new page to the document this also makes the new page the current active object
Parameters:
method openHere [line 2952]
void openHere(
$style, [
$a = 0], [
$b = 0], [
$c = 0])
|
|
specify where the document should open when it first starts
Parameters:
method openObject [line 2493]
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
method output [line 1223]
void output(
[
$debug = 0])
|
|
return the pdf stream as a string returned from the function
Parameters:
method o_action [line 729]
void o_action(
$id,
$action, [
$options = ''])
|
|
an action object, used to link to URLS initially
Parameters:
method o_annotation [line 772]
void o_annotation(
$id,
$action, [
$options = ''])
|
|
an annotation object, this will add an annotation to the current page. initially will support just link annotations
Parameters:
method o_catalog [line 300]
void o_catalog(
$id,
$action, [
$options = ''])
|
|
define the document catalog, the overall controller for the document
Parameters:
method o_contents [line 893]
void o_contents(
$id,
$action, [
$options = ''])
|
|
the contents objects hold all of the content which appears on pages
Parameters:
method o_destination [line 227]
void o_destination(
$id,
$action, [
$options = ''])
|
|
destination object, used to specify the location for the user to jump to, presently on opening
Parameters:
method o_encryption [line 1018]
void o_encryption(
$id,
$action, [
$options = ''])
|
|
encryption object.
Parameters:
method o_font [line 478]
void o_font(
$id,
$action, [
$options = ''])
|
|
an object to hold the font description
Parameters:
method o_fontDescriptor [line 562]
void o_fontDescriptor(
$id,
$action, [
$options = ''])
|
|
a font descriptor, needed for including additional fonts
Parameters:
method o_fontEncoding [line 613]
void o_fontEncoding(
$id,
$action, [
$options = ''])
|
|
the font encoding
Parameters:
method o_image [line 943]
void o_image(
$id,
$action, [
$options = ''])
|
|
an image object, will be an XObject in the document, includes description and data
Parameters:
method o_info [line 685]
void o_info(
$id,
$action, [
$options = ''])
|
|
define the document information
Parameters:
method o_outlines [line 448]
void o_outlines(
$id,
$action, [
$options = ''])
|
|
define the outlines in the doc, empty for now
Parameters:
method o_page [line 824]
void o_page(
$id,
$action, [
$options = ''])
|
|
a page object, it also creates a contents object to hold its contents
Parameters:
method o_pages [line 350]
void o_pages(
$id,
$action, [
$options = ''])
|
|
object which is a parent to the pages in the document
Parameters:
method o_procset [line 650]
void o_procset(
$id,
$action, [
$options = ''])
|
|
the document procset, solves some problems with printing to old PS printers
Parameters:
method o_viewerPreferences [line 262]
void o_viewerPreferences(
$id,
$action, [
$options = ''])
|
|
set the viewer preferences
Parameters:
method partEllipse [line 1695]
void partEllipse(
$x0,
$y0,
$astart,
$afinish,
$r1, [
$r2 = 0], [
$angle = 0], [
$nSeg = 8])
|
|
draw a part of an ellipse
Parameters:
method polygon [line 1821]
void polygon(
$p,
$np, [
$f = 0])
|
|
draw a polygon, the syntax for this is similar to the GD polygon command
Parameters:
method rectangle [line 1846]
void 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
Parameters:
method reopenObject [line 2508]
open an existing object for editing
Parameters:
method restoreState [line 2474]
void restoreState(
[
$pageEnd = 0])
|
|
restore a previously saved state
Parameters:
method saveState [line 2450]
void 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
Parameters:
method selectFont [line 1420]
void 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.
Parameters:
method setColor [line 1658]
void setColor(
$r,
$g,
$b, [
$force = 0])
|
|
sets the colour for fill operations
Parameters:
method setEncryption [line 1187]
void 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
Parameters:
method setFontFamily [line 2988]
void 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.
Parameters:
method setLineStyle [line 1792]
void 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.
Parameters:
method setPreferences [line 2610]
void setPreferences(
$label, [
$value = 0])
|
|
set the viewer preferences of the document, it is up to the browser to obey these.
Parameters:
method setStrokeColor [line 1668]
void setStrokeColor(
$r,
$g,
$b, [
$force = 0])
|
|
sets the colour for stroke operations
Parameters:
method stopObject [line 2536]
stop an object from appearing on pages from this point on
Parameters:
method stream [line 1902]
void stream(
[
$options = ''])
|
|
output the pdf code, streaming it to the browser the relevant headers are set so that hopefully the browser will recognise it
Parameters:
method transaction [line 3032]
void transaction(
$action)
|
|
a few functions which should allow the document to be treated transactionally.
Parameters:
|
|