\Cpdf
Synopsis
class Cpdf
{
- // members
- public integer $numObj = 0;
- public array $objects = ;
- public $catalogId;
- public array $fonts = ;
- public string $defaultFont = './fonts/Helvetica.afm';
- public string $currentFont = '';
- public string $currentBaseFont = '';
- public integer $currentFontNum = 0;
- public $currentNode;
- public $currentPage;
- public $currentContents;
- public integer $numFonts = 0;
- private integer $numStates = 0;
- private array $gstates = ;
- public $currentColor = NULL;
- public $currentStrokeColor = NULL;
- public string $fillRule = "nonzero";
- public string $currentLineStyle = '';
- public array $currentLineTransparency = ;
- public array $currentFillTransparency = ;
- public array $stateStack = ;
- public integer $nStateStack = 0;
- public integer $numPages = 0;
- public array $stack = ;
- public integer $nStack = 0;
- public array $looseObjects = ;
- public array $addLooseObjects = ;
- public integer $infoObject = 0;
- public integer $numImages = 0;
- public array $options = ;
- public $firstPageId;
- public $procsetObjectId;
- public array $fontFamilies = ;
- public string $fontcache = '';
- public integer $fontcacheVersion = 6;
- public string $tmp = '';
- public string $currentTextState = '';
- public string $messages = '';
- public string $arc4 = '';
- public integer $arc4_objnum = 0;
- public string $fileIdentifier = '';
- public boolean $encrypted = false;
- public string $encryptionKey = '';
- public array $callback = ;
- public integer $nCallback = 0;
- public array $destinations = ;
- public string $checkpoint = '';
- public array $imagelist = ;
- public boolean $isUnicode = false;
- public string $javascript = '';
- protected boolean $compressionReady = false;
- protected array $currentPageSize = ;
- protected array $stringSubsets = ;
- protected static string $targetEncoding = 'Windows-1252';
- protected static array $coreFonts = ;
- // methods
- public void __construct()
- protected string|null o_destination()
- protected string|null o_viewerPreferences()
- protected string|null o_catalog()
- protected string|null o_pages()
- protected string|null o_outlines()
- protected string|null o_font()
- protected null|string o_toUnicode()
- protected null|string o_fontDescriptor()
- protected null|string o_fontEncoding()
- protected null|string o_fontDescendentCID()
- protected null|string o_cidSystemInfo()
- protected null|string o_fontGIDtoCIDMap()
- protected null|string o_procset()
- protected null|string o_info()
- protected null|string o_action()
- protected null|string o_annotation()
- protected null|string o_page()
- protected null|string o_contents()
- protected string|null o_embedjs()
- protected null|string o_javascript()
- protected null|string o_image()
- protected null|string o_extGState()
- protected string|null o_encryption()
- public string md5_16()
- public void encryptInit()
- public void ARC4_init()
- public string ARC4()
- public void addLink()
- public void addInternalLink()
- public void setEncryption()
- public void checkAllHere()
- public string output()
- private void newDocument()
- private void openFont()
- public int selectFont()
- private void setCurrentFont()
- public int getFirstPageId()
- private void addContent()
- public void setColor()
- public void setFillRule()
- public void setStrokeColor()
- public void setGraphicsState()
- public void setLineTransparency()
- public void setFillTransparency()
- public void line()
- public void curve()
- public void partEllipse()
- public void filledEllipse()
- public void lineTo()
- public void moveTo()
- public void curveTo()
- public void quadTo()
- public void closePath()
- public void endPath()
- public void ellipse()
- public void setLineStyle()
- public void polygon()
- public void filledRectangle()
- public void rectangle()
- public void rect()
- public void stroke()
- public void fill()
- public void fillStroke()
- public void save()
- public void restore()
- public void clippingRectangle()
- public void clippingRectangleRounded()
- public void clippingEnd()
- public void scale()
- public void translate()
- public void rotate()
- public void skew()
- public void transform()
- public int newPage()
- public void stream()
- public float|int getFontHeight()
- public float|int getFontXHeight()
- public float|int getFontDescender()
- public string filterText()
- public array utf8toCodePointsArray()
- public string utf8toUtf16BE()
- private array getTextPosition()
- public string toUpper()
- public void concatMatches()
- public void registerText()
- public void addText()
- public float|int getTextWidth()
- public void saveState()
- public void restoreState()
- public int openObject()
- public void reopenObject()
- public void closeObject()
- public void stopObject()
- public void addObject()
- public string|null serializeObject()
- public int restoreSerializedObject()
- public void addInfo()
- public void setPreferences()
- private int getBytes()
- public bool image_iscached()
- public void addImagePng()
- protected void addImagePngAlpha()
- public void addPngFromFile()
- public void addSvgFromFile()
- public void addPngFromBuf()
- public void addJpegFromFile()
- private void addJpegImage_common()
- public void openHere()
- public void addJavascript()
- public void addDestination()
- public void setFontFamily()
- public void addMessage()
- public void transaction()
Members
private
- $gstates — array
- $numStates — integer
protected
- $compressionReady — boolean
- $coreFonts — array
- $currentPageSize — array
- $stringSubsets — array
- $targetEncoding — string
public
-
$addLooseObjects
array contains information about how the loose objects are to be added to the document - $arc4 — string
- $arc4_objnum — integer
- $callback — array
- $catalogId — integer
- $checkpoint — array
- $currentBaseFont — string
- $currentColor — array
- $currentContents — integer
-
$currentFillTransparency
array Current fill transparency (partial graphics state) - $currentFont
- $currentFontNum — integer
- $currentLineStyle — string
- $currentLineTransparency — array
- $currentNode — integer
- $currentPage — integer
- $currentStrokeColor — array
- $currentTextState — string
- $defaultFont — string
- $destinations — array
- $encrypted — boolean
- $encryptionKey — string
- $fileIdentifier — string
- $fillRule — string
- $firstPageId — integer
- $fontFamilies — array
- $fontcache — string
- $fontcacheVersion — integer
- $fonts — array
- $imagelist — array
- $infoObject — integer
- $isUnicode — boolean
- $javascript — string
-
$looseObjects
an array which contains information about the objects which are not firmly attached to pages these have been added with the addObject function - $messages — string
- $nCallback — integer
- $nStack — integer
- $nStateStack — integer
- $numFonts — integer
- $numImages — integer
- $numObj — integer
- $numPages — integer
- $objects — array
- $options — array
- $procsetObjectId — integer
- $stack — array
- $stateStack — array
- $tmp — string
Methods
private
- addContent() — add content to the currently active object
- addJpegImage_common() — common code used by the two JPEG adding functions
- getBytes() — extract an integer from a position in a byte stream
- getTextPosition() — given a start position and information about how text is to be laid out, calculate where on the page the text will end
- newDocument() — initialize 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() — open the font file and return a php structure containing it.
- setCurrentFont() — sets up the current font, based on the font families, and the current text state note that this system is quite flexible, a bold-italic font can be completely different to a italic-bold font, and even bold-bold 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 appropriate family one is.
protected
- addImagePngAlpha()
- o_action() — an action object, used to link to URLS initially
- o_annotation() — an annotation object, this will add an annotation to the current page.
- o_catalog() — define the document catalog, the overall controller for the document
- o_cidSystemInfo() — CID system info section, needed for unicode fonts
- o_contents() — the contents objects hold all of the content which appears on pages
- o_destination() — Destination object, used to specify the location for the user to jump to, presently on opening
- o_embedjs()
- o_encryption() — encryption object.
- o_extGState() — graphics state object
- o_font() — an object to hold the font description
- o_fontDescendentCID() — a descendent cid font, needed for unicode fonts
- o_fontDescriptor() — a font descriptor, needed for including additional fonts
- o_fontEncoding() — the font encoding
- o_fontGIDtoCIDMap() — a font glyph to character map, needed for unicode fonts
- o_image() — an image object, will be an XObject in the document, includes description and data
- o_info() — define the document information
- o_javascript()
- o_outlines() — define the outlines in the doc, empty for now
- o_page() — a page object, it also creates a contents object to hold its contents
- o_pages() — object which is a parent to the pages in the document
- o_procset() — the document procset, solves some problems with printing to old PS printers
- o_toUnicode() — A toUnicode section, needed for unicode fonts
- o_viewerPreferences() — set the viewer preferences
public
- __construct() — Class constructor This will start a new document
- ARC4() — ARC4 encrypt a text string
- ARC4_init() — initialize the ARC4 encryption
- addDestination() — create a labelled destination within the document
- addImagePng() — add a PNG image into the document, from a GD object this should work with remote files
- addInfo() — add content to the documents info object
- addInternalLink() — add a link in the document to an internal destination (ie. within the document)
- addJavascript() — Add JavaScript code to the PDF document
- addJpegFromFile() — add a JPEG image into the document, from a file
- addLink() — add a link in the document to an external URL
- addMessage() — used to add messages for use in debugging
- addObject() — after an object has been created, it wil only show if it has been added, using this function.
- addPngFromBuf() — add a PNG image into the document, from a memory buffer of the file
- addPngFromFile() — add a PNG image into the document, from a file this should work with remote files
- addSvgFromFile() — add a PNG image into the document, from a file this should work with remote files
- addText() — add text to the document, at a specified location, size and angle on the page
- checkAllHere() — should be used for internal checks, not implemented as yet
- clippingEnd() — ends the last clipping shape
- clippingRectangle() — draw a clipping rectangle, all the elements added after this will be clipped
- clippingRectangleRounded() — draw a clipping rounded rectangle, all the elements added after this will be clipped
- closeObject() — close an object
- closePath()
- concatMatches()
- curve() — draw a bezier curve based on 4 control points
- curveTo() — draw a bezier curve based on 4 control points
- ellipse() — draw an ellipse note that the part and filled ellipse are just special cases of this function
- encryptInit() — initialize the encryption for processing a particular object
- endPath()
- fill()
- fillStroke()
- filledEllipse() — draw a filled ellipse
- filledRectangle() — a filled rectangle, note that it is the width and height of the rectangle which are the secondary parameters, not the coordinates of the upper-right corner
- filterText() — 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
- 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.
- getFontDescender() — 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
- getFontHeight() — return the height in units of the current font in the given size
- getFontXHeight()
- getTextWidth() — calculate how wide a given text string will be on a page, at a given size.
- image_iscached() — Check if image already added to pdf image directory.
- line() — draw a line from one set of coordinates to another
- lineTo()
- md5_16() — calculate the 16 byte version of the 128 bit md5 digest of the string
- moveTo()
- newPage() — add a new page to the document this also makes the new page the current active object
- openHere() — specify where the document should open when it first starts
- openObject() — make a loose object, the output will go into this object, until it is closed, then will revert to the current one.
- output() — return the pdf stream as a string returned from the function
- partEllipse() — draw a part of an ellipse
- polygon() — draw a polygon, the syntax for this is similar to the GD polygon command
- quadTo() — draw a bezier curve based on 4 control points
- rect() — draw a rectangle, note that it is the width and height of the rectangle which are the secondary parameters, not the coordinates of the upper-right corner
- rectangle() — draw a rectangle, note that it is the width and height of the rectangle which are the secondary parameters, not the coordinates of the upper-right corner
- registerText() — register text for font subsetting
- reopenObject() — open an existing object for editing
- restore() — restore the last graphic state
- restoreSerializedObject() — restore an object from its stored representation. returns its new object id.
- restoreState() — restore a previously saved state
- rotate() — rotate
- save() — save the current graphic state
- saveState() — 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
- scale() — scale
- selectFont() — 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.
- serializeObject() — return a storable representation of a specific object
- setColor() — sets the color for fill operations
- setEncryption() — set the encryption of the document can be used to turn it on and/or set the passwords which it will have.
- setFillRule() — sets the color for fill operations
- setFillTransparency() — Set current blend mode & opacity for filled objects.
- setFontFamily() — 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.
- setGraphicsState() — Set the graphics state for compositions
- setLineStyle() — this sets the line drawing style.
- setLineTransparency() — Set current blend mode & opacity for lines.
- setPreferences() — set the viewer preferences of the document, it is up to the browser to obey these.
- setStrokeColor() — sets the color for stroke operations
- skew() — skew
- stopObject() — stop an object from appearing on pages from this point on
- stream() — Streams the PDF to the client.
- stroke()
- toUpper() — Callback method used by smallCaps
- transaction() — a few functions which should allow the document to be treated transactionally.
- transform() — apply graphic transformations
- translate() — translate
- utf8toCodePointsArray() — return array containing codepoints (UTF-8 character values) for the string passed in.
- utf8toUtf16BE() — convert UTF-8 to UTF-16 with an additional byte order marker at the front if required.