[ Index ]

PHP Cross Reference of osCMax 2.0.4




/admin/includes/modules/batch_print/ -> class.pdf.php (summary)

(no description)

File Size: 3075 lines (100 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

Cpdf:: (74 methods):

Class: Cpdf  - X-Ref



A PHP class to provide the basic functionality to create a pdf document without
any requirement for additional modules.

Note that they companion class CezPdf can be used to extend this class and dramatically
simplify the creation of documents.

there is no warranty, implied or otherwise with this software.

This code has been placed in the Public Domain for all to enjoy.

Cpdf($pageSize=array(0,0,612,792)   X-Ref
class constructor
this will start a new document

o_destination($id,$action,$options='')   X-Ref
destination object, used to specify the location for the user to jump to, presently on opening

o_viewerPreferences($id,$action,$options='')   X-Ref
set the viewer preferences

o_catalog($id,$action,$options='')   X-Ref
define the document catalog, the overall controller for the document

o_pages($id,$action,$options='')   X-Ref
object which is a parent to the pages in the document

o_outlines($id,$action,$options='')   X-Ref
define the outlines in the doc, empty for now

o_font($id,$action,$options='')   X-Ref
an object to hold the font description

o_fontDescriptor($id,$action,$options='')   X-Ref
a font descriptor, needed for including additional fonts

o_fontEncoding($id,$action,$options='')   X-Ref
the font encoding

o_procset($id,$action,$options='')   X-Ref
the document procset, solves some problems with printing to old PS printers

o_info($id,$action,$options='')   X-Ref
define the document information

o_action($id,$action,$options='')   X-Ref
an action object, used to link to URLS initially

o_annotation($id,$action,$options='')   X-Ref
an annotation object, this will add an annotation to the current page.
initially will support just link annotations

o_page($id,$action,$options='')   X-Ref
a page object, it also creates a contents object to hold its contents

o_contents($id,$action,$options='')   X-Ref
the contents objects hold all of the content which appears on pages

o_image($id,$action,$options='')   X-Ref
an image object, will be an XObject in the document, includes description and data

o_encryption($id,$action,$options='')   X-Ref
encryption object.

md5_16($string)   X-Ref
calculate the 16 byte version of the 128 bit md5 digest of the string

encryptInit($id)   X-Ref
initialize the encryption for processing a particular object

ARC4_init($key='')   X-Ref
initialize the ARC4 encryption

ARC4($text)   X-Ref
ARC4 encrypt a text string

addLink($url,$x0,$y0,$x1,$y1)   X-Ref
add a link in the document to an external URL

addInternalLink($label,$x0,$y0,$x1,$y1)   X-Ref
add a link in the document to an internal destination (ie. within the document)

setEncryption($userPass='',$ownerPass='',$pc=array()   X-Ref
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

checkAllHere()   X-Ref
should be used for internal checks, not implemented as yet

output($debug=0)   X-Ref
return the pdf stream as a string returned from the function

newDocument($pageSize=array(0,0,612,792)   X-Ref
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

openFont($font)   X-Ref
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

selectFont($fontName,$encoding='',$set=1)   X-Ref
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.

setCurrentFont()   X-Ref
sets up the current font, based on the font families, and the current text state
note that this system is quite flexible, a <b><i> font can be completely different to a
<i><b> font, and even <b><b> 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

getFirstPageId()   X-Ref
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.

addContent($content)   X-Ref
add content to the currently active object

setColor($r,$g,$b,$force=0)   X-Ref
sets the colour for fill operations

setStrokeColor($r,$g,$b,$force=0)   X-Ref
sets the colour for stroke operations

line($x1,$y1,$x2,$y2)   X-Ref
draw a line from one set of coordinates to another

curve($x0,$y0,$x1,$y1,$x2,$y2,$x3,$y3)   X-Ref
draw a bezier curve based on 4 control points

partEllipse($x0,$y0,$astart,$afinish,$r1,$r2=0,$angle=0,$nSeg=8)   X-Ref
draw a part of an ellipse

filledEllipse($x0,$y0,$r1,$r2=0,$angle=0,$nSeg=8,$astart=0,$afinish=360)   X-Ref
draw a filled ellipse

ellipse($x0,$y0,$r1,$r2=0,$angle=0,$nSeg=8,$astart=0,$afinish=360,$close=1,$fill=0)   X-Ref
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.

setLineStyle($width=1,$cap='',$join='',$dash='',$phase=0)   X-Ref
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.

polygon($p,$np,$f=0)   X-Ref
draw a polygon, the syntax for this is similar to the GD polygon command

filledRectangle($x1,$y1,$width,$height)   X-Ref
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

rectangle($x1,$y1,$width,$height)   X-Ref
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

newPage($insert=0,$id=0,$pos='after')   X-Ref
add a new page to the document
this also makes the new page the current active object

stream($options='')   X-Ref
output the pdf code, streaming it to the browser
the relevant headers are set so that hopefully the browser will recognise it

getFontHeight($size)   X-Ref
return the height in units of the current font in the given size

getFontDecender($size)   X-Ref
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

filterText($text)   X-Ref
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

PRVTgetTextPosition($x,$y,$angle,$size,$wa,$text)   X-Ref
given a start position and information about how text is to be laid out, calculate where
on the page the text will end

PRVTcheckTextDirective(&$text,$i,&$f)   X-Ref
wrapper function for PRVTcheckTextDirective1

PRVTcheckTextDirective1(&$text,$i,&$f,$final,&$x,&$y,$size=0,$angle=0,$wordSpaceAdjust=0)   X-Ref
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

addText($x,$y,$size,$text,$angle=0,$wordSpaceAdjust=0)   X-Ref
add text to the document, at a specified location, size and angle on the page

getTextWidth($size,$text)   X-Ref
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

PRVTadjustWrapText($text,$actual,$width,&$x,&$adjust,$justification)   X-Ref
do a part of the calculation for sorting out the justification of the text

addTextWrap($x,$y,$width,$size,$text,$justification='left',$angle=0,$test=0)   X-Ref
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

saveState($pageEnd=0)   X-Ref
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

restoreState($pageEnd=0)   X-Ref
restore a previously saved state

openObject()   X-Ref
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

reopenObject($id)   X-Ref
open an existing object for editing

closeObject()   X-Ref
close an object

stopObject($id)   X-Ref
stop an object from appearing on pages from this point on

addObject($id,$options='add')   X-Ref
after an object has been created, it wil only show if it has been added, using this function.

addInfo($label,$value=0)   X-Ref
add content to the documents info object

setPreferences($label,$value=0)   X-Ref
set the viewer preferences of the document, it is up to the browser to obey these.

PRVT_getBytes(&$data,$pos,$num)   X-Ref
extract an integer from a position in a byte stream

addPngFromFile($file,$x,$y,$w=0,$h=0)   X-Ref
add a PNG image into the document, from a file
this should work with remote files

addJpegFromFile($img,$x,$y,$w=0,$h=0)   X-Ref
add a JPEG image into the document, from a file

addImage(&$img,$x,$y,$w=0,$h=0,$quality=75)   X-Ref
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

addJpegImage_common(&$data,$x,$y,$w=0,$h=0,$imageWidth,$imageHeight,$channels=3)   X-Ref
common code used by the two JPEG adding functions

openHere($style,$a=0,$b=0,$c=0)   X-Ref
specify where the document should open when it first starts

addDestination($label,$style,$a=0,$b=0,$c=0)   X-Ref
create a labelled destination within the document

setFontFamily($family,$options='')   X-Ref
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.

addMessage($message)   X-Ref
used to add messages for use in debugging

transaction($action)   X-Ref
a few functions which should allow the document to be treated transactionally.

Generated: Fri Jan 1 13:43:16 2010 Cross-referenced by PHPXref 0.7