/
Writer.php
3287 lines (3055 loc) · 103 KB
/
Writer.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* Based on the FPDF class by Olivier Plathey (http://www.fpdf.org/).
*
* Minimal conversion to PHP 5 by Maintainable Software
* (http://maintainable.com).
*
* Copyright 2001-2003 Olivier Plathey <olivier@fpdf.org>
* Copyright 2003-2017 Horde LLC (http://www.horde.org/)
*
* @author Olivier Plathey <olivier@fpdf.org>
* @author Marko Djukic <marko@oblo.com>
* @author Jan Schneider <jan@horde.org>
* @license http://www.horde.org/licenses/lgpl21
* @category Horde
* @package Pdf
*/
/**
* The Horde_Pdf_Writer class provides a PHP-only implementation of a PDF
* library. No external libs or PHP extensions are required.
*
* @category Horde
* @package Pdf
*/
class Horde_Pdf_Writer
{
/**
* Current page number.
*
* @var integer
*/
protected $_page = 0;
/**
* Current object number.
*
* @var integer
*/
protected $_n = 2;
/**
* Array of object offsets.
*
* @var array
*/
protected $_offsets = array();
/**
* Buffer holding in-memory Pdf.
*
* @var string
*/
protected $_buffer = '';
/**
* Buffer length, including already flushed content.
*
* @var integer
*/
protected $_buflen = 0;
/**
* Whether the buffer has been flushed already.
*
* @var boolean
*/
protected $_flushed = false;
/**
* Array containing the pages.
*
* @var array
*/
protected $_pages = array();
/**
* Current document state.<pre>
* 0 - initial state
* 1 - document opened
* 2 - page opened
* 3 - document closed
* </pre>
*
* @var integer
*/
protected $_state = 0;
/**
* Flag indicating if PDF file is to be compressed or not.
*
* @var boolean
*/
protected $_compress;
/**
* The default page orientation.
*
* @var string
*/
protected $_default_orientation;
/**
* The current page orientation.
*
* @var string
*/
protected $_current_orientation;
/**
* Array indicating orientation changes.
*
* @var array
*/
protected $_orientation_changes = array();
/**
* Current width of page format in points.
*
* @var float
*/
public $fwPt;
/**
* Current height of page format in points.
*
* @var float
*/
public $fhPt;
/**
* Current width of page format in user units.
*
* @var float
*/
public $fw;
/**
* Current height of page format in user units.
*
* @var float
*/
public $fh;
/**
* Current width of page in points.
*
* @var float
*/
public $wPt;
/**
* Current height of page in points.
*
* @var float
*/
public $hPt;
/**
* Current width of page in user units
*
* @var float
*/
public $w;
/**
* Current height of page in user units
*
* @var float
*/
public $h;
/**
* Scale factor (number of points in user units).
*
* @var float
*/
protected $_scale;
/**
* Left page margin size.
*
* @var float
*/
protected $_left_margin;
/**
* Top page margin size.
*
* @var float
*/
protected $_top_margin;
/**
* Right page margin size.
*
* @var float
*/
protected $_right_margin;
/**
* Break page margin size, the bottom margin which triggers a page break.
*
* @var float
*/
protected $_break_margin;
/**
* Cell margin size.
*
* @var float
*/
protected $_cell_margin;
/**
* The current horizontal position for cell positioning.
* Value is set in user units and is calculated from the top left corner
* as origin.
*
* @var float
*/
public $x;
/**
* The current vertical position for cell positioning.
* Value is set in user units and is calculated from the top left corner
* as origin.
*
* @var float
*/
public $y;
/**
* The height of the last cell printed.
*
* @var float
*/
protected $_last_height;
/**
* Line width in user units.
*
* @var float
*/
protected $_line_width;
/**
* An array of standard font names.
*
* @var array
*/
protected $_core_fonts = array('courier' => 'Courier',
'courierB' => 'Courier-Bold',
'courierI' => 'Courier-Oblique',
'courierBI' => 'Courier-BoldOblique',
'helvetica' => 'Helvetica',
'helveticaB' => 'Helvetica-Bold',
'helveticaI' => 'Helvetica-Oblique',
'helveticaBI' => 'Helvetica-BoldOblique',
'times' => 'Times-Roman',
'timesB' => 'Times-Bold',
'timesI' => 'Times-Italic',
'timesBI' => 'Times-BoldItalic',
'symbol' => 'Symbol',
'zapfdingbats' => 'ZapfDingbats');
/**
* An array of used fonts.
*
* @var array
*/
protected $_fonts = array();
/**
* An array of font files.
*
* @var array
*/
protected $_font_files = array();
/**
* Widths of specific font files
*
* @var array
*/
protected static $_font_widths = array();
/**
* An array of encoding differences.
*
* @var array
*/
protected $_diffs = array();
/**
* An array of used images.
*
* @var array
*/
protected $_images = array();
/**
* An array of links in pages.
*
* @var array
*/
protected $_page_links;
/**
* An array of internal links.
*
* @var array
*/
protected $_links = array();
/**
* Current font family.
*
* @var string
*/
protected $_font_family = '';
/**
* Current font style.
*
* @var string
*/
protected $_font_style = '';
/**
* Underlining flag.
*
* @var boolean
*/
protected $_underline = false;
/**
* An array containing current font info.
*
* @var array
*/
protected $_current_font;
/**
* Current font size in points.
*
* @var float
*/
protected $_font_size_pt = 12;
/**
* Current font size in user units.
*
* @var float
*/
protected $_font_size = 12;
/**
* Commands for filling color.
*
* @var string
*/
protected $_fill_color = '0 g';
/**
* Commands for text color.
*
* @var string
*/
protected $_text_color = '0 g';
/**
* Whether text color is different from fill color.
*
* @var boolean
*/
protected $_color_flag = false;
/**
* Commands for drawing color.
*
* @var string
*/
protected $_draw_color = '0 G';
/**
* Word spacing.
*
* @var integer
*/
protected $_word_spacing = 0;
/**
* Automatic page breaking.
*
* @var boolean
*/
protected $_auto_page_break;
/**
* Threshold used to trigger page breaks.
*
* @var float
*/
protected $_page_break_trigger;
/**
* Flag set when processing footer.
*
* @var boolean
*/
protected $_in_footer = false;
/**
* Zoom display mode.
*
* @var string
*/
protected $_zoom_mode;
/**
* Layout display mode.
*
* @var string
*/
protected $_layout_mode;
/**
* An array containing the document info, consisting of:
* - title
* - subject
* - author
* - keywords
* - creator
*
* @var array
*/
protected $_info = array();
/**
* Alias for total number of pages.
*
* @var string
*/
protected $_alias_nb_pages = '{nb}';
/**
* Constructor
*
* It allows to set up the page format, the orientation and the units of
* measurement used in all the methods (except for the font sizes).
*
* Example:
* <code>
* $pdf = new Horde_Pdf_Writer(array('orientation' => 'P',
* 'unit' => 'mm',
* 'format' => 'A4'));
* </code>
*
* @param array $params A hash with parameters for the created PDF object.
* Possible parameters are:
* - orientation - Default page orientation. Possible
* values are (case insensitive):
* - P or Portrait (default)
* - L or Landscape
* - unit - User measure units. Possible values
* values are:
* - pt: point
* - mm: millimeter (default)
* - cm: centimeter
* - in: inch
* A point equals 1/72 of inch, that is to say
* about 0.35 mm (an inch being 2.54 cm). This is a
* very common unit in typography; font sizes are
* expressed in that unit.
* - format - The format used for pages. It can be
* either one of the following values (case
* insensitive):
* - A3
* - A4 (default)
* - A5
* - Letter
* - Legal
* or a custom format in the form of a two-element
* array containing the width and the height
* (expressed in the unit given by the unit
* parameter).
*/
public function __construct($params = array())
{
/* Default parameters. */
$defaults = array('orientation' => 'P', 'unit' => 'mm', 'format' => 'A4');
$params = array_merge($defaults, $params);
/* Scale factor. */
if ($params['unit'] == 'pt') {
$this->_scale = 1;
} elseif ($params['unit'] == 'mm') {
$this->_scale = 72 / 25.4;
} elseif ($params['unit'] == 'cm') {
$this->_scale = 72 / 2.54;
} elseif ($params['unit'] == 'in') {
$this->_scale = 72;
} else {
throw new Horde_Pdf_Exception(sprintf('Incorrect units: %s', $params['unit']));
}
/* Page format. */
if (is_string($params['format'])) {
$params['format'] = Horde_String::lower($params['format']);
if ($params['format'] == 'a3') {
$params['format'] = array(841.89, 1190.55);
} elseif ($params['format'] == 'a4') {
$params['format'] = array(595.28, 841.89);
} elseif ($params['format'] == 'a5') {
$params['format'] = array(420.94, 595.28);
} elseif ($params['format'] == 'letter') {
$params['format'] = array(612, 792);
} elseif ($params['format'] == 'legal') {
$params['format'] = array(612, 1008);
} else {
throw new Horde_Pdf_Exception(sprintf('Unknown page format: %s', $params['format']));
}
$this->fwPt = $params['format'][0];
$this->fhPt = $params['format'][1];
} else {
$this->fwPt = $params['format'][0] * $this->_scale;
$this->fhPt = $params['format'][1] * $this->_scale;
}
$this->fw = $this->fwPt / $this->_scale;
$this->fh = $this->fhPt / $this->_scale;
/* Page orientation. */
$params['orientation'] = Horde_String::lower($params['orientation']);
if ($params['orientation'] == 'p' || $params['orientation'] == 'portrait') {
$this->_default_orientation = 'P';
$this->wPt = $this->fwPt;
$this->hPt = $this->fhPt;
} elseif ($params['orientation'] == 'l' || $params['orientation'] == 'landscape') {
$this->_default_orientation = 'L';
$this->wPt = $this->fhPt;
$this->hPt = $this->fwPt;
} else {
throw new Horde_Pdf_Exception(sprintf('Incorrect orientation: %s', $params['orientation']));
}
$this->_current_orientation = $this->_default_orientation;
$this->w = $this->wPt / $this->_scale;
$this->h = $this->hPt / $this->_scale;
/* Page margins (1 cm) */
$margin = 28.35 / $this->_scale;
$this->setMargins($margin, $margin);
/* Interior cell margin (1 mm) */
$this->_cell_margin = $margin / 10;
/* Line width (0.2 mm) */
$this->_line_width = .567 / $this->_scale;
/* Automatic page break */
$this->setAutoPageBreak(true, 2 * $margin);
/* Full width display mode */
$this->setDisplayMode('fullwidth');
/* Compression */
$this->setCompression(true);
}
/**
* Defines the left, top and right margins.
*
* By default, they equal 1 cm. Call this method to change them.
*
* @param float $left Left margin.
* @param float $top Top margin.
* @param float $right Right margin. If not specified default to the value
* of the left one.
*
* @see setAutoPageBreak()
* @see setLeftMargin()
* @see setRightMargin()
* @see setTopMargin()
*/
public function setMargins($left, $top, $right = null)
{
/* Set left and top margins. */
$this->_left_margin = $left;
$this->_top_margin = $top;
/* If no right margin set default to same as left. */
$this->_right_margin = (is_null($right) ? $left : $right);
}
/**
* Defines the left margin.
*
* The method can be called before creating the first page. If the
* current abscissa gets out of page, it is brought back to the margin.
*
* @param float $margin The margin.
*
* @see setAutoPageBreak()
* @see setMargins()
* @see setRightMargin()
* @see setTopMargin()
*/
public function setLeftMargin($margin)
{
$this->_left_margin = $margin;
/* If there is a current page and the current X position is less than
* margin set the X position to the margin value. */
if ($this->_page > 0 && $this->x < $margin) {
$this->x = $margin;
}
}
/**
* Defines the top margin.
*
* The method can be called before creating the first page.
*
* @param float $margin The margin.
*/
public function setTopMargin($margin)
{
$this->_top_margin = $margin;
}
/**
* Defines the right margin.
*
* The method can be called before creating the first page.
*
* @param float $margin The margin.
*/
public function setRightMargin($margin)
{
$this->_right_margin = $margin;
}
/**
* Returns the actual page width.
*
* @return float The page width.
*/
public function getPageWidth()
{
return ($this->w - $this->_right_margin - $this->_left_margin);
}
/**
* Returns the actual page height.
*
* @return float The page height.
*/
public function getPageHeight()
{
return ($this->h - $this->_top_margin - $this->_break_margin);
}
/**
* Enables or disables the automatic page breaking mode.
*
* When enabling, the second parameter is the distance from the bottom of
* the page that defines the triggering limit. By default, the mode is on
* and the margin is 2 cm.
*
* @param boolean $auto Boolean indicating if mode should be on or off.
* @param float $margin Distance from the bottom of the page.
*/
public function setAutoPageBreak($auto, $margin = 0)
{
$this->_auto_page_break = $auto;
$this->_break_margin = $margin;
$this->_page_break_trigger = $this->h - $margin;
}
/**
* Defines the way the document is to be displayed by the viewer.
*
* The zoom level can be set: pages can be displayed entirely on screen,
* occupy the full width of the window, use real size, be scaled by a
* specific zooming factor or use viewer default (configured in the
* Preferences menu of Acrobat). The page layout can be specified too:
* single at once, continuous display, two columns or viewer default. By
* default, documents use the full width mode with continuous display.
*
* @param mixed $zoom The zoom to use. It can be one of the following
* string values:
* - fullpage: entire page on screen
* - fullwidth: maximum width of window
* - real: uses real size (100% zoom)
* - default: uses viewer default mode
* or a number indicating the zooming factor.
* @param string layout The page layout. Possible values are:
* - single: one page at once
* - continuous: pages in continuously
* - two: two pages on two columns
* - default: uses viewer default mode
* Default value is continuous.
*/
public function setDisplayMode($zoom, $layout = 'continuous')
{
$zoom = Horde_String::lower($zoom);
if ($zoom == 'fullpage' || $zoom == 'fullwidth' || $zoom == 'real'
|| $zoom == 'default' || !is_string($zoom)) {
$this->_zoom_mode = $zoom;
} elseif ($zoom == 'zoom') {
$this->_zoom_mode = $layout;
} else {
throw new Horde_Pdf_Exception(sprintf('Incorrect zoom display mode: %s', $zoom));
}
$layout = Horde_String::lower($layout);
if ($layout == 'single' || $layout == 'continuous' || $layout == 'two'
|| $layout == 'default') {
$this->_layout_mode = $layout;
} elseif ($zoom != 'zoom') {
throw new Horde_Pdf_Exception(sprintf('Incorrect layout display mode: %s', $layout));
}
}
/**
* Activates or deactivates page compression.
*
* When activated, the internal representation of each page is compressed,
* which leads to a compression ratio of about 2 for the resulting
* document. Compression is on by default.
*
* Note: the {@link http://www.php.net/zlib/ zlib extension} is required
* for this feature. If not present, compression will be turned off.
*
* @param boolean $compress Boolean indicating if compression must be
* enabled or not.
*/
public function setCompression($compress)
{
/* If no gzcompress function is available then default to false. */
$this->_compress = (function_exists('gzcompress') ? $compress : false);
}
/**
* Set the info to a document.
*
* Possible info settings are:
* - title
* - subject
* - author
* - keywords
* - creator
*
* @param array|string $info If passed as an array then the complete hash
* containing the info to be inserted into the
* document. Otherwise the name of setting to be
* set.
* @param string $value The value of the setting.
*/
public function setInfo($info, $value = '')
{
if (is_array($info)) {
$this->_info = $info;
} else {
$this->_info[$info] = $value;
}
}
/**
* Defines an alias for the total number of pages.
*
* It will be substituted as the document is closed.
*
* Example:
* <code>
* class My_Pdf extends Horde_Pdf_Writer {
* function footer()
* {
* // Go to 1.5 cm from bottom
* $this->setY(-15);
* // Select Arial italic 8
* $this->setFont('Arial', 'I', 8);
* // Print current and total page numbers
* $this->cell(0, 10, 'Page ' . $this->getPageNo() . '/{nb}', 0,
* 0, 'C');
* }
* }
* $pdf = new My_Pdf();
* $pdf->aliasNbPages();
* </code>
*
* @param string $alias The alias.
*
* @see getPageNo()
* @see footer()
*/
public function aliasNbPages($alias = '{nb}')
{
$this->_alias_nb_pages = $alias;
}
/**
* This method begins the generation of the PDF document; it must be
* called before any output commands.
*
* No page is created by this method, therefore it is necessary to call
* {@link addPage()}.
*
* @see addPage()
* @see close()
*/
public function open()
{
$this->_beginDoc();
}
/**
* Terminates the PDF document.
*
* If the document contains no page, {@link addPage()} is called to
* prevent from getting an invalid document.
*
* @see open()
*/
public function close()
{
// Terminate document
if ($this->_page == 0) {
$this->addPage();
}
// Page footer
$this->_in_footer = true;
$this->x = $this->_left_margin;
$this->footer();
$this->_in_footer = false;
// Close page and document
$this->_endPage();
$this->_endDoc();
}
/**
* Adds a new page to the document.
*
* If a page is already present, the {@link footer()} method is called
* first to output the footer. Then the page is added, the current
* position set to the top-left corner according to the left and top
* margins, and {@link header()} is called to display the header.
*
* The font which was set before calling is automatically restored. There
* is no need to call {@link setFont()} again if you want to continue with
* the same font. The same is true for colors and line width. The origin
* of the coordinate system is at the top-left corner and increasing
* ordinates go downwards.
*
* @param string $orientation Page orientation. Possible values
* are (case insensitive):
* - P or Portrait
* - L or Landscape
* The default value is the one passed to the
* constructor.
*
* @see header()
* @see footer()
* @see setMargins()
*/
public function addPage($orientation = '')
{
/* For good measure make sure this is called. */
$this->_beginDoc();
/* Save style settings so that they are not overridden by
* footer() or header(). */
$lw = $this->_line_width;
$dc = $this->_draw_color;
$fc = $this->_fill_color;
$tc = $this->_text_color;
$cf = $this->_color_flag;
$font_family = $this->_font_family;
$font_style = $this->_font_style . ($this->_underline ? 'U' : '');
$font_size = $this->_font_size_pt;
if ($this->_page > 0) {
/* Page footer. */
$this->_in_footer = true;
$this->x = $this->_left_margin;
$this->footer();
$this->_in_footer = false;
/* Close page. */
$this->_endPage();
}
/* Start new page. */
$this->_beginPage($orientation);
/* Set line cap style to square. */
$this->_out('2 J');
/* Set line width. */
$this->_line_width = $lw;
$this->_out(sprintf('%.2F w', $lw * $this->_scale));
/* Force the setting of the font. Each new page requires a new
* call. */
if ($font_family) {
$this->setFont($font_family, $font_style, $font_size, true);
}
/* Restore styles. */
if ($this->_fill_color != $fc) {
$this->_fill_color = $fc;
$this->_out($this->_fill_color);
}
if ($this->_draw_color != $dc) {
$this->_draw_color = $dc;
$this->_out($this->_draw_color);
}
$this->_text_color = $tc;
$this->_color_flag = $cf;
/* Page header. */
$this->header();
/* Restore styles. */
if ($this->_line_width != $lw) {
$this->_line_width = $lw;
$this->_out(sprintf('%.2F w', $lw * $this->_scale));
}
$this->setFont($font_family, $font_style, $font_size);
if ($this->_fill_color != $fc) {
$this->_fill_color = $fc;
$this->_out($this->_fill_color);
}
if ($this->_draw_color != $dc) {
$this->_draw_color = $dc;
$this->_out($this->_draw_color);
}
$this->_text_color = $tc;
$this->_color_flag = $cf;
}
/**
* This method is used to render the page header.
*
* It is automatically called by {@link addPage()} and should not be
* called directly by the application. The implementation in Horde_Pdf_Writer is
* empty, so you have to subclass it and override the method if you want a
* specific processing.
*
* Example:
* <code>
* class My_Pdf extends Horde_Pdf_Writer {
* function header()
* {
* // Select Arial bold 15
* $this->setFont('Arial', 'B', 15);
* // Move to the right
* $this->cell(80);
* // Framed title
* $this->cell(30, 10, 'Title', 1, 0, 'C');
* // Line break
* $this->newLine(20);
* }
* }
* </code>
*
* @see footer()
*/
public function header()
{
/* To be implemented in your own inherited class. */
}
/**
* This method is used to render the page footer.
*
* It is automatically called by {@link addPage()} and {@link close()} and
* should not be called directly by the application. The implementation in
* Horde_Pdf_Writer is empty, so you have to subclass it and override the method
* if you want a specific processing.
*
* Example:
* <code>
* class My_Pdf extends Horde_Pdf_Writer {
* function footer()
* {
* // Go to 1.5 cm from bottom
* $this->setY(-15);
* // Select Arial italic 8
* $this->setFont('Arial', 'I', 8);
* // Print centered page number
* $this->cell(0, 10, 'Page ' . $this->getPageNo(), 0, 0, 'C');
* }
* }
* </code>
*
* @see header()
*/
public function footer()
{
/* To be implemented in your own inherited class. */