Contents
Introduction 1
Changes 1
version 009 1
version 008 1
version 007 2
version 006 2
version 005 3
version 004 3
notes from version 003 3
Use 3
Extensions 3
EZPDF Class Extension 5
Cezpdf 5
ezSetMargins 6
ezSetCmMargins 6
ezNewPage 6
ezInsertMode 6
ezSetY 6
ezSetDy 6
ezTable 7
ezText 10
ezImage 11
ezStartPageNumbers 12
ezWhatPageNumber 13
ezStopPageNumbers 14
ezOutput 14
ezStream 14
ezColumnsStart 14
ezColumnsStop 15
inline codes 15
Base Class Functions 17
addText 17
setColor 17
setStrokeColor 17
setLineStyle 18
line 18
curve 18
ellipse 19
partEllipse 19
polygon 20
filledRectangle 20
rectangle 20
newPage 21
getFirstPageId 21
stream 21
getFontHeight 21
getFontDecender 21
http://ros.co.nz/pdf - http://www.sourceforge.net/projects/pdf-php
getTextWidth 22
addTextWrap 22
saveState 22
restoreState 22
openObject 22
reopenObject 22
closeObject 23
addObject 23
stopObject 23
addInfo 23
setPreferences 23
addImage 23
addJpegFromFile 24
addPngFromFile 24
output 24
openHere 24
selectFont 25
setFontFamily 26
setEncryption 27
addLink 27
addInternalLink 27
addDestination 28
transaction 28
Misc 29
Callback functions 29
Units 30
FAQs 32
Whats all this crap I see, my page is broken ? 32
What page sizes can I use ? 32
What is this Call to undefined function: imagecreatefromjpeg() error about ? 32
Does this work with accented characters ? 33
How can I write the PDF file to a static file on the webserver? 33
How do I do Hello World? 33
Can I put the fonts directory somewhere else ? 34
Can I see the code behind the online demo ? 34
What values can I give for the setPreferences method labels? 35
my accented characters do not work with full justification? 36
I just get a blank page? 36
So what are the page sizes? 37
why am I getting this array_search() function missing? 37
I get an error which says bad value for BBOX in font! 37
How should I do debugging ?! 37
Is there a code example for writing the file to disk and redirecting? 38
How do I get the Euro character to show in my text? 39
How do I get the symbolic fonts (eg zapfdingbats) working? 40
How do I make a table from my database information? 40
http://ros.co.nz/pdf - http://www.sourceforge.net/projects/pdf-php
Introduction
This class is designed to provide a non-module, non-commercial alternative to dynamically creating
pdf documents from within PHP.
Obviously this will not be quite as quick as the module alternatives, but it is surprisingly fast, this
demonstration page is almost a worst case due to the large number of fonts which are displayed.
There are a number of features which can be within a Pdf document that it is not at the moment
possible to use with this class, but I feel that it is useful enough to be released.
This document describes the possible useful calls to the class, the readme.php file (which will create
this pdf) should be sufficient as an introduction.
Note that this document was generated using the demo script 'readme.php' which came with this
package.
Changes
version 009
- support for underlining in the ezPdf class (but only in the base class functions using the callback
function directly).
- improvements to the underlining of the links, so that it is sized and positioned better, will work with
angled text now.
- automatic column support.
- some improvements to the table functions. Can set row and column gaps. The table will not now
split rows across pages by default.
- addition of transaction control support to the base class (this is quite useful, recommend advanced
users take special note).
- numerous small bug fixes, including notably some bugs relating to the inclusion of fonts, especially
when using the differences array to take care of characters normally outside the default set.
version 008
changes to class.pdf.php:
- adjustment to the way that type 1 fonts are loaded to make them more reliable
- changes to that angled text can use bold and italic tags
- implemented file encryption, which gives the ability to restrict user cut and paste, or printing.
- added callback functions activated by text markers, see the misc section for full decription.
- allow object to be added on the 'next' page.
- extended the newPage function to allow insertion of extra pages between existing pages.
- adjustment to ellipse function to allow partial curves.
changes to class.ezpdf.php:
- made the column headings in the tables have the same alignment as the settings for the column data.
1 of 41
http://ros.co.nz/pdf - http://www.sourceforge.net/projects/pdf-php
- adjusted the size of an A4 page to be more accurate.
- fixed the table title alignment to stay centered on the table if the table position is fixed on the page
- used callback functions to add clickable links to the text.
- implemented a better algorithm for determining table widths when it needs to be shrunk to width.
- changed ezTable and ezText to return the y-position.
- made the page numbering system more functional.
- added insert page functionality.
- added link capability to tables, can specify one column to be links, using another column as URLs.
version 007
This is it - the james bond version - though all similarity ends with the name, but there are some funky
new features and a few bug fixes.
The ezTable features have been extended, it is now possible to define the justification of the
individual columns, and to specify colum widths as well as the width of the entire table.
You can now have extra fonts!. It is possible to add type 1 postscript fonts, or TrueType fonts.
Though note that for the postscript font you have to have both a .pfb file and a .afm file - but there are
free products out there which can convert a .pfa to a .pfb. Also to use a TrueType file you have to
have a corersponding .afm file as this is required to specify the character widths - luckily there is a
program which will generate one from a ttf file.
Bugfixes:
- fix the open font command so that the font file can be in the same directory.
- fix a bug with full justification, a space was being left at the end of each line - the justification now
lines up much better.
- added some binary characters near the start of the pdf file, this is so that transfer programs will
recognise it as binary.
- adjusted addTextWrap so that a text angle can now be supplied.
- have found that the reasona that jpeg file loading was not working for a lot of people is that if
magic_quotes_runtime is set on in the php.ini file, then the file read is not binary safe. Adjusted the
code to turn that option off before the read, then on again afterwards - there is at least one report of it
working much better now.
- added the missing code to specify the xPos of a table - this was documented in the last version, but
someone forgot to code it.
version 006
Still more bug fixes of course, but also some improved functionality.
It is now possible to use <b></b><i></i> markers within the text stream to do the obvious
functionality. This depends on 'font families' being set up, which are described later.
The table functionality within ezPdf has been enhanced so that the width of a table can be specified
and the cell contents will be wrapped to fit.
There is some trial functionality to allow the specification of adjusted character maps, this does mean
that this version will have to re-create your 'php_<font>.afm' files, but it will do it automatically on
first use, but make sure you have the adobe .afm files in the directory and that the web-server
has write access, alternatively download the new ones.
2 of 41
http://ros.co.nz/pdf - http://www.sourceforge.net/projects/pdf-php