composer package updates
[openemr.git] / vendor / rospdf / pdf-php / data.txt
blobfd15d565299b769b54c6f94bcc439b3b48cb299d
1 # this is the text which will end up within readme.pdf, when processed
2 # by readme.php.
4 # the syntax being used is fairly obvious:
6 # a line starting with '#' is a comment or a directive
7 # 1<title>  is a first level heading (text is 'title')
8 # 2<heading> is a second level heading (text is 'heading')
10 # the table of contents is automatically generated from the titles and headings.
12 # "#NP" starts a new page
13 # "#C" starts a code section (put this on a line by itself
14 # "#c" end the code section
15 # "#X" and "#x" surround a block which will be executed as php code.
17 # <b></b> <i></i> can be used within the text with gleeful abandon
19 # a link can be added within the text using <c:alink:url_here>label</c:alink>
22 1<Introduction>
24 This class is designed to provide a <b>non-module</b>, 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. 
26 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.
28 Note that this document was generated using the demo script 'readme.php' which came with this package.
30 1<Changelog>
32 3<0.12.46>
34 - applied PR #103 and fixed background repeater
36 3<0.12.45>
38 - clean up some code in 'addText' and 'getDirectives' method
39 - corrected callback coordinates on unicode fonts
40 - fixed possible issues with full justification
41 - use proper tempPath on windows by default
42 - fixed ttf font program not properly shown (unicode subset)
43 - fixed pager position (centered)
45 3<0.12.44>
47 - replaced each() method for PHP 7.2 compatibility reason #96
48 - applied PR #98
50 3<0.12.43>
52 - fixed issue #84
54 3<0.12.42>
56 - PR #92
58 3<0.12.41>
60 - fixed issue #80
61 - applied several PR's related to coding standards
62 - replaced pack with md5 raw output
64 Please refer to https://github.com/rospdf/pdf-php for all previous changes
66 #NP
68 1<Use>
70 It is free for use for any purpose (public domain), though we would prefer it if you retain the notes at the top of the class containing the authorship, and feedback details.
72 Note that there is no guarantee or warranty, implied or otherwise with this class, or the extension.
74 1<Extensions>
76 In order to create simple documents with ease a class extension called 'ezPdf' has been developed, at the moment this includes auto page numbering, tabular data presentation, text wrapping to new pages, etc. This document has been created using mostly ezPdf functions.
78 The functions of ezpdf are described in the next section, though as it is a class extension, all of the basic functions from the original class are still available.
80 #NP
81 1<EZPDF Class Extension>
84 (note that the creation of this document in readme.php was converted to ezpdf with the saving of many lines of code).
86 It is anticipated that in practise only the simplest of documents will be able to be created using just ezpdf functions, they should be used in conjunction with the base class functions to achieve the desired result.
89 2<Cezpdf> ([paper='a4'],[orientation='portrait'],[type='none'],[options=array()])
91 This is the constructor function, and allows the user to set up a basic page without having to know exactly how many units across and up the page is going to be.
92 Valid values for paper are listed below, a two or four member array can also be passed, a two member array will be interpreted as the size of the page in centimeters, and a four member array will be the size of the page in points, similar to the call to the base calss constructor function.
93 Starting ezpdf with the code below will create an a4 portrait document.
95 <b>$paper</b> The valid values for the paper (thanks to the work of Nicola Asuni) are:
96 '4A0', '2A0', 'A0', 'A1', 'A2', 'A3', 'A4', 'A5', 'A6' , 'A7', 'A8', 'A9', 'A10', 'B0', 'B1', 'B2', 'B3', 'B4', 'B5', 'B6', 'B7', 'B8', 'B9', 'B10', 'C0', 'C1', 'C2' , 'C3', 'C4' , 'C5', 'C6', 'C7', 'C8', 'C9', 'C10' , 'RA0', 'RA1', 'RA2', 'RA3', 'RA4', 'SRA0', 'SRA1', 'SRA2', 'SRA3', 'SRA4', 'LETTER', 'LEGAL', 'EXECUTIVE', 'FOLIO'
98 <b>$orientation</b> 'portrait' and 'landscape' can be used
100 <b>$type</b> following types are possible: 'none' | 'color' | 'image'
102 <b>$options</b> if type is diffent then 'none' $options can be set as follows
103      if $type is set to 'color'
104        $options['r'] = red-component   of backgroundcolour ( 0 <= r <= 1)
105        $options['g'] = green-component of backgroundcolour ( 0 <= g <= 1)
106        $options['b'] = blue-component  of backgroundcolour ( 0 <= b <= 1)
107      if $type is set to 'image' then the $options array has other attributes
108        $options['img']    = location of image file; URI's are allowed if allow_url_open is enabled
109        $options['width']  = width of background image; default is width of page
110        $options['height'] = height of background image; default is height of page
111        $options['xpos']   = horizontal position of background image; default is 0
112        $options['ypos']   = vertical position of background image; default is 0
113        $options['repeat'] = repeat image horizontally (1), repeat image vertically (2) or full in both directions (3); default is 0
114                             highly recommend to set this->hashed to true when using repeat function
116 This document shows you the 'color' type with following:
119 $pdf = new Cezpdf('a4','portrait','color',array(0.8,0.8,0.8));
122 If you want to get started in an easy manner, then here is the 'hello world' program:
125 <?php
126 include ('class.ezpdf.php');
127 $pdf = new Cezpdf();
128 $pdf->selectFont('Helvetica');
129 $pdf->ezText('Hello World!',50);
130 $pdf->ezStream();
134 2<ezSetMargins> (top,bottom,left,right)
136 Sets the margins for the document, this command is optional and they will all be set to 30 by default. Setting these margins does not stop you writing outside them using the base class functions, but the ezpdf functions will wrap onto a new page when they hit the bottom margin, and will not write over the side margins when using the <b>ezText</b> command below.
138 2<ezSetCmMargins> (top,bottom,left,right)
140 Sets the margins for the document using centimeters
142 2<ezNewPage> ()
144 Starts a new page. This is subtly different to the newPage command in the base class as it also places the ezpdf writing pointer back to the top of the page. So if you are using the ezpdf text functions, then this is the one to use when manually requesting a new page.
146 2<ezColumnsStart> ([options])
148 This will start the text flowing into columns, <i>options</i> is an array which contains the control options.
150 The options are:
151 'gap' => the gap between the columns
152 'num' => the number of columns.
154 Both options (and the array itself) are optional, if missed out then the defaults are gap=10, num=2;
156 Example calls could be (you would use only one of these):
159 $pdf->ezColumnsStart();
160 $pdf->ezColumnsStart(array('num'=>3));
161 $pdf->ezColumnsStart(array('num'=>3,'gap'=>2));
162 $pdf->ezColumnsStart(array('gap'=>20));
163 #c 
165 <i>ezColumnStop</i> is used to stop multi-column mode.
167 2<ezColumnsStop>
169 This stops multi-column mode, it will leave the writing point at whatever level it was at, it is recommended that an ezNewPage() command is executed straight after this command, but for flexibility this is left up to the individual consumer.
171 2<ezInsertMode> ([status=1,$pageNum=1,$pos='before'])
173 This command can be used to stop and start page insert mode, while this mode is on then any new page will be inserted into the midst of the document. If it is called with status=1, then insert mode is started and subsequent pages are added before or after page number 'pageNum'. 'pos' can be set to 'before' or 'after' to define where the pages are put. The 'pageNum' is set to which page number this position is relative to.
175 All subsequent pages added with ezNewPage are then inserted within the document following the last inserted page.
177 Insertion page is ended by calling this command with 'status'=0, and further pages are added to the end of the document.
179 2<ezSetY> (y)
181 Positions the ezpdf writing pointer to a particular height on the page, don't forget that pdf documents have <b>y-coordinates which are zero at the bottom of the page and increase as they go up</b> the page.
183 2<ezSetDy> (dy [,mod])
185 Changes the vertical position of the writing point by a set amount, so to move the pointer 10 units down the page (making a gap in the writing), use:
188 ezSetDy(-10)
191 If this movement makes the writing location below the bottom margin, then a new page will automatically be made, and the pointer moved to the top of it.
193 The optional parameter 'mod' can be set to the value 'makeSpace', which means that if a new page is forced, then the pointer will be moved the distance 'dy' on the new page as well. The intention of this is if you needed 100 units of space to draw a picture, then doing:
196 ezSetDy(-100,'makeSpace')
199 guarantees that there will be 100 units of space above the final writing point.
201 2<ezStartPageNumbers> (x,y,size,[pos],[pattern],[num]) = setNum
203 Add page numbers on the pages from here, place then on the 'pos' side of the coordinates (x,y) (pos can be 'left' or 'right').
204 Use the given 'pattern' for display, where {PAGENUM} and {TOTALPAGENUM} are replaced as required, by default the pattern is set to '{PAGENUM} of {TOTALPAGENUM}'
205 If $num is set, then make the first page this number, the number of total pages will be adjusted to account for this.
207 the following code produces a seven page document, numbered from the second page (which will be labelled '1 of 6'), and numbered until the 6th page (labelled '5 of 6')
210 $pdf = new Cezpdf();
211 $pdf->selectFont('Helvetica');
212 $pdf->ezNewPage();
213 $pdf->ezStartPageNumbers(300,500,20,'','',1);
214 $pdf->ezNewPage();
215 $pdf->ezNewPage();
216 $pdf->line(300,400,300,600); // line drawn to check 'pos' is working
217 $pdf->ezNewPage();
218 $pdf->ezNewPage();
219 $pdf->ezNewPage();
220 $pdf->ezStopPageNumbers(); 
221 $pdf->ezStream();
224 This function was modified in version 009 to return a page numbering set number (setNum in the call above), this allows independent numbering schemes to be started and stopped within a single document. This number is passed back into <i>ezStopPageNumbers</i> when it is called.
226 Here is a more complex example:
230 $pdf->selectFont('Helvetica');
231 $pdf->ezNewPage();
232 $i=$pdf->ezStartPageNumbers(300,500,20,'','',1);
233 $pdf->ezNewPage();
234 $pdf->ezNewPage();
235 $pdf->ezStopPageNumbers(1,1,$i);
236 $pdf->ezNewPage();
237 $i=$pdf->ezStartPageNumbers(300,500,20,'','',1);
238 $pdf->ezNewPage();
239 $pdf->ezNewPage();
240 $pdf->ezStopPageNumbers(1,1,$i);
241 $pdf->ezNewPage();
242 $i=$pdf->ezStartPageNumbers(300,500,20,'','',1);
243 $pdf->ezNewPage();
244 $pdf->ezNewPage();
245 $pdf->setColor(1,0,0);
246 $pdf->ezNewPage();
247 $pdf->ezStopPageNumbers(1,1,$i);
248 $pdf->ezNewPage();
249 $i=$pdf->ezStartPageNumbers(300,500,20,'','',1);
250 $pdf->ezNewPage();
251 $pdf->ezNewPage();
252 $pdf->ezNewPage();
253 $pdf->ezNewPage();
254 $j=$pdf->ezStartPageNumbers(300,400,20,'','',1);
255 $k=$pdf->ezStartPageNumbers(300,300,20,'','',1);
256 $pdf->ezNewPage();
257 $pdf->ezNewPage();
258 $pdf->ezNewPage();
259 $pdf->ezStopPageNumbers(1,1,$i);
260 $pdf->ezNewPage();
261 $pdf->ezNewPage();
262 $pdf->ezStopPageNumbers(1,1,$j);
263 $pdf->ezStopPageNumbers(0,1,$k);
264 $pdf->ezNewPage();
265 $pdf->ezNewPage();
268 This will create a document with 23 pages, the numbering shown on each of the pages is:
271 $array = array(
272 array('p'=>1,'c'=>'blank')
273 ,array('p'=>2,'c'=>'1 of 3')
274 ,array('p'=>3,'c'=>'2 of 3')
275 ,array('p'=>4,'c'=>'3 of 3')
276 ,array('p'=>5,'c'=>'1 of 3')
277 ,array('p'=>6,'c'=>'2 of 3')
278 ,array('p'=>7,'c'=>'3 of 3')
279 ,array('p'=>8,'c'=>'1 of 3')
280 ,array('p'=>9,'c'=>'2 of 3')
281 ,array('p'=>10,'c'=>'3 of 3')
282 ,array('p'=>11,'c'=>'4 of 4')
283 ,array('p'=>12,'c'=>'1 of 8')
284 ,array('p'=>13,'c'=>'2 of 8')
285 ,array('p'=>14,'c'=>'3 of 8')
286 ,array('p'=>15,'c'=>'4 of 8')
287 ,array('p'=>16,'c'=>'5 of 8, 1 of 6, 1 of 8')
288 ,array('p'=>17,'c'=>'6 of 8, 2 of 6, 2 of 8')
289 ,array('p'=>18,'c'=>'7 of 8, 3 of 6, 3 of 8')
290 ,array('p'=>19,'c'=>'8 of 8, 4 of 6, 4 of 8')
291 ,array('p'=>20,'c'=>'5 of 6, 5 of 8')
292 ,array('p'=>21,'c'=>'6 of 6, 6 of 8')
293 ,array('p'=>22,'c'=>'blank')
294 ,array('p'=>23,'c'=>'blank')
296 $pdf->ezTable($array,array('p'=>'page','c'=>'contents'));
300 2<ezWhatPageNumber> (pageNum,[setNum]) = num
302 Returns the number of a page within the specified page numbering system.
304 'pageNum' => the absolute number of the page within the document (this is based on the order that they are created).
305 'setNum' => the page numbering set, returned from the <i>ezStartPageNumbers</i> command.
307 2<ezGetCurrentPageNumber>
309 return the page number of the current page
311 2<ezStopPageNumbers> ([stopTotal],[next],[setNum])
313 In version 009 this function was enhanced to include a number of extra parameters:
315 'stopTotal' => 0 or 1 (default 0), stops the totaling for the page numbering set. So for example if you start numbering a 10 page document on the second page, and stop it on the 4th page, with stopTotal set to 1, then the numbers will be reported as "x of 3".
316 'next' => 0 or 1, stops on the next page, not this one.
317 'setNum' => (defaults to 0) define which set number is to be stopped, this is the number returned from the <i>ezStartPageNumbers</i> command.
319 2<ezTable> (array data,[array cols],[title],[array options]) = y
321 <b>$data</b> The easy way to throw a table of information onto the page, can be used with just the data variable, which must contain a two dimensional array of data. This function was made with data extracted from database queries in mind, so is expecting it in that format, a two dimensional array with the first array having one entry for each row (and each of those is another array).
323 The table will start writing from the current writing point, and will proceed until the all the data has been presented, by default, borders will be drawn, alternate limes will be shaded gray, and the table will wrap over pages, re-printing the headers at the top of each page.
325 The return value from the function is the y-position of the writing pointer after the table has been added to the document.
327 <strong>since 0.12.27 $data can contain the follow keys to colorize cells</strong>
330 '[columnName]Fill' => array(r,g,b)  // used to fill a cell background color
331 '[columnName]Color' => array(r,g,b) // used to color the cell text
334 The other options are described here below
336 <b>$cols</b> (optional) is an associative array, the keys are the names of the columns from $data to be presented (and in that order), the values are the titles to be given to the columns, if this is not wanted, but you do want later options then '' (the empty string) is a suitable placeholder.
338 <b>$title</b> (optional) is the title to be put on the top of the table
340 <b>$options</b> is an associative array which can contain:
341 'showHeadings' => 0 or 1 (enable or disable head line)
342 'shaded'=> 0,1,2, default is 1 (alternate lines are shaded)
343     0->no shading, 2->both sets are shaded
344 'shadeCol' => (r,g,b) array, defining the colour of the shading, default is (0.8,0.8,0.8)
345 'shadeCol2' => (r,g,b) array, defining the colour of the shading of the second set, default is (0.7,0.7,0.7), used when 'shaded' is set to 2.
346 'fontSize' => 10
347 'textCol' => (r,g,b) array, text colour
348 'titleFontSize' => 12
349 'rowGap' => 2 , the space between the text and the row lines on each row
350 'colGap' => 5 , the space between the text and the column lines in each column
351 'lineCol' => (r,g,b) array, defining the colour of the lines, default, black.
352 'xPos' => 'left','right','center','centre',or coordinate, reference coordinate in the x-direction
353 'xOrientation' => 'left','right','center','centre', position of the table w.r.t 'xPos'. This entry is to be used in conjunction with 'xPos' to give control over the lateral position of the table.
354 'width' => <number>, the exact width of the table, the cell widths will be adjusted to give the table this width.
355 'maxWidth' => <number>, the maximum width of the table, the cell widths will only be adjusted if the table width is going to be greater than this.
356 'cols' => array(<colname>=> array('justification'=>'left', 'width'=>100, 'link'=><linkColName>, 'bgcolor'=> (r,g,b)), <colname>=>....) allow the setting of other paramaters for the individual columns, each column can have its width and/or its justification set.
357 'innerLineThickness' => <number>, the thickness of the inner lines, defaults to 1
358 'outerLineThickness' => <number>, the thickness of the outer lines, defaults to 1
359 'protectRows' => <number>, the number of rows to keep with the heading, if there are less than this on a page, then all is moved to the next page.
360 'nextPageY'=> true or false (eg. 0 or 1) Sets the same Y position of the table for all future pages
361 'evenColumns' => 0, 1, 3, Set set all columns to the same widths, version 0.12.44
362 'evenColumnsMin' => <number>, the minimum width a column should have
364 <b>0.12.9:</b>
365 'shadeHeadingCol'=>(r,g,b) array, defining the backgound color of headings, default is empty
367 <b>0.12.11:</b>
368 'gridlines'=> EZ_GRIDLINE_* default is EZ_GRIDLINE_DEFAULT, overrides 'showLines' to provide finer control
369  'alignHeadings' => 'left','right','center'
371 <b>0.12.27:</b>
372 'evenColumns' => 0,1 make all column width the same size
374 Below is an example output of ezTable containing the following $data
377 $data = array(
378  array('num'=>1,'name'=>'gandalf','type'=>'wizard')
379 ,array('num'=>2,'name'=>'bilbo','type'=>'hobbit','url'=>'https://github.com/rospdf/pdf-php')
380 ,array('num'=>3,'name'=>'frodo','type'=>'hobbit')
381 ,array('num'=>4,'name'=>'saruman','type'=>'bad dude','url'=>'https://github.com/rospdf/pdf-php')
382 ,array('num'=>5,'name'=>'sauron','type'=>'really bad dude')
387 $pdf->ezTable($data,$cols,'',array(
388     'gridlines'=> EZ_GRIDLINE_DEFAULT,
389     'shadeHeadingCol'=>array(0.6,0.6,0.5),
390     'width'=>400,
391     'cols'=> array(
392         'name'=>array('bgcolor'=>array(0.9,0.9,0.7)),
393         'type'=>array('bgcolor'=>array(0.6,0.4,0.2))
394     )
399 $data = array(
400  array('num'=>1,'name'=>'gandalf','type'=>'wizard')
401 ,array('num'=>2,'name'=>'bilbo','type'=>'hobbit','url'=>'https://github.com/rospdf/pdf-php')
402 ,array('num'=>3,'name'=>'frodo','type'=>'hobbit')
403 ,array('num'=>4,'name'=>'saruman','type'=>'bad dude','url'=>'https://github.com/rospdf/pdf-php')
404 ,array('num'=>5,'name'=>'sauron','type'=>'really bad dude')
406 $cols = array('num'=>"<b>Number</b>",'name'=>'<b>Name</b>','type'=>'<b>Type</b>');
407 $pdf->ezTable($data,$cols,'',array(
408     'gridlines'=> EZ_GRIDLINE_DEFAULT,
409     'shadeHeadingCol'=>array(0.6,0.6,0.5),
410     'alignHeadings'=>'center',
411     'width'=>400,
412     'cols'=> array(
413         'name'=>array('bgcolor'=>array(0.9,0.9,0.7)),
414         'type'=>array('bgcolor'=>array(0.6,0.4,0.2))
415     )
419 <b>Please refer to examples/tables.php for more demos</b>
421 2<ezText> (text,[size],[array options]) = y
423 This is designed for putting blocks of text onto the page. It will add a string of text to the document (note that the string can be very large, spanning multiple pages), starting at the current drawing position. It will wrap to keep within the margins, including optional offsets from the left and the right, if $size is not specified, then it will be the last one used, or the default value (12 I think). The text will go to the start of the next line when a return code "\n" is found.
425 The return value from the function (y) is the vertical position on the page of the writing pointer, after the text has been added.
427 possible options are:
428  'left'=> number, gap to leave from the left margin
429  'right'=> number, gap to leave from the right margin
430  'aleft'=> number, absolute left position (overrides 'left')
431  'aright'=> number, absolute right position (overrides 'right')
432  'justification' => 'left','right','center','centre','full'
434  only set one of the next two items (leading overrides spacing)
435  'leading' => number, defines the total height taken by the line, independent of the font height.
436  'spacing' => a real number, though usually set to one of 1, 1.5, 2 (line spacing as used in word processing)
438 This function now supports the use of underlining markers (&lt;u> &lt;/u>), these are implemented via a callback function, which is information that you need only of you want to use them in functions in the base class, as these markers will not work there and the full callback function markers wil have to be used (though note that ezPdf stillhas to be part of the class object as the callback function are included with that code base. The callback function markers would look like &lt;c:uline>this&lt;/c:uline>.
441 2<ezImage> (image,[padding],[width],[resize],[justification], [angle],[array border])
443 This function makes it much easier to simply place an image (either jpeg or png) within the flow of text within a document.  Although this function can certainly be used with full page documents, its functionality is most suited to documents that are formatted in multiple columns.
445 This function can be used by simply supplying the name of an image file as the first argument.  The image will be resized to fit centered within the current column with the default padding of 5 on each side.
447 The arguments are:
449 <b>$image</b> is a string containing the filename and path of the jpeg or png image you want to insert into the page.  If allow_url_fopen is enabled in the PHP ini settings this can be an HTTP or FTP URL.
451 <b>$padding</b> (optional) is the number of page units that will pad the image on all sides.  The default is five (5).  If you do not want any padding, you may enter 0.
453 <b>$width</b> (optional) is the width of the image on the page.  The default is to use the actual width of the image in pixels.  Whether or not you specify a width, the actual width of the image on the page will depend on what you enter for the $resize argument as well as the placement of the image on the page.
455 <b>$resize</b> (optional) can be one of 'full', 'width', or 'none'.  The default value is 'full'.  
457 The value 'none' means that an image will not be sized up to fit the width of a column and will not be sized down vertically to fit within the current page. If the image is too long to fit on the page it will be placed on the next page or column.  If the image is too wide to fit within the current column, it will still be sized down.  This is because there is no alternative, other than to actually let the image run off the page.
459 The value 'width' behaves the same as 'none' with the exception that images will be resized to fit the width of the current column if the given width is smaller that the current column (minus the padding).
461 The value 'full' behaves the same as 'width' with the exception that images will be resized down vertically to fit within the current page and column if their height is too long to fit.
463 <b>$justification</b> (optional) determines the horizontal position of the image within the current column.  The default is 'center', and can be specified as either 'center', 'left', or 'right'.  This setting has little meaning if the image has been resized to fit the column and only makes a practical difference if the width of the image is smaller than the width of the column.
465 <b>$angle</b> (optional) allows you the rotate the image
467 <b>$border</b> (optional) is an array which specifies the details of the border around the image.  The default is no border if this argument is not given.  You may specify any of the following border elements:
469 $border['width'] is the width of the border.  The default is 1.
470 $border['cap'] is the cap type as specified in setLineStyle.  The default is 'round'.
471 $border['join'] is the join type as specified in setLineStyle.  The default is 'round'.
472 $border['color'] is an associative array for specifying the line color of the border.
473 The values are as specified in setStrokeColor and should be assigned to:
474 $border['color']['red'], $border['color']['green'] and $border['color']['blue'] respectively.
478 2<ezOutput> ([debug])
480 Very similar to the output function from the base class, but performs any closing tasks that ezpdf requires, such as adding the page numbers.
482 If you are using ezpdf, then you should use this function, rather than the one from the base class.
484 2<ezStream> ([options])
486 Very similar to the stream function from the base class (all the same options, see later in this document), but performs any closing tasks that ezpdf requires, such as adding the page numbers.
488 If you are using ezpdf, then you should use this function, rather than the one from the base class.
490 2<Inline codes>
492 There are a few callback functions (see callback functions) which are contained within the ezPdf class, these are intended to make life easier. They enable complex operations to be done by including codes within the text stream.
494 <b>Underline</b>
495 Though underlining is supported in the ezPdf class by using the &lt;u&gt; directive, 
496 if you use the base class functions to add text (such as addtext) then this wont work, instead you can use the <i>uline</i> callback function.
498 (Note that what the ezPdf class does internally is convert the &lt;u&gt; and &lt;/u&gt; directives into callback function calls)
500 So as an example, this code adds some text with two pieces of underlining, one done each way
503 $pdf->ezText('The &lt;u&gt;quick brown&lt;/u&gt; fox, &lt;c:uline&gt;is sick of jumping&lt;/uline&gt; the lazy dog')
506 The <u>quick brown</u> fox, is <c:uline>sick of jumping</c:uline> the lazy dog
509 <b>Links to URLs</b>
511 If you are adding links to a document, it is quite tricky to figure out where to put the rectange which will be clckable, especially if the text in teh link starts wrapping across pages, etc. 
513 The <i>alink</i> callback allows for simple insertion of links, the format is:
515 &lt;c:alink:<i>your_url_here</i>&gt;text to be clickable&lt;/c:alink&gt;
517 So as an example:
520 $pdf->ezText('&lt;c:alink:https://github.com/rospdf/pdf-php/ pdf class&lt;/c:alink&gt;');
523 <c:alink:https://github.com/rospdf/pdf-php/>R&OS pdf class</c:alink>
525 <b>Links within the document</b>
527 There is a directive similar to <i>alink</i>, but designed for linking within the document, this is the <i>ilink</i> callback function.
529 It is similar to <i>alink</i> except that instead of providing a URL the label of a pre-created destination should be used. 
531 &lt;c:ilink:<i>destination_label</i>>text to be clickable&lt;/c:ilink>
534 // place required to be marked
535 $pdf->addDestination('xxxyyyzzz','Fit');
536 // add lots of stuff, new pages etc, then...
537 $pdf->ezText('&lt;c:ilink:xxxyyyzzz>R&OS pdf class&lt;/c:ilink>');
540 Click here to go to the <c:ilink:toc5>5th item</c:ilink> on the table of contents.
542 Note that the code for the example and the actual one shown are not identical for technical reasons.
545 1<Base Class Functions>
548 2<addText> (x,y,size,text[,width=0][,justification='left'][,angle=0][,wordspace=0][,test=0)
550 Add the text at a particular location on the page, noting that the origin on the axes in a pdf document is in the lower left corner by default.
551 An angle can be supplied as this will do the obvious (in degrees).
553 'adjust', gives the value of units to be added to the width of each space within the text. This is used mainly to support the justification options within the ezpdf ezText function.
555 The text stream can now (version 006) contain directives to make the text bold and/or italic. The directives are similar the basic html: 
557 &lt;b&gt;<b>bold text</b>&lt;/b&gt; 
558 &lt;i&gt;<i>italic text</i>&lt;/i&gt; 
559 &lt;b&gt;&lt;i&gt;<b><i>bold italic text</i></b>&lt;i&gt;&lt;/b&gt; 
561 <b>Note</b> that there can be no spaces within the directives, and that they must be in lower case.
563 Especially <b>bold</b> and <i>italic</i> requires the style of the font being used
565 If you wish to print an actual '<', most of the time it would cause no problem, except in the instance where it would form a directive. Use HTML special char &amp;lt; and &amp;gt;
568 $pdf->addText(150,$y,10,"the quick brown fox &lt;b>jumps&lt;/b> &lt;i>over&lt;/i> the lazy dog!",0, 'left',-10);
571 $pdf->ezSetDy(-40,'makeSpace');
572 $pdf->addText(150,$pdf->y,10,"the quick brown fox <b>jumps</b> <i>over</i> the lazy dog!",0, 'left',-10);
573 $pdf->ezSetDy(-5);
576 2<setColor> (r,g,b,[force=0])
578 Set the fill colour to the r,g,b triplet, each in the range 0->1.
579 If force is set, then the entry will be forced into the pdf file, otherwise it will only be put in if it is different from the current state.
581 2<setStrokeColor> (r,g,b,[force=0])
583 Set the stroke color, see the notes for the fill color.
585 2<setLineStyle> ([width],[cap],[join],[dash],[phase])
587 This sets the line drawing style.
588  width, is the thickness of the line in user units
589  cap is the type of cap to put on the line, values can be 'butt','round','square' where the difference between 'square' and 'butt' is that 'square' projects a flat end past the end of the line.
590  join can be 'miter', 'round', 'bevel'
591  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.
592    for example: (2) represents 2 on, 2 off, 2 on , 2 off ...
593       (2,1) is 2 on, 1 off, 2 on, 1 off.. etc
594  phase is a modifier on the dash pattern which is used to shift the point at which the pattern starts. 
597 $pdf->setLineStyle(1);
600 $pdf->setLineStyle(1);
601 $pdf->ezSetDy(-8,'makeSpace');
602 $pdf->line(100,$pdf->y,400,$pdf->y);
603 $pdf->ezSetDy(-5);
606 $pdf->setLineStyle(5);
609 $pdf->setLineStyle(5);
610 $pdf->ezSetDy(-8,'makeSpace');
611 $pdf->line(100,$pdf->y,400,$pdf->y);
612 $pdf->ezSetDy(-5);
615 $pdf->setLineStyle(5,'round');
618 $pdf->setLineStyle(5,'round');
619 $pdf->ezSetDy(-8,'makeSpace');
620 $pdf->line(100,$pdf->y,400,$pdf->y);
621 $pdf->ezSetDy(-5);
624 $pdf->setLineStyle(5,'','',array(5));
627 $pdf->setLineStyle(5,'','',array(5));
628 $pdf->ezSetDy(-8,'makeSpace');
629 $pdf->line(100,$pdf->y,400,$pdf->y);
630 $pdf->ezSetDy(-5);
633 $pdf->setLineStyle(5,'','',array(10,5));
636 $pdf->setLineStyle(5,'','',array(10,5));
637 $pdf->ezSetDy(-8,'makeSpace');
638 $pdf->line(100,$pdf->y,400,$pdf->y);
639 $pdf->ezSetDy(-5);
642 $pdf->setLineStyle(5,'','',array(20,5,10,5));
645 $pdf->setLineStyle(5,'','',array(20,5,10,5));
646 $pdf->ezSetDy(-8,'makeSpace',4);
647 $pdf->line(100,$pdf->y,400,$pdf->y);
648 $pdf->ezSetDy(-5);
651 $pdf->setLineStyle(5,'round','',array(0,15));
654 $pdf->setLineStyle(5,'round','',array(0,15));
655 $pdf->ezSetDy(-8,'makeSpace');
656 $pdf->line(100,$pdf->y,400,$pdf->y);
657 $pdf->ezSetDy(-5);
660 Note that the code shown with each of these lines is just the line style command, the drawing of each line also requires a <b>line</b> command, which is not shown.
662 2<line> (x1,y1,x2,y2)
664 Draw a line from (x1,y1) to (x2,y2), set the line width using setLineStyle.
666 2<curve> (x0,y0,x1,y1,x2,y2,x3,y3)
668 Draw a Bezier curve. The end points are (x0,y0)->(x3,y3), and the control points are the other two.
670 Bezier curves are neat, but probably not for the novice. The <b>ellipse</b> command uses a series of Bezier curves to make the ellipse.
672 The distinctive feature of these curves is that the curve is guaranteed to lie within the 4 sided polygon formed from the 4 control points (they are also computationally easy to draw). An example is shown below with the control points marked.
675 $pdf->curve(200,$y+40,250,$y+5,350,$y,400,$y+45);
678 $pdf->ezSetDy(-50,'makeSpace');
679 $y = $pdf->y;
680 $pdf->setLineStyle(2);
681 $pdf->curve(200,$y+40,250,$y+5,350,$y,400,$y+45);
682 $pdf->setLineStyle(0.5);
683 $pdf->ellipse(200,$y+40,5);
684 $pdf->ellipse(250,$y+5,5);
685 $pdf->ellipse(350,$y,5);
686 $pdf->ellipse(400,$y+45,5);
687 $pdf->setLineStyle(0.5,'','',array(10,5));
688 $pdf->line(200,$y+40,250,$y+5);
689 $pdf->line(250,$y+5,350,$y);
690 $pdf->line(350,$y,400,$y+45);
693 Note that the Bezier curve is a tangent to the line between the control points at either end of the curve.
695 2<ellipse> (x0,y0,r1,[r2=0],[angle=0],[nSeg=8])
697 Draw an ellipse, centred ay (x0,y0), with radii (r1,r2), oriented at 'angle' (anti-clockwise), and formed from nSeg bezier curves (the default 8 gives a reasonable approximation to the required shape).
699 If r2 is left out, or set to zero, then it is assumed that a circle is being drawn.
702 $pdf->ellipse(300,$y+25,20);
705 $pdf->ezSetDy(-50,'makeSpace');
706 $pdf->setLineStyle(2);
707 $pdf->ellipse(300,$pdf->y+25,20);
711 $pdf->ellipse(300,$y+25,40,20);
714 $pdf->ezSetDy(-50,'makeSpace');
715 $pdf->setLineStyle(2);
716 $pdf->ellipse(300,$pdf->y+25,40,20);
720 $pdf->ellipse(300,$y+25,40,20,45);
723 $pdf->ezSetDy(-50,'makeSpace');
724 $pdf->setLineStyle(2);
725 $pdf->ellipse(300,$pdf->y+25,40,20,45);
728 Of course the previous line style features also apply to these lines
731 $pdf->setLineStyle(4,'round','',array(0,6,4,6));
732 $pdf->ellipse(300,$y+25,40,20,45);
735 $pdf->ezSetDy(-50,'makeSpace');
736 $pdf->setLineStyle(4,'round','',array(0,6,4,6));
737 $pdf->ellipse(300,$pdf->y+25,40,20,45);
740 2<partEllipse> (x,y,a1,a2,r1 [,r2] [,angle] [,nSeg])
742 Draw a part ellipse (or circle), draw an ellipse centered on (x,y) from angle 'a1' to angle 'a2' (in degrees), with radius 'r1' in the x-direction and 'r2' in the y-direction and oriented at angle 'angle'. If 'r2' is not supplied the it defaults to 'r1' and a circle is formed.
745 $pdf->ellipse(300,$y+25,38);
746 $pdf->partEllipse(300,$y+25,119,421,80,12,10);
747 $pdf->partEllipse(300,$y+25,117,423,84,14,10);
748 $pdf->partEllipse(300,$y+25,115,425,85,15,10);
752 $pdf->ezSetDy(-60,'makeSpace');
753 $pdf->ellipse(300,$pdf->y+25,38);
754 $pdf->partEllipse(300,$pdf->y+25,119,421,80,12,10);
755 $pdf->partEllipse(300,$pdf->y+25,117,423,84,14,10);
756 $pdf->partEllipse(300,$pdf->y+25,115,425,85,15,10);
759 2<polygon> (p,np,[f=0])
761 Draw a polygon, where there are np points, and p is an array containing (x0,y0,x1,y1,x2,y2,...,x(np-1),y(np-1)).
762 If f=1 then fill the area.
765 $pdata = array(200,10,400,20,300,50,150,40);
766 $pdf->polygon($pdata,4);
769 $pdata = array(200,10,400,20,300,50,150,40);
770 $pdf->ezSetDy(-60,'makeSpace');
771 for ($i=1;$i<count($pdata);$i+=2){
772   $pdata[$i]+=$pdf->y;
774 $pdf->polygon($pdata,4);
778 $pdf->polygon($pdata,4,1);
781 $pdf->ezSetDy(-60,'makeSpace');
782 $pdata = array(200,10,400,20,300,50,150,40);
783 $pdf->ezSetDy(-60,'makeSpace');
784 for ($i=1;$i<count($pdata);$i+=2){
785   $pdata[$i]+=$pdf->y;
787 $pdf->polygon($pdata,4,1);
791 $pdf->setColor(0.9,0.9,0.9);
792 $pdf->polygon($pdata,4,1);
795 $pdf->ezSetDy(-60,'makeSpace');
796 $pdata = array(200,10,400,20,300,50,150,40);
797 $pdf->ezSetDy(-60,'makeSpace');
798 for ($i=1;$i<count($pdata);$i+=2){
799   $pdata[$i]+=$pdf->y;
801 $pdf->setColor(0.9,0.9,0.9);
802 $pdf->polygon($pdata,4,1);
805 2<rectangle> (x1,y1,width,height)
807 Build a rectangle with no background, only borders
810 $pdf->rectangle(400, $pdf->y, 120,50);
814 $pdf->rectangle(400, $pdf->y, 120,50);
817 2<filledRectangle> (x1,y1,width,height)
819 Build a rectangle with filled color.
822 $pdf->filledRectangle(400, $pdf->y, 120, 50);
826 $pdf->filledRectangle(400, $pdf->y, 120,50);
829 2<newPage> ([insert,id,pos]) = id
831 Starts a new page and returns the id of the page contents, this can be safely ignored, but storing it will allow the insertion of more information back into the page later, through the use of the 'reopenObject' function.
833 The command is usually used without any of the options to simply add a new page to the end of the current bunch, but with the options can be used to insert a page within the existing pages. The 'insert' value can be set to 0 or 1 (use 1 to insert). 'id' should be set to a value which was returned by a previous newPage command (this is actually the object id of the contents of a page). 'pos' will determine whether the page is inserted before or after the specified page, it should be set to 'before' or 'after'.
835 2<getFirstPageId> () = id
837 A related command is this which returns the id of the first page, this page is created during the class instantiation and so does not have its id returned to the user, this is the only way to fetch it, but it can be done at any point.
839 2<stream> ([array options])
841 Used for output, this will set the required headers and output the pdf code.
843 The options array can be used to set a number of things about the output:
845  'Content-Disposition'=>'filename' sets the filename, though not too sure how well this will work as in my trial the browser seems to use the filename of the php file with .pdf on the end.
846  'Accept-Ranges'=>1 or 0 - if this is not set to 1, then this header is not included, off by default this header seems to have caused some problems despite the fact that it is supposed to solve them, so I am leaving it off by default.
847  'compress'=> 1 or 0 - apply content stream compression, this is on (1) by default.
849 2<getFontHeight> (size) = height
851 Returns the height of the current font, in the given size. This is the distance from the bottom of the descender to the top of the Capitals.
853 2<getFontDescender> (size) = height
855 Returns a number which is the distance that the descender goes beneath the Baseline, for a normal character set this is a negative number. 
857 2<getTextWidth> (size,text) = width
859 Returns the width of the given text string at the given size.
861 2<saveState> ()
863 Save the graphic state.
865 2<restoreState> ()
867 Restore a saved graphics state.
869 2<openObject> () = id
871 Start an independent object. This will return an object handle, and all further writes to a page will actually go into this object, until a closeObject call is made.
873 2<reopenObject> (id)
875 Makes the point of current content insertion the numbered object, this 'id' must have been returned from a call to 'openObject' or 'newPage' for it to be a valid object to insert content into. Do not forget to call 'closeObject' to close off input to this object and return it to where it was beforehand (most likely the current page).
876 This will allow the user to add information to previous pages, as long as they have stored the id of the pages.
878 2<closeObject> ()
880 Close the currently open object. Further writes will now go to the current page.
882 2<addObject> (id,[options='add'])
884 Add the object specified by id to the current page (default). If a string is supplied in options, then the following may be specified:
885 'add' - add to the current page only.
886 'all' - add to every page from the current one on.
887 'odd' - add to all odd numbered pages from now on.
888 'even' - add to all even numbered pages from now on.
889 'next' - add to just the next page.
890 'nextodd' - add to all odd numbered pages from the next one.
891 'nexteven' - add to all even numbered pages from the next one.
893 2<stopObject> (id)
895 If the object (id) has been appearing on pages up to now, then stop it, this page will be the last one that could contain it.
897 2<addInfo> (label,value)
899 Add document information, the valid values for label are:
900 Title, Author, Subject, Keywords, Creator, Producer, CreationDate, ModDate, Trapped
902 modified in version 003 so that 'label' can also be an array of key->value pairs, in which case 'value' should not be set.
904 2<setPreferences> (label,value)
906 Set some document preferences, the valid values for label are:
907 HideToolbar, HideMenuBar, HideWindoUI, FitWindow, CenterWindow, NonFullScreenPageMode, Direction
909 modified in version 003 so that 'label' can also be an array of key->value pairs, in which case 'value' should not be set.
911 2<addImage> (img,x,y,w,[h],[quality=75],[angle=0])
913 Add an image to the document, this feature needs some development. But as it stands, img must be a handle to a GD graphics object, and one or both of w or h must be specified, if only one of them is specified, then the other is calculated by keeping the ratio of the height and width of the image constant.
914 The image will be placed with its lower left corner at (x,y), and w and h refer to page units, not pixels.
916 2<addJpegFromFile> (imgFileName,x,y,w,[h],[angle=0])
918 Add a JPEG image to the document, this function does not require the GD functionality, so should be usable to more people, interestingly it also seems to 
919 be more reliable and better quality. The syntax of the command is similar to the above 'addImage' function, though 'img' is a string containing the file name of the jpeg image.
921 x,y are the position of the lower left corner of the image, and w,h are the width and height. Note that the resolution of the image in the document is defined only by the resolution of the image that you insert, and the size that you make it on the page. If you have an image which is 500 pixels across and then you place it on the page so that it is 72 units across then this image will be about 500 dpi (as 72 units is about 72 points which is 1 inch).
923 2<addPngFromFile> (imgFileName,x,y,w,[h],[angle=0])
925 Similar to <i>addJepgFromFile</i>, but for PNG images.
927 2<output> ([debug=0]) = a
929 As an alternative to streaming the output directly to the browser, this function simply returns the pdf code. No headers are set, so if you wish to stream at a later time, then you will have to manually set them. This is ideal for saving the code to make a pdf file, or showing the code on the screen for debug purposes.
931 If the 'debug' parameter is set to 1, then the only effect at the moment is that the compression option is not used for the content streams, so that they can be viewed clearly.
933 2<openHere> (style[,a][,b][,c])
935 Make the document open at a specific page when it starts. The page will be the one which is the current page when the function is called.
937 The style option will define how it will look when open, valid values are:
938 (where the extra parameters will be used to supply any values specified for the style chosen)
940 'XYZ'  left, top, zoom <i>open at a particular coordinate on the page, with a given zoom factor</i>
941 'Fit'  <i>fit the page to the view</i>
942 'FitH' top <i>fit horizontally, and at the vertical position given</i>
943 'FitV' left <i>fit vertically, and at the horizontal position given</i>
944 'FitB' <i>fit the bounding box of the page into the viewer</i>
945 'FitBH' top <i>fit the width of the bounding box to the viewer and set at the vertical position given</i>
946 'FitBV' left <i>fit bounding box vertically and set given horizontal position</i>
948 2<selectFont> (fontName [,encoding = ''] [, set = 1] [,subsetFont = false])
950 This selects a font to be used from this point in the document. Errors can occur if some of the other functions are used if a font has not been selected, so it is wise to do this early on.
952 In all versions prior to 0.12 it was required to "convert" ttf fonts into either *.AFM or *.UFM for unicode font files.
953 Since version >= 0.12.0 R&OS pdf class natively reads the information from the TTF font by using TTF.php
954 It also supports font supbsetting  (>= 0.11.8) by using TTFsubset.php. Thanks to Thanos Efraimidis (4real.gr).
956 The encoding directive is still experimental and no guarantee its working at all in version >= 0.12. But theoretical  it allows the user to re-map character numbers from the 0->255 range to any named character in the set (as most of the sets have more than 256 characters). It should be an array of <number> => <name> pairs in an associative array. This is important to ensure that the right width for the character is used within the presentation characters, it has been noticed that sometimes, although the right character appears on the page, the incorrect width has been caluclated, using this function to explicitly set that number to the named character should fix the problem.
957 Note that the encoding directive will be effective <b>only the first time</b> that a font is selected, and it should not be used on symbolic fonts (such as Symbol or ZapfDingbats).
960 // use a Times-Roman font with MacExpertEncoding
961 $pdf->selectFont('Times-Roman','MacExpertEncoding');
962 // this next line should be equivalent
963 $pdf->selectFont('Times-Roman',array('encoding'=>'MacExpertEncoding'));
965 // setup the helvetica font for use with german characters
966 $diff=array(196=>'Adieresis',228=>'adieresis',
967              214=>'Odieresis',246=>'odieresis',
968              220=>'Udieresis',252=>'udieresis',
969              223=>'germandbls');
970 $pdf->selectFont('Helvetica'
971        ,array('encoding'=>'WinAnsiEncoding'
972              ,'differences'=>$diff));
976 2<setFontFamily> (family,options)
978 This function defines the relationship between the various fonts that are in the system, so that when a base font is selected the program then knows which to use when it is asked for the <b>bold</b> version or the <i>italic</i> version (not forgetting of course <b><i>bold-italic</i></b>).
980 It maintains a set of arrays which give the alternatives for the base fonts. The defaults that are in the system to start with are:
982 'Helvetica'
983         'b'=>'Helvetica-Bold'
984         'i'=>'Helvetica-Oblique'
985         'bi'=>'Helvetica-BoldOblique'
986         'ib'=>'Helvetica-BoldOblique'
988 'Courier'
989         'b'=>'Courier-Bold'
990         'i'=>'Courier-Oblique'
991         'bi'=>'Courier-BoldOblique'
992         'ib'=>'Courier-BoldOblique'
994 'Times-Roman'
995         'b'=>'Times-Bold'
996         'i'=>'Times-Italic'
997         'bi'=>'Times-BoldItalic'
998         'ib'=>'Times-BoldItalic'
1000 (where 'b' indicate bold, and 'i' indicates italic)
1001         
1002 Which means that (for example) if you have selected the 'Courier' font, and then you use the italic markers then the system will change to the 'Courier-Oblique' font.
1004 Note that at the moment it is not possible to have any more fonts, so there is little use in calling this function (except to change these settings, discussed below), but this is paving the way for when soon we will be able to add other fonts (both .afm, and .ttf), which is also why the suffix must be specified in the font name.
1006 Note also that it is possible to have a different font when some text is bolded, then italicized, as compared to when it is italicized, then bolded ('bi' vs 'ib'), though they have all been set to be the same by default.
1008 If you bold a font twice, then under the current system it would look for a 'bb' entry in the font family, and since there are none in the default families the font will revert to the base font. As an example here is the code that you would use to define a new font family for the Courier font which (for some reason) changed to Times-Roman when a double bold is used:
1011 $tmp = array(
1012          'b'=>'Courier-Bold'
1013         ,'i'=>'Courier-Oblique'
1014         ,'bi'=>'Courier-BoldOblique'
1015         ,'ib'=>'Courier-BoldOblique'
1016         ,'bb'=>'Times-Roman'
1017       );
1018 $pdf->setFontFamily('Courier',$tmp);
1021 2<setEncryption> ([userPass=''],[ownerPass=''],[pc=array], [mode=1])
1023 Calling this function sets up the document to be encrypted, this is the only way to mark the document so that they user cannot use cut and paste, or printing.
1025 Since version 0.11.2 a new parameter "$mode" has been added to this function to allow RC4 128bit encryption (PDF 1.4 required)
1027 Using the call without options, defaults to preventing the user from cut & paste or printing. There are no passwords require to open the document.
1030 $pdf->setEncryption();
1033 Setting either off the passwords will mean that the user will have to enter a password to open the document. If the owner password is entered when the document is opened then the user will be able to print etc. If the two passwords are set to be the same (or the owner password is left blank) then there is noo owner password, and the document cannot be opened in the accesible mode.
1035 The pc array can be used to <b>allow</b> specific actions. The following example, sets an owner password, a user password, and allows printing and cut & paste.
1038 $pdf->setEncryption('trees','frogs',array('copy','print'));
1042 2<addLink> (url,x0,y0,x1,y1)
1044 Creates a clickable rectangular area within the document, which takes the user to the URL when clicked. The coordinates specify the area.
1046 See the information in the <i>inline codes</i> chapter of the ezPdf section to see and easy way of adding links to your code.
1049 $pdf->addLink("https://github.com/rospdf/pdf-php/",50,100,500,120);
1050 $pdf->rectangle(50,100,450,20);
1053 $pdf->ezSetDy(-40,'makeSpace');
1054 $pdf->addLink("https://github.com/rospdf/pdf-php/",50,$pdf->y,500,$pdf->y+20);
1055 $pdf->rectangle(50,$pdf->y,450,20);
1058 2<addInternalLink> (label,x0,y0,x1,y1)
1060 Creates an internal link in the document, 'label' is the name of an target point, and the other settings are the coordinates of the enclosing rectangle of the clickable area.
1062 Note that the destination markers are created using the <i>addDestination</i> function described below.
1064 See the information in the <i>inline codes</i> chapter of the ezPdf section to see and easy way of adding links to your code.
1066 2<addDestination> (label,style[,a][,b][,c])
1068 This marks a point in the document as a potential destination for an internal link, the 'label' can be any string, though should be unique for the document, else confusion may ensue. The remainer of the options are identical to the <i>openHere</i> function.
1071 2<transaction> (action)
1073 One of the major problems with this class has been the inability to format things so that they fit nicely, as you cannot know how large something is until you have it on the page, this function attempts to produce a solution this.
1075 Transaction support (terminology borrowed from databases) allows you to mark a point in the development of your document, and if you do not like how things are going from there you can abort and return to that place. This will allow tentatively trying a few different options for things, then settling with the one that looks like what you like. The most obvious application immediatly is support for stopping table cells being split over pages. If you start a row and on completion discover that you are on a new page, then just abort the transaction, going back to the position before you started making that row, and then make a new page there.
1077 'action' can be set to one of 'start','commit','rewind','abort', which are fairly obvious in their usage.
1079 'start' - mark a checkpoint, a position to return to upon 'abort'
1080 'commit' - you are happy with this one, it releases the most recent 'start' though does not affect the document.
1081 'rewind' - you are not happy, but are planning to start again from the last checkpoint, this is the same as an 'abort' and a 'start', but is much more efficient.
1082 'abort' - you are not happy with you the document is looking, this will return you to the state at last 'start' point.
1084 Notes:
1085 - 'start' commands can be nested, and 'abort' or 'commit' will always affect the most recent start.
1086 - though often it seems that you do not need to 'commit' if you are happy with your changes, it is good practice, the 'start' command is effectively making an internal copy of the document, if you are working on a large document you may run out of space. The 'commit' command frees up that space once more.
1087 - these commands, though they are part of the base class, save all the setting of the object in which they are contained, this means most often that they will work fine with an ezPdf object, and will also work with user class extensions.
1089 1<Misc>
1091 2<Callback functions>
1093 Code has been included within class.pdf.php which allows the user to place a marker within the text, when the interpreter places that piece of text on the page, then the named function will be called, passing an array which has the details about the position.
1095 The marker is either of the forms:
1097 &lt;c:<i>func</i>:<i>paramater</i>>aaa bbb ccc&lt;/c:<i>func</i>>
1098 &lt;C:<i>func</i>:<i>paramater</i>>
1101 The first form (with the small 'c') is for when the situation requires both an opening and a closing tag, and the second form for when only one specific point needs to be marked.
1103 When this piece of text is placed, the class function 'func' will be called, and it must have been defined with a single paramater. This paramater will be an array, which will have members:
1106 x => x-position
1107 y => y-position
1108 status => <see below>
1109 f => function name
1110 height => font height
1111 decender => font decender
1114 Where the status can have one of the values 'start','end','sol','eol'. The start and end values are obvious and indicate that this is either the start or the end of the marked range. The other two indicate start-of-line and end-of-line, which are called if the start or end of a line is reached between matching start and end markers.
1116 Note that the function needs to be a function of the pdf class, so if you wish to use a custom function then you need to extend the class and add your own functions. This is done within the script that makes this document, to collect the information which makes the table of contents, and to add the dots on each line within the table of contents display.
1118 <b>NOTE</b> For various technical reasons if there are any spaces within the marker, then these will affect the justification calculation, it is best to avoid having them. This is why the title names in the example below were urlencoded when placed in the paramater section.
1120 <b>NOTE</b> These functions should be used with care, it is possible to set up an infinite loop. If the function called by the two-part form has an addText command within it, then if it is not set up very carefully then an infinite loop is formed as the function is re-called at the start and end of the addText command... and so on... and so on... and so on...
1122 As an example, here is the code which extends the class for this document
1125 include 'class.ezpdf.php';
1127 class Creport extends Cezpdf {
1129 // <i>make a location to store the information that will be collected during document formation</i>
1130 var $reportContents = array();
1132 // <i>it is neccesary to manually call the constructor of the extended class</i>
1133 function Creport($p,$o){
1134   $this->Cezpdf($p,$o);
1138 <i>The function 'rf' records in an array the page number level number and heading for each title as the document is constructed. This information is used at the end to construct the table of contents. Each heading has had a marker put next to it of the form:
1139 &lt;C:rf:1top%20heading>, which would be for a level 1 heading called 'top heading'.
1140 After the bulk of the document has been constructed, the array $pdf->reportContents is selected, and the table of contents made.
1141 </i> */
1142 function rf($info){
1143   $tmp = $info['p'];
1144   $lvl = $tmp[0];
1145   $lbl = rawurldecode(substr($tmp,1));
1146   $num=$this->ezWhatPageNumber($this->ezGetCurrentPageNumber());
1147   $this->reportContents[] = array($lbl,$num,$lvl );
1150 /*<i>
1151 The dots function is called by a marker of the form:
1152 &lt;C:dots:213>
1153 Which would represent a heading being show for which the original document was on page 13, and the heading was level 2. The marker is placed at the end of the text being displayed within the table of contents, upon activation it draws a dotted line across from that point to the right hand side of the page, and puts the given label there (to be more accurate it draws the line from the right, back to the left, so that all the dots line up down the page).
1154 </i>*/
1155 function dots($info){
1156   // draw a dotted line over to the right and put on a page number
1157   $tmp = $info['p'];
1158   $lvl = $tmp[0];
1159   $lbl = substr($tmp,1);
1160   $xpos = 520;
1162   switch($lvl){
1163     case '1':
1164       $size=16;
1165       $thick=1;
1166       break;
1167     case '2':
1168       $size=12;
1169       $thick=0.5;
1170       break;
1171   }
1172   $this->saveState();
1173   $this->setLineStyle($thick,'round','',array(0,10));
1174   $this->line($xpos,$info['y'],$info['x']+5,$info['y']);
1175   $this->restoreState();
1176   $this->addText($xpos+5,$info['y'],$size,$lbl);
1181 Both of these functions use only the single point call to a callback function, for an example of the more complicated two-part from, refer to the function 'alink' within class.ezpdf.php which uses callback functions to implement the url links on marked document text.
1183 2<Units>
1185 The units used for positioning within this class are the default pdf user units, in which each unit is roughly equivalent to 1/72 of an inch.
1187 and some additional user contributed notes are (thanks Andrew):
1189 1/72" is 0.3528mm or 1 point
1190 1 point was historically 0.0138 inches, a little under 1/72"
1191 10mm is 28.35 points
1192 A4 is 210 x 297 mm or 595.28 x 841.89 points