MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
class.ezpdf.php
Ir para a documentação deste ficheiro.
1<?php
2include_once ('class.pdf.php');
3
4class Cezpdf extends Cpdf
5{
6 //==============================================================================
7 // this class will take the basic interaction facilities of the Cpdf class
8 // and make more useful functions so that the user does not have to
9 // know all the ins and outs of pdf presentation to produce something pretty.
10 //
11 // IMPORTANT NOTE
12 // there is no warranty, implied or otherwise with this software.
13 //
14 // version 009 (versioning is linked to class.pdf.php)
15 //
16 // released under a public domain licence.
17 //
18 // Wayne Munro, R&OS Ltd, http://www.ros.co.nz/pdf
19 //==============================================================================
20
21 var $ez = array('fontSize' => 10); // used for storing most of the page configuration parameters
22 var $y = 0.0; // this is the current vertical positon on the page of the writing point, very important
23 var $ezPages = array(
24 ); // keep an array of the ids of the pages, making it easy to go back and add page numbers etc.
25
26 var $ezPageCount = 0;
27
28 // ------------------------------------------------------------------------------
29
30 function Cezpdf($paper = 'a4', $orientation = 'portrait')
31 {
32 self::__construct($paper, $orientation);
33 }
34
35 function __construct($paper = 'a4', $orientation = 'portrait')
36 {
37 // Assuming that people don't want to specify the paper size using the absolute coordinates
38 // allow a couple of options:
39 // orientation can be 'portrait' or 'landscape'
40 // or, to actually set the coordinates, then pass an array in as the first parameter.
41 // the defaults are as shown.
42 //
43 // -------------------------
44 // 2002-07-24 - Nicola Asuni (info@tecnick.com):
45 // Added new page formats (45 standard ISO paper formats and 4 american common formats)
46 // paper cordinates are calculated in this way: (inches * 72) where 1 inch = 2.54 cm
47 //
48 // Now you may also pass a 2 values array containing the page width and height in centimeters
49 // -------------------------
50
51 if (!is_array($paper))
52 {
53 switch (strtoupper($paper))
54 {
55 case '4A0':
56 {
57 $size = array
58 (
59 0,
60 0,
61 4767.87,
62 6740.79
63 );
64
65 break;
66 }
67
68 case '2A0':
69 {
70 $size = array
71 (
72 0,
73 0,
74 3370.39,
75 4767.87
76 );
77
78 break;
79 }
80
81 case 'A0':
82 {
83 $size = array
84 (
85 0,
86 0,
87 2383.94,
88 3370.39
89 );
90
91 break;
92 }
93
94 case 'A1':
95 {
96 $size = array
97 (
98 0,
99 0,
100 1683.78,
101 2383.94
102 );
103
104 break;
105 }
106
107 case 'A2':
108 {
109 $size = array
110 (
111 0,
112 0,
113 1190.55,
114 1683.78
115 );
116
117 break;
118 }
119
120 case 'A3':
121 {
122 $size = array
123 (
124 0,
125 0,
126 841.89,
127 1190.55
128 );
129
130 break;
131 }
132
133 case 'A4':
134 default:
135 {
136 $size = array
137 (
138 0,
139 0,
140 595.28,
141 841.89
142 );
143
144 break;
145 }
146
147 case 'A5':
148 {
149 $size = array
150 (
151 0,
152 0,
153 419.53,
154 595.28
155 );
156
157 break;
158 }
159
160 case 'A6':
161 {
162 $size = array
163 (
164 0,
165 0,
166 297.64,
167 419.53
168 );
169
170 break;
171 }
172
173 case 'A7':
174 {
175 $size = array
176 (
177 0,
178 0,
179 209.76,
180 297.64
181 );
182
183 break;
184 }
185
186 case 'A8':
187 {
188 $size = array
189 (
190 0,
191 0,
192 147.40,
193 209.76
194 );
195
196 break;
197 }
198
199 case 'A9':
200 {
201 $size = array
202 (
203 0,
204 0,
205 104.88,
206 147.40
207 );
208
209 break;
210 }
211
212 case 'A10':
213 {
214 $size = array
215 (
216 0,
217 0,
218 73.70,
219 104.88
220 );
221
222 break;
223 }
224
225 case 'B0':
226 {
227 $size = array
228 (
229 0,
230 0,
231 2834.65,
232 4008.19
233 );
234
235 break;
236 }
237
238 case 'B1':
239 {
240 $size = array
241 (
242 0,
243 0,
244 2004.09,
245 2834.65
246 );
247
248 break;
249 }
250
251 case 'B2':
252 {
253 $size = array
254 (
255 0,
256 0,
257 1417.32,
258 2004.09
259 );
260
261 break;
262 }
263
264 case 'B3':
265 {
266 $size = array
267 (
268 0,
269 0,
270 1000.63,
271 1417.32
272 );
273
274 break;
275 }
276
277 case 'B4':
278 {
279 $size = array
280 (
281 0,
282 0,
283 708.66,
284 1000.63
285 );
286
287 break;
288 }
289
290 case 'B5':
291 {
292 $size = array
293 (
294 0,
295 0,
296 498.90,
297 708.66
298 );
299
300 break;
301 }
302
303 case 'B6':
304 {
305 $size = array
306 (
307 0,
308 0,
309 354.33,
310 498.90
311 );
312
313 break;
314 }
315
316 case 'B7':
317 {
318 $size = array
319 (
320 0,
321 0,
322 249.45,
323 354.33
324 );
325
326 break;
327 }
328
329 case 'B8':
330 {
331 $size = array
332 (
333 0,
334 0,
335 175.75,
336 249.45
337 );
338
339 break;
340 }
341
342 case 'B9':
343 {
344 $size = array
345 (
346 0,
347 0,
348 124.72,
349 175.75
350 );
351
352 break;
353 }
354
355 case 'B10':
356 {
357 $size = array
358 (
359 0,
360 0,
361 87.87,
362 124.72
363 );
364
365 break;
366 }
367
368 case 'C0':
369 {
370 $size = array
371 (
372 0,
373 0,
374 2599.37,
375 3676.54
376 );
377
378 break;
379 }
380
381 case 'C1':
382 {
383 $size = array
384 (
385 0,
386 0,
387 1836.85,
388 2599.37
389 );
390
391 break;
392 }
393
394 case 'C2':
395 {
396 $size = array
397 (
398 0,
399 0,
400 1298.27,
401 1836.85
402 );
403
404 break;
405 }
406
407 case 'C3':
408 {
409 $size = array
410 (
411 0,
412 0,
413 918.43,
414 1298.27
415 );
416
417 break;
418 }
419
420 case 'C4':
421 {
422 $size = array
423 (
424 0,
425 0,
426 649.13,
427 918.43
428 );
429
430 break;
431 }
432
433 case 'C5':
434 {
435 $size = array
436 (
437 0,
438 0,
439 459.21,
440 649.13
441 );
442
443 break;
444 }
445
446 case 'C6':
447 {
448 $size = array
449 (
450 0,
451 0,
452 323.15,
453 459.21
454 );
455
456 break;
457 }
458
459 case 'C7':
460 {
461 $size = array
462 (
463 0,
464 0,
465 229.61,
466 323.15
467 );
468
469 break;
470 }
471
472 case 'C8':
473 {
474 $size = array
475 (
476 0,
477 0,
478 161.57,
479 229.61
480 );
481
482 break;
483 }
484
485 case 'C9':
486 {
487 $size = array
488 (
489 0,
490 0,
491 113.39,
492 161.57
493 );
494
495 break;
496 }
497
498 case 'C10':
499 {
500 $size = array
501 (
502 0,
503 0,
504 79.37,
505 113.39
506 );
507
508 break;
509 }
510
511 case 'RA0':
512 {
513 $size = array
514 (
515 0,
516 0,
517 2437.80,
518 3458.27
519 );
520
521 break;
522 }
523
524 case 'RA1':
525 {
526 $size = array
527 (
528 0,
529 0,
530 1729.13,
531 2437.80
532 );
533
534 break;
535 }
536
537 case 'RA2':
538 {
539 $size = array
540 (
541 0,
542 0,
543 1218.90,
544 1729.13
545 );
546
547 break;
548 }
549
550 case 'RA3':
551 {
552 $size = array
553 (
554 0,
555 0,
556 864.57,
557 1218.90
558 );
559
560 break;
561 }
562
563 case 'RA4':
564 {
565 $size = array
566 (
567 0,
568 0,
569 609.45,
570 864.57
571 );
572
573 break;
574 }
575
576 case 'SRA0':
577 {
578 $size = array
579 (
580 0,
581 0,
582 2551.18,
583 3628.35
584 );
585
586 break;
587 }
588
589 case 'SRA1':
590 {
591 $size = array
592 (
593 0,
594 0,
595 1814.17,
596 2551.18
597 );
598
599 break;
600 }
601
602 case 'SRA2':
603 {
604 $size = array
605 (
606 0,
607 0,
608 1275.59,
609 1814.17
610 );
611
612 break;
613 }
614
615 case 'SRA3':
616 {
617 $size = array
618 (
619 0,
620 0,
621 907.09,
622 1275.59
623 );
624
625 break;
626 }
627
628 case 'SRA4':
629 {
630 $size = array
631 (
632 0,
633 0,
634 637.80,
635 907.09
636 );
637
638 break;
639 }
640
641 case 'LETTER':
642 {
643 $size = array
644 (
645 0,
646 0,
647 612.00,
648 792.00
649 );
650
651 break;
652 }
653
654 case 'LEGAL':
655 {
656 $size = array
657 (
658 0,
659 0,
660 612.00,
661 1008.00
662 );
663
664 break;
665 }
666
667 case 'EXECUTIVE':
668 {
669 $size = array
670 (
671 0,
672 0,
673 521.86,
674 756.00
675 );
676
677 break;
678 }
679
680 case 'FOLIO':
681 {
682 $size = array
683 (
684 0,
685 0,
686 612.00,
687 936.00
688 );
689
690 break;
691 }
692 }
693
694 switch (strtolower($orientation))
695 {
696 case 'landscape':
697 $a = $size[3];
698
699 $size[3] = $size[2];
700 $size[2] = $a;
701 break;
702 }
703 }
704 else
705 {
706 if (count($paper) > 2)
707 {
708 // then an array was sent it to set the size
709 $size = $paper;
710 }
711 else
712 { //size in centimeters has been passed
713 $size[0] = 0;
714 $size[1] = 0;
715 $size[2] = ($paper[0] / 2.54) * 72;
716 $size[3] = ($paper[1] / 2.54) * 72;
717 }
718 }
719
720 $this->Cpdf($size);
721 $this->ez['pageWidth'] = $size[2];
722 $this->ez['pageHeight'] = $size[3];
723
724 // also set the margins to some reasonable defaults
725 $this->ez['topMargin'] = 30;
726 $this->ez['bottomMargin'] = 30;
727 $this->ez['leftMargin'] = 30;
728 $this->ez['rightMargin'] = 30;
729
730 // set the current writing position to the top of the first page
731 $this->y = $this->ez['pageHeight'] - $this->ez['topMargin'];
732 // and get the ID of the page that was created during the instancing process.
733 $this->ezPages[1] = $this->getFirstPageId();
734 $this->ezPageCount = 1;
735 }
736
737 // ------------------------------------------------------------------------------
738 // 2002-07-24: Nicola Asuni (info@tecnick.com)
739 // Set Margins in centimeters
740 function ezSetCmMargins($top, $bottom, $left, $right)
741 {
742 $top = ($top / 2.54) * 72;
743 $bottom = ($bottom / 2.54) * 72;
744 $left = ($left / 2.54) * 72;
745 $right = ($right / 2.54) * 72;
746 $this->ezSetMargins($top, $bottom, $left, $right);
747 }
748 // ------------------------------------------------------------------------------
749
750 function ezColumnsStart($options = array(
751 ))
752 {
753 // start from the current y-position, make the set number of columne
754 if (isset($this->ez['columns']) && $this->ez['columns'] == 1)
755 {
756 // if we are already in a column mode then just return.
757 return;
758 }
759
760 $def = array
761 (
762 'gap' => 10,
763 'num' => 2
764 );
765
766 foreach ($def as $k => $v)
767 {
768 if (!isset($options[$k]))
769 {
770 $options[$k] = $v;
771 }
772 }
773
774 // setup the columns
775 $this->ez['columns'] = array
776 (
777 'on' => 1,
778 'colNum' => 1
779 );
780
781 // store the current margins
782 $this->ez['columns']['margins'] = array
783 (
784 $this->ez['leftMargin'],
785 $this->ez['rightMargin'],
786 $this->ez['topMargin'],
787 $this->ez['bottomMargin']
788 );
789
790 // and store the settings for the columns
791 $this->ez['columns']['options'] = $options;
792 // then reset the margins to suit the new columns
793 // safe enough to assume the first column here, but start from the current y-position
794 $this->ez['topMargin'] = $this->ez['pageHeight'] - $this->y;
795 $width = ($this->ez['pageWidth'] - $this->ez['leftMargin'] - $this->ez['rightMargin'] - ($options['num'] - 1)
796 * $options['gap']) / $options['num'];
797 $this->ez['columns']['width'] = $width;
798 $this->ez['rightMargin'] = $this->ez['pageWidth'] - $this->ez['leftMargin'] - $width;
799 }
800
801 // ------------------------------------------------------------------------------
802 function ezColumnsStop()
803 {
804 if (isset($this->ez['columns']) && $this->ez['columns']['on'] == 1)
805 {
806 $this->ez['columns']['on'] = 0;
807 $this->ez['leftMargin'] = $this->ez['columns']['margins'][0];
808 $this->ez['rightMargin'] = $this->ez['columns']['margins'][1];
809 $this->ez['topMargin'] = $this->ez['columns']['margins'][2];
810 $this->ez['bottomMargin'] = $this->ez['columns']['margins'][3];
811 }
812 }
813
814 // ------------------------------------------------------------------------------
815 function ezInsertMode($status = 1, $pageNum = 1, $pos = 'before')
816 {
817 // puts the document into insert mode. new pages are inserted until this is re-called with status=0
818 // by default pages wil be inserted at the start of the document
819 switch ($status)
820 {
821 case '1':
822 if (isset($this->ezPages[$pageNum]))
823 {
824 $this->ez['insertMode'] = 1;
825 $this->ez['insertOptions'] = array
826 (
827 'id' => $this->ezPages[$pageNum],
828 'pos' => $pos
829 );
830 }
831
832 break;
833
834 case '0':
835 $this->ez['insertMode'] = 0;
836
837 break;
838 }
839 }
840 // ------------------------------------------------------------------------------
841
842 function ezNewPage()
843 {
844 $pageRequired = 1;
845
846 if (isset($this->ez['columns']) && $this->ez['columns']['on'] == 1)
847 {
848 // check if this is just going to a new column
849 // increment the column number
850 //echo 'HERE<br>';
851 $this->ez['columns']['colNum']++;
852
853 //echo $this->ez['columns']['colNum'].'<br>';
854 if ($this->ez['columns']['colNum'] <= $this->ez['columns']['options']['num'])
855 {
856 // then just reset to the top of the next column
857 $pageRequired = 0;
858 }
859 else
860 {
861 $this->ez['columns']['colNum'] = 1;
862 $this->ez['topMargin'] = $this->ez['columns']['margins'][2];
863 }
864
865 $width = $this->ez['columns']['width'];
866 $this->ez['leftMargin'] = $this->ez['columns']['margins'][0] + ($this->ez['columns']['colNum'] - 1)
867 * ($this->ez['columns']['options']['gap'] + $width);
868 $this->ez['rightMargin'] = $this->ez['pageWidth'] - $this->ez['leftMargin'] - $width;
869 }
870 //echo 'left='.$this->ez['leftMargin'].' right='.$this->ez['rightMargin'].'<br>';
871
872 if ($pageRequired)
873 {
874 // make a new page, setting the writing point back to the top
875 $this->y = $this->ez['pageHeight'] - $this->ez['topMargin'];
876 // make the new page with a call to the basic class.
877 $this->ezPageCount++;
878
879 if (isset($this->ez['insertMode']) && $this->ez['insertMode'] == 1)
880 {
881 $id = $this->ezPages[$this->ezPageCount] = $this->newPage(1, $this->ez['insertOptions']['id'],
882 $this->ez['insertOptions']['pos']);
883 // then manipulate the insert options so that inserted pages follow each other
884 $this->ez['insertOptions']['id'] = $id;
885 $this->ez['insertOptions']['pos'] = 'after';
886 }
887 else
888 {
889 $this->ezPages[$this->ezPageCount] = $this->newPage();
890 }
891 }
892 else
893 {
894 $this->y = $this->ez['pageHeight'] - $this->ez['topMargin'];
895 }
896 }
897
898 // ------------------------------------------------------------------------------
899
900 function ezSetMargins($top, $bottom, $left, $right)
901 {
902 // sets the margins to new values
903 $this->ez['topMargin'] = $top;
904 $this->ez['bottomMargin'] = $bottom;
905 $this->ez['leftMargin'] = $left;
906 $this->ez['rightMargin'] = $right;
907
908 // check to see if this means that the current writing position is outside the
909 // writable area
910 if ($this->y > $this->ez['pageHeight'] - $top)
911 {
912 // then move y down
913 $this->y = $this->ez['pageHeight'] - $top;
914 }
915
916 if ($this->y < $bottom)
917 {
918 // then make a new page
919 $this->ezNewPage();
920 }
921 }
922
923 // ------------------------------------------------------------------------------
924
925 function ezGetCurrentPageNumber()
926 {
927 // return the strict numbering (1,2,3,4..) number of the current page
928 return $this->ezPageCount;
929 }
930
931 // ------------------------------------------------------------------------------
932
933 function ezStartPageNumbers($x, $y, $size, $pos = 'left', $pattern = '{PAGENUM} of {TOTALPAGENUM}', $num = '')
934 {
935 // put page numbers on the pages from here.
936 // place then on the 'pos' side of the coordinates (x,y).
937 // pos can be 'left' or 'right'
938 // use the given 'pattern' for display, where (PAGENUM} and {TOTALPAGENUM} are replaced
939 // as required.
940 // if $num is set, then make the first page this number, the number of total pages will
941 // be adjusted to account for this.
942 // Adjust this function so that each time you 'start' page numbers then you effectively start a different batch
943 // return the number of the batch, so that they can be stopped in a different order if required.
944 if (!$pos || !strlen($pos))
945 {
946 $pos = 'left';
947 }
948
949 if (!$pattern || !strlen($pattern))
950 {
951 $pattern = '{PAGENUM} of {TOTALPAGENUM}';
952 }
953
954 if (!isset($this->ez['pageNumbering']))
955 {
956 $this->ez['pageNumbering'] = array(
957 );
958 }
959
960 $i = count($this->ez['pageNumbering']);
961 $this->ez['pageNumbering'][$i][$this->ezPageCount] = array
962 (
963 'x' => $x,
964 'y' => $y,
965 'pos' => $pos,
966 'pattern' => $pattern,
967 'num' => $num,
968 'size' => $size
969 );
970
971 return $i;
972 }
973
974 // ------------------------------------------------------------------------------
975
976 function ezWhatPageNumber($pageNum, $i = 0)
977 {
978 // given a particular generic page number (ie, document numbered sequentially from beginning),
979 // return the page number under a particular page numbering scheme ($i)
980 $num = 0;
981 $start = 1;
982 $startNum = 1;
983
984 if (!isset($this->ez['pageNumbering']))
985 {
986 $this->addMessage('WARNING: page numbering called for and wasn\'t started with ezStartPageNumbers');
987 return 0;
988 }
989
990 foreach ($this->ez['pageNumbering'][$i] as $k => $v)
991 {
992 if ($k <= $pageNum)
993 {
994 if (is_array($v))
995 {
996 // start block
997 if (strlen($v['num']))
998 {
999 // a start was specified
1000 $start = $v['num'];
1001 $startNum = $k;
1002 $num = $pageNum - $startNum + $start;
1003 }
1004 }
1005 else
1006 {
1007 // stop block
1008 $num = 0;
1009 }
1010 }
1011 }
1012
1013 return $num;
1014 }
1015
1016 // ------------------------------------------------------------------------------
1017
1018 function ezStopPageNumbers($stopTotal = 0, $next = 0, $i = 0)
1019 {
1020 // if stopTotal=1 then the totalling of pages for this number will stop too
1021 // if $next=1, then do this page, but not the next, else do not do this page either
1022 // if $i is set, then stop that particular pagenumbering sequence.
1023 if (!isset($this->ez['pageNumbering']))
1024 {
1025 $this->ez['pageNumbering'] = array(
1026 );
1027 }
1028
1029 if ($next && isset($this->ez['pageNumbering'][$i][$this->ezPageCount]) && is_array(
1030 $this->ez['pageNumbering'][$i][$this->ezPageCount]))
1031 {
1032 // then this has only just been started, this will over-write the start, and nothing will appear
1033 // add a special command to the start block, telling it to stop as well
1034 if ($stopTotal)
1035 {
1036 $this->ez['pageNumbering'][$i][$this->ezPageCount]['stoptn'] = 1;
1037 }
1038 else
1039 {
1040 $this->ez['pageNumbering'][$i][$this->ezPageCount]['stopn'] = 1;
1041 }
1042 }
1043 else
1044 {
1045 if ($stopTotal)
1046 {
1047 $this->ez['pageNumbering'][$i][$this->ezPageCount] = 'stopt';
1048 }
1049 else
1050 {
1051 $this->ez['pageNumbering'][$i][$this->ezPageCount] = 'stop';
1052 }
1053
1054 if ($next)
1055 {
1056 $this->ez['pageNumbering'][$i][$this->ezPageCount] .= 'n';
1057 }
1058 }
1059 }
1060
1061 // ------------------------------------------------------------------------------
1062
1063 function ezPRVTpageNumberSearch($lbl, &$tmp)
1064 {
1065 foreach ($tmp as $i => $v)
1066 {
1067 if (is_array($v))
1068 {
1069 if (isset($v[$lbl]))
1070 {
1071 return $i;
1072 }
1073 }
1074 else
1075 {
1076 if ($v == $lbl)
1077 {
1078 return $i;
1079 }
1080 }
1081 }
1082
1083 return 0;
1084 }
1085
1086 // ------------------------------------------------------------------------------
1087
1088 function ezPRVTaddPageNumbers()
1089 {
1090 // this will go through the pageNumbering array and add the page numbers are required
1091 if (isset($this->ez['pageNumbering']))
1092 {
1093 $totalPages1 = $this->ezPageCount;
1094 $tmp1 = $this->ez['pageNumbering'];
1095 $status = 0;
1096
1097 foreach ($tmp1 as $i => $tmp)
1098 {
1099 // do each of the page numbering systems
1100 // firstly, find the total pages for this one
1101 $k = $this->ezPRVTpageNumberSearch('stopt', $tmp);
1102
1103 if ($k && $k > 0)
1104 {
1105 $totalPages = $k - 1;
1106 }
1107 else
1108 {
1109 $l = $this->ezPRVTpageNumberSearch('stoptn', $tmp);
1110
1111 if ($l && $l > 0)
1112 {
1113 $totalPages = $l;
1114 }
1115 else
1116 {
1117 $totalPages = $totalPages1;
1118 }
1119 }
1120
1121 foreach ($this->ezPages as $pageNum => $id)
1122 {
1123 if (isset($tmp[$pageNum]))
1124 {
1125 if (is_array($tmp[$pageNum]))
1126 {
1127 // then this must be starting page numbers
1128 $status = 1;
1129 $info = $tmp[$pageNum];
1130 $info['dnum'] = $info['num'] - $pageNum;
1131
1132 // also check for the special case of the numbering stopping and starting on the same page
1133 if (isset($info['stopn']) || isset($info['stoptn']))
1134 {
1135 $status = 2;
1136 }
1137 }
1138 else if ($tmp[$pageNum] == 'stop' || $tmp[$pageNum] == 'stopt')
1139 {
1140 // then we are stopping page numbers
1141 $status = 0;
1142 }
1143 else if ($status == 1 && ($tmp[$pageNum] == 'stoptn' || $tmp[$pageNum] == 'stopn'))
1144 {
1145 // then we are stopping page numbers
1146 $status = 2;
1147 }
1148 }
1149
1150 if ($status)
1151 {
1152 // then add the page numbering to this page
1153 if (strlen($info['num']))
1154 {
1155 $num = $pageNum + $info['dnum'];
1156 }
1157 else
1158 {
1159 $num = $pageNum;
1160 }
1161
1162 $total = $totalPages + $num - $pageNum;
1163 $pat = str_replace('{PAGENUM}', $num, $info['pattern']);
1164 $pat = str_replace('{TOTALPAGENUM}', $total, $pat);
1165 $this->reopenObject($id);
1166
1167 switch ($info['pos'])
1168 {
1169 case 'right':
1170 $this->addText($info['x'], $info['y'], $info['size'], $pat);
1171
1172 break;
1173
1174 default:
1175 $w = $this->getTextWidth($info['size'], $pat);
1176
1177 $this->addText($info['x'] - $w, $info['y'], $info['size'], $pat);
1178 break;
1179 }
1180
1181 $this->closeObject();
1182 }
1183
1184 if ($status == 2)
1185 {
1186 $status = 0;
1187 }
1188 }
1189 }
1190 }
1191 }
1192
1193 // ------------------------------------------------------------------------------
1194
1195 function ezPRVTcleanUp()
1196 {
1197 $this->ezPRVTaddPageNumbers();
1198 }
1199
1200 // ------------------------------------------------------------------------------
1201
1202 function ezStream($options = '')
1203 {
1204 $this->ezPRVTcleanUp();
1205 $this->stream($options);
1206 }
1207
1208 // ------------------------------------------------------------------------------
1209
1210 function ezOutput($options = 0)
1211 {
1212 $this->ezPRVTcleanUp();
1213 return $this->output($options);
1214 }
1215
1216 // ------------------------------------------------------------------------------
1217
1218 function ezSetY($y)
1219 {
1220 // used to change the vertical position of the writing point.
1221 $this->y = $y;
1222
1223 if ($this->y < $this->ez['bottomMargin'])
1224 {
1225 // then make a new page
1226 $this->ezNewPage();
1227 }
1228 }
1229
1230 // ------------------------------------------------------------------------------
1231
1232 function ezSetDy($dy, $mod = '')
1233 {
1234 // used to change the vertical position of the writing point.
1235 // changes up by a positive increment, so enter a negative number to go
1236 // down the page
1237 // if $mod is set to 'makeSpace' and a new page is forced, then the pointed will be moved
1238 // down on the new page, this will allow space to be reserved for graphics etc.
1239 $this->y += $dy;
1240
1241 if ($this->y < $this->ez['bottomMargin'])
1242 {
1243 // then make a new page
1244 $this->ezNewPage();
1245
1246 if ($mod == 'makeSpace')
1247 {
1248 $this->y += $dy;
1249 }
1250 }
1251 }
1252
1253 // ------------------------------------------------------------------------------
1254
1255 function ezPrvtTableDrawLines($pos, $gap, $x0, $x1, $y0, $y1, $y2, $col, $inner, $outer, $opt = 1)
1256 {
1257 $x0 = 1000;
1258 $x1 = 0;
1259 $this->setStrokeColor($col[0], $col[1], $col[2]);
1260 $cnt = 0;
1261 $n = count($pos);
1262
1263 foreach ($pos as $x)
1264 {
1265 $cnt++;
1266
1267 if ($cnt == 1 || $cnt == $n)
1268 {
1269 $this->setLineStyle($outer);
1270 }
1271 else
1272 {
1273 $this->setLineStyle($inner);
1274 }
1275
1276 $this->line($x - $gap / 2, $y0, $x - $gap / 2, $y2);
1277
1278 if ($x > $x1)
1279 {
1280 $x1 = $x;
1281 }
1282
1283 ;
1284
1285 if ($x < $x0)
1286 {
1287 $x0 = $x;
1288 }
1289
1290 ;
1291 }
1292
1293 $this->setLineStyle($outer);
1294 $this->line($x0 - $gap / 2 - $outer / 2, $y0, $x1 - $gap / 2 + $outer / 2, $y0);
1295
1296 // only do the second line if it is different to the first, AND each row does not have
1297 // a line on it.
1298 if ($y0 != $y1 && $opt < 2)
1299 {
1300 $this->line($x0 - $gap / 2, $y1, $x1 - $gap / 2, $y1);
1301 }
1302
1303 $this->line($x0 - $gap / 2 - $outer / 2, $y2, $x1 - $gap / 2 + $outer / 2, $y2);
1304 }
1305
1306 // ------------------------------------------------------------------------------
1307
1308 function ezPrvtTableColumnHeadings($cols, $pos, $maxWidth, $height, $decender, $gap, $size, &$y,
1309 $optionsAll = array(
1310 ))
1311 {
1312 // uses ezText to add the text, and returns the height taken by the largest heading
1313 // this page will move the headings to a new page if they will not fit completely on this one
1314 // transaction support will be used to implement this
1315
1316 if (isset($optionsAll['cols']))
1317 {
1318 $options = $optionsAll['cols'];
1319 }
1320 else
1321 {
1322 $options = array(
1323 );
1324 }
1325
1326 $mx = 0;
1327 $startPage = $this->ezPageCount;
1328 $secondGo = 0;
1329
1330 // $y is the position at which the top of the table should start, so the base
1331 // of the first text, is $y-$height-$gap-$decender, but ezText starts by dropping $height
1332
1333 // the return from this function is the total cell height, including gaps, and $y is adjusted
1334 // to be the postion of the bottom line
1335
1336 // begin the transaction
1337 $this->transaction('start');
1338 $ok = 0;
1339 // $y-=$gap-$decender;
1340 $y -= $gap;
1341
1342 while ($ok == 0)
1343 {
1344 foreach ($cols as $colName => $colHeading)
1345 {
1346 $this->ezSetY($y);
1347
1348 if (isset($options[$colName]) && isset($options[$colName]['justification']))
1349 {
1350 $justification = $options[$colName]['justification'];
1351 }
1352 else
1353 {
1354 $justification = 'left';
1355 }
1356
1357 $this->ezText($colHeading,
1358 $size,
1359 array('aleft' => $pos[$colName], 'aright' => ($maxWidth[$colName] + $pos[$colName]),
1360 'justification' => $justification));
1361 $dy = $y - $this->y;
1362
1363 if ($dy > $mx)
1364 {
1365 $mx = $dy;
1366 }
1367 }
1368
1369 $y = $y - $mx - $gap + $decender;
1370
1371 // $y -= $mx-$gap+$decender;
1372
1373 // now, if this has moved to a new page, then abort the transaction, move to a new page, and put it there
1374 // do not check on the second time around, to avoid an infinite loop
1375 if ($this->ezPageCount != $startPage && $secondGo == 0)
1376 {
1377 $this->transaction('rewind');
1378 $this->ezNewPage();
1379 $y = $this->y - $gap - $decender;
1380 $ok = 0;
1381 $secondGo = 1;
1382 // $y = $store_y;
1383 $mx = 0;
1384 }
1385 else
1386 {
1387 $this->transaction('commit');
1388 $ok = 1;
1389 }
1390 }
1391
1392 return $mx + $gap * 2 - $decender;
1393 }
1394
1395 // ------------------------------------------------------------------------------
1396
1397 function ezPrvtGetTextWidth($size, $text)
1398 {
1399 // will calculate the maximum width, taking into account that the text may be broken
1400 // by line breaks.
1401 $mx = 0;
1402 $lines = explode("\n", $text);
1403
1404 foreach ($lines as $line)
1405 {
1406 $w = $this->getTextWidth($size, $line);
1407
1408 if ($w > $mx)
1409 {
1410 $mx = $w;
1411 }
1412 }
1413
1414 return $mx;
1415 }
1416
1417 // ------------------------------------------------------------------------------
1418
1419 function ezTable(&$data, $cols = '', $title = '', $options = '')
1420 {
1421 // add a table of information to the pdf document
1422 // $data is a two dimensional array
1423 // $cols (optional) is an associative array, the keys are the names of the columns from $data
1424 // to be presented (and in that order), the values are the titles to be given to the columns
1425 // $title (optional) is the title to be put on the top of the table
1426 //
1427 // $options is an associative array which can contain:
1428 // 'showLines'=> 0,1,2, default is 1 (show outside and top lines only), 2=> lines on each row
1429 // 'showHeadings' => 0 or 1
1430 // 'shaded'=> 0,1,2,3 default is 1 (1->alternate lines are shaded, 0->no shading, 2-> both shaded, second uses shadeCol2)
1431 // 'shadeCol' => (r,g,b) array, defining the colour of the shading, default is (0.8,0.8,0.8)
1432 // 'shadeCol2' => (r,g,b) array, defining the colour of the shading of the other blocks, default is (0.7,0.7,0.7)
1433 // 'fontSize' => 10
1434 // 'textCol' => (r,g,b) array, text colour
1435 // 'titleFontSize' => 12
1436 // 'rowGap' => 2 , the space added at the top and bottom of each row, between the text and the lines
1437 // 'colGap' => 5 , the space on the left and right sides of each cell
1438 // 'lineCol' => (r,g,b) array, defining the colour of the lines, default, black.
1439 // 'xPos' => 'left','right','center','centre',or coordinate, reference coordinate in the x-direction
1440 // 'xOrientation' => 'left','right','center','centre', position of the table w.r.t 'xPos'
1441 // 'width'=> <number> which will specify the width of the table, if it turns out to not be this
1442 // wide, then it will stretch the table to fit, if it is wider then each cell will be made
1443 // proportionalty smaller, and the content may have to wrap.
1444 // 'maxWidth'=> <number> similar to 'width', but will only make table smaller than it wants to be
1445 // 'options' => array(<colname>=>array('justification'=>'left','width'=>100,'link'=>linkDataName),<colname>=>....)
1446 // allow the setting of other paramaters for the individual columns
1447 // 'minRowSpace'=> the minimum space between the bottom of each row and the bottom margin, in which a new row will be started
1448 // if it is less, then a new page would be started, default=-100
1449 // 'innerLineThickness'=>1
1450 // 'outerLineThickness'=>1
1451 // 'splitRows'=>0, 0 or 1, whether or not to allow the rows to be split across page boundaries
1452 // 'protectRows'=>number, the number of rows to hold with the heading on page, ie, if there less than this number of
1453 // rows on the page, then move the whole lot onto the next page, default=1
1454 //
1455 // note that the user will have had to make a font selection already or this will not
1456 // produce a valid pdf file.
1457
1458 if (!is_array($data))
1459 {
1460 return;
1461 }
1462
1463 if (!is_array($cols))
1464 {
1465 // take the columns from the first row of the data set
1466 reset ($data);
1467 list($k, $v) = each($data);
1468
1469 if (!is_array($v))
1470 {
1471 return;
1472 }
1473
1474 $cols = array(
1475 );
1476
1477 foreach ($v as $k1 => $v1)
1478 {
1479 $cols[$k1] = $k1;
1480 }
1481 }
1482
1483 if (!is_array($options))
1484 {
1485 $options = array(
1486 );
1487 }
1488
1489 $defaults = array
1490 (
1491 'shaded' => 1,
1492 'showLines' => 1,
1493 'shadeCol' => array(0.8, 0.8, 0.8),
1494 'shadeCol2' => array(0.7, 0.7, 0.7),
1495 'fontSize' => 10,
1496 'titleFontSize' => 12,
1497 'titleGap' => 5,
1498 'lineCol' => array(0, 0, 0),
1499 'gap' => 5,
1500 'xPos' => 'centre',
1501 'xOrientation' => 'centre',
1502 'showHeadings' => 1,
1503 'textCol' => array(0, 0, 0),
1504 'width' => 0,
1505 'maxWidth' => 0,
1506 'cols' => array(
1507 ),
1508 'minRowSpace' => -100,
1509 'rowGap' => 2,
1510 'colGap' => 5,
1511 'innerLineThickness' => 1,
1512 'outerLineThickness' => 1,
1513 'splitRows' => 0,
1514 'protectRows' => 1
1515 );
1516
1517 foreach ($defaults as $key => $value)
1518 {
1519 if (is_array($value))
1520 {
1521 if (!isset($options[$key]) || !is_array($options[$key]))
1522 {
1523 $options[$key] = $value;
1524 }
1525 }
1526 else
1527 {
1528 if (!isset($options[$key]))
1529 {
1530 $options[$key] = $value;
1531 }
1532 }
1533 }
1534
1535 $options['gap'] = 2 * $options['colGap'];
1536
1537 $middle = ($this->ez['pageWidth'] - $this->ez['rightMargin']) / 2 + ($this->ez['leftMargin']) / 2;
1538 // figure out the maximum widths of the text within each column
1539 $maxWidth = array(
1540 );
1541
1542 foreach ($cols as $colName => $colHeading)
1543 {
1544 $maxWidth[$colName] = 0;
1545 }
1546
1547 // find the maximum cell widths based on the data
1548 foreach ($data as $row)
1549 {
1550 foreach ($cols as $colName => $colHeading)
1551 {
1552 $w = $this->ezPrvtGetTextWidth($options['fontSize'], (string)$row[$colName]) * 1.01;
1553
1554 if ($w > $maxWidth[$colName])
1555 {
1556 $maxWidth[$colName] = $w;
1557 }
1558 }
1559 }
1560
1561 // and the maximum widths to fit in the headings
1562 foreach ($cols as $colName => $colTitle)
1563 {
1564 $w = $this->ezPrvtGetTextWidth($options['fontSize'], (string)$colTitle) * 1.01;
1565
1566 if ($w > $maxWidth[$colName])
1567 {
1568 $maxWidth[$colName] = $w;
1569 }
1570 }
1571
1572 // calculate the start positions of each of the columns
1573 $pos = array(
1574 );
1575
1576 $x = 0;
1577 $t = $x;
1578 $adjustmentWidth = 0;
1579 $setWidth = 0;
1580
1581 foreach ($maxWidth as $colName => $w)
1582 {
1583 $pos[$colName] = $t;
1584
1585 // if the column width has been specified then set that here, also total the
1586 // width avaliable for adjustment
1587 if (isset($options['cols'][$colName]) && isset($options['cols'][$colName]['width'])
1588 && $options['cols'][$colName]['width'] > 0)
1589 {
1590 $t = $t + $options['cols'][$colName]['width'];
1591 $maxWidth[$colName] = $options['cols'][$colName]['width'] - $options['gap'];
1592 $setWidth += $options['cols'][$colName]['width'];
1593 }
1594 else
1595 {
1596 $t = $t + $w + $options['gap'];
1597 $adjustmentWidth += $w;
1598 $setWidth += $options['gap'];
1599 }
1600 }
1601
1602 $pos['_end_'] = $t;
1603
1604 // if maxWidth is specified, and the table is too wide, and the width has not been set,
1605 // then set the width.
1606 if ($options['width'] == 0 && $options['maxWidth'] && ($t - $x) > $options['maxWidth'])
1607 {
1608 // then need to make this one smaller
1609 $options['width'] = $options['maxWidth'];
1610 }
1611
1612 if ($options['width'] && $adjustmentWidth > 0 && $setWidth < $options['width'])
1613 {
1614 // first find the current widths of the columns involved in this mystery
1615 $cols0 = array(
1616 );
1617
1618 $cols1 = array(
1619 );
1620
1621 $xq = 0;
1622 $presentWidth = 0;
1623 $last = '';
1624
1625 foreach ($pos as $colName => $p)
1626 {
1627 if (!isset($options['cols'][$last]) || !isset($options['cols'][$last]['width'])
1628 || $options['cols'][$last]['width'] <= 0)
1629 {
1630 if (strlen($last))
1631 {
1632 $cols0[$last] = $p - $xq - $options['gap'];
1633 $presentWidth += ($p - $xq - $options['gap']);
1634 }
1635 }
1636 else
1637 {
1638 $cols1[$last] = $p - $xq;
1639 }
1640
1641 $last = $colName;
1642 $xq = $p;
1643 }
1644
1645 // $cols0 contains the widths of all the columns which are not set
1646 $neededWidth = $options['width'] - $setWidth;
1647
1648 // if needed width is negative then add it equally to each column, else get more tricky
1649 if ($presentWidth < $neededWidth)
1650 {
1651 foreach ($cols0 as $colName => $w)
1652 {
1653 $cols0[$colName] += ($neededWidth - $presentWidth) / count($cols0);
1654 }
1655 }
1656 else
1657 {
1658 $cnt = 0;
1659
1660 while ($presentWidth > $neededWidth && $cnt < 100)
1661 {
1662 $cnt++; // insurance policy
1663 // find the widest columns, and the next to widest width
1664 $aWidest = array(
1665 );
1666
1667 $nWidest = 0;
1668 $widest = 0;
1669
1670 foreach ($cols0 as $colName => $w)
1671 {
1672 if ($w > $widest)
1673 {
1674 $aWidest = array($colName);
1675 $nWidest = $widest;
1676 $widest = $w;
1677 }
1678 else if ($w == $widest)
1679 {
1680 $aWidest[] = $colName;
1681 }
1682 }
1683
1684 // then figure out what the width of the widest columns would have to be to take up all the slack
1685 $newWidestWidth = $widest - ($presentWidth - $neededWidth) / count($aWidest);
1686
1687 if ($newWidestWidth > $nWidest)
1688 {
1689 // then there is space to set them to this
1690 foreach ($aWidest as $colName)
1691 {
1692 $cols0[$colName] = $newWidestWidth;
1693 }
1694
1695 $presentWidth = $neededWidth;
1696 }
1697 else
1698 {
1699 // there is not space, reduce the size of the widest ones down to the next size down, and we
1700 // will go round again
1701 foreach ($aWidest as $colName)
1702 {
1703 $cols0[$colName] = $nWidest;
1704 }
1705
1706 $presentWidth = $presentWidth - ($widest - $nWidest) * count($aWidest);
1707 }
1708 }
1709 }
1710
1711 // $cols0 now contains the new widths of the constrained columns.
1712 // now need to update the $pos and $maxWidth arrays
1713 $xq = 0;
1714
1715 foreach ($pos as $colName => $p)
1716 {
1717 $pos[$colName] = $xq;
1718
1719 if (!isset($options['cols'][$colName]) || !isset($options['cols'][$colName]['width'])
1720 || $options['cols'][$colName]['width'] <= 0)
1721 {
1722 if (isset($cols0[$colName]))
1723 {
1724 $xq += $cols0[$colName] + $options['gap'];
1725 $maxWidth[$colName] = $cols0[$colName];
1726 }
1727 }
1728 else
1729 {
1730 if (isset($cols1[$colName]))
1731 {
1732 $xq += $cols1[$colName];
1733 }
1734 }
1735 }
1736
1737 $t = $x + $options['width'];
1738 $pos['_end_'] = $t;
1739 }
1740
1741 // now adjust the table to the correct location across the page
1742 switch ($options['xPos'])
1743 {
1744 case 'left':
1745 $xref = $this->ez['leftMargin'];
1746
1747 break;
1748
1749 case 'right':
1750 $xref = $this->ez['pageWidth'] - $this->ez['rightMargin'];
1751
1752 break;
1753
1754 case 'centre':
1755 case 'center':
1756 $xref = $middle;
1757
1758 break;
1759
1760 default:
1761 $xref = $options['xPos'];
1762
1763 break;
1764 }
1765
1766 switch ($options['xOrientation'])
1767 {
1768 case 'left':
1769 $dx = $xref - $t;
1770
1771 break;
1772
1773 case 'right':
1774 $dx = $xref;
1775
1776 break;
1777
1778 case 'centre':
1779 case 'center':
1780 $dx = $xref - $t / 2;
1781
1782 break;
1783 }
1784
1785 foreach ($pos as $k => $v)
1786 {
1787 $pos[$k] = $v + $dx;
1788 }
1789
1790 $x0 = $x + $dx;
1791 $x1 = $t + $dx;
1792
1793 $baseLeftMargin = $this->ez['leftMargin'];
1794 $basePos = $pos;
1795 $baseX0 = $x0;
1796 $baseX1 = $x1;
1797
1798 // ok, just about ready to make me a table
1799 $this->setColor($options['textCol'][0], $options['textCol'][1], $options['textCol'][2]);
1800 $this->setStrokeColor($options['shadeCol'][0], $options['shadeCol'][1], $options['shadeCol'][2]);
1801
1802 $middle = ($x1 + $x0) / 2;
1803
1804 // start a transaction which will be used to regress the table, if there are not enough rows protected
1805 if ($options['protectRows'] > 0)
1806 {
1807 $this->transaction('start');
1808 $movedOnce = 0;
1809 }
1810
1811 $abortTable = 1;
1812
1813 while ($abortTable)
1814 {
1815 $abortTable = 0;
1816
1817 $dm = $this->ez['leftMargin'] - $baseLeftMargin;
1818
1819 foreach ($basePos as $k => $v)
1820 {
1821 $pos[$k] = $v + $dm;
1822 }
1823
1824 $x0 = $baseX0 + $dm;
1825 $x1 = $baseX1 + $dm;
1826 $middle = ($x1 + $x0) / 2;
1827
1828 // if the title is set, then do that
1829 if (strlen($title))
1830 {
1831 $w = $this->getTextWidth($options['titleFontSize'], $title);
1832 $this->y -= $this->getFontHeight($options['titleFontSize']);
1833
1834 if ($this->y < $this->ez['bottomMargin'])
1835 {
1836 $this->ezNewPage();
1837 // margins may have changed on the newpage
1838 $dm = $this->ez['leftMargin'] - $baseLeftMargin;
1839
1840 foreach ($basePos as $k => $v)
1841 {
1842 $pos[$k] = $v + $dm;
1843 }
1844
1845 $x0 = $baseX0 + $dm;
1846 $x1 = $baseX1 + $dm;
1847 $middle = ($x1 + $x0) / 2;
1848 $this->y -= $this->getFontHeight($options['titleFontSize']);
1849 }
1850
1851 $this->addText($middle - $w / 2, $this->y, $options['titleFontSize'], $title);
1852 $this->y -= $options['titleGap'];
1853 }
1854
1855 // margins may have changed on the newpage
1856 $dm = $this->ez['leftMargin'] - $baseLeftMargin;
1857
1858 foreach ($basePos as $k => $v)
1859 {
1860 $pos[$k] = $v + $dm;
1861 }
1862
1863 $x0 = $baseX0 + $dm;
1864 $x1 = $baseX1 + $dm;
1865
1866 $y = $this->y; // to simplify the code a bit
1867
1868 // make the table
1869 $height = $this->getFontHeight($options['fontSize']);
1870 $decender = $this->getFontDecender($options['fontSize']);
1871
1872 $y0 = $y + $decender;
1873 $dy = 0;
1874
1875 if ($options['showHeadings'])
1876 {
1877 if ($options['shaded'])
1878 {
1879 $this->saveState();
1880 $textObjectId = $this->openObject();
1881 }
1882
1883 // this function will move the start of the table to a new page if it does not fit on this one
1884 $headingHeight = $this->ezPrvtTableColumnHeadings(
1885 $cols, $pos, $maxWidth, $height, $decender, $options['rowGap'],
1886 $options['fontSize'], $y, $options);
1887 $y0 = $y + $headingHeight;
1888 $y1 = $y;
1889
1890 $dm = $this->ez['leftMargin'] - $baseLeftMargin;
1891
1892 foreach ($basePos as $k => $v)
1893 {
1894 $pos[$k] = $v + $dm;
1895 }
1896
1897 $x0 = $baseX0 + $dm;
1898 $x1 = $baseX1 + $dm;
1899
1900 if ($options['shaded'])
1901 {
1902 $this->closeObject();
1903 $this->setColor($options['shadeCol'][0], $options['shadeCol'][1], $options['shadeCol'][2], 1);
1904 $this->filledRectangle($x0 - $options['gap'] / 2, $y1, $x1 - $x0, $headingHeight);
1905 $this->addObject($textObjectId);
1906 $this->closeObject();
1907 $this->restoreState();
1908 }
1909 }
1910 else
1911 {
1912 $y1 = $y0;
1913 }
1914
1915 $firstLine = 1;
1916
1917 // open an object here so that the text can be put in over the shading
1918 if ($options['shaded'])
1919 {
1920 $this->saveState();
1921 $textObjectId = $this->openObject();
1922 $this->closeObject();
1923
1924 // $this->setColor($options['shadeCol'][0],$options['shadeCol'][1],$options['shadeCol'][2],1);
1925 // $this->filledRectangle($x0-$options['gap']/2,$y1,$x1-$x0,$headingHeight);
1926
1927 // $this->setColor($options['shadeCol'][0],$options['shadeCol'][1],$options['shadeCol'][2],1);
1928 // $this->filledRectangle($x0-$options['gap']/2,$y0,$x1-$x0,$y0+$dm);
1929 // $this->filledRectangle($x0-$options['gap']/2,$y+$decender+$height-$mx,$x1-$x0,$mx);
1930 // $this->filledRectangle($x0-$options['gap']/2,$y0-12,$x1-$x0,$y0);
1931
1932 $this->addObject($textObjectId);
1933
1934 // $this->setColor($options['shadeCol'][0],$options['shadeCol'][1],$options['shadeCol'][2],1);
1935 // $this->filledRectangle($x0-$options['gap']/2,$y1,$x1-$x0,$headingHeight);
1936
1937 $this->reopenObject($textObjectId);
1938 }
1939
1940 $cnt = 0;
1941 $newPage = 0;
1942
1943 foreach ($data as $row)
1944 {
1945 $cnt++;
1946
1947 // the transaction support will be used to prevent rows being split
1948 if ($options['splitRows'] == 0)
1949 {
1950 $pageStart = $this->ezPageCount;
1951
1952 if (isset($this->ez['columns']) && $this->ez['columns']['on'] == 1)
1953 {
1954 $columnStart = $this->ez['columns']['colNum'];
1955 }
1956
1957 $this->transaction('start');
1958 $row_orig = $row;
1959 $y_orig = $y;
1960 $y0_orig = $y0;
1961 $y1_orig = $y1;
1962 }
1963
1964 $ok = 0;
1965 $secondTurn = 0;
1966
1967 while (!$abortTable && $ok == 0)
1968 {
1969 $mx = 0;
1970 $newRow = 1;
1971
1972 while (!$abortTable && ($newPage || $newRow))
1973 {
1974 $y -= $height;
1975
1976 if ($newPage || $y < $this->ez['bottomMargin'] || (isset($options['minRowSpace']) && $y
1977 < ($this->ez['bottomMargin']
1978 + $options['minRowSpace'])))
1979 {
1980 // check that enough rows are with the heading
1981 if ($options['protectRows'] > 0 && $movedOnce == 0 && $cnt <= $options['protectRows'])
1982 {
1983 // then we need to move the whole table onto the next page
1984 $movedOnce = 1;
1985 $abortTable = 1;
1986 }
1987
1988 $y2 = $y - $mx + 2 * $height + $decender - $newRow * $height;
1989
1990 if ($options['showLines'])
1991 {
1992 if (!$options['showHeadings'])
1993 {
1994 $y0 = $y1;
1995 }
1996
1997 $this->ezPrvtTableDrawLines($pos,
1998 $options['gap'],
1999 $x0,
2000 $x1,
2001 $y0,
2002 $y1,
2003 $y2,
2004 $options['lineCol'],
2005 $options['innerLineThickness'],
2006 $options['outerLineThickness'],
2007 $options['showLines']);
2008 }
2009
2010 if ($options['shaded'])
2011 {
2012 $this->closeObject();
2013 $this->restoreState();
2014 }
2015
2016 $this->ezNewPage();
2017 // and the margins may have changed, this is due to the possibility of the columns being turned on
2018 // as the columns are managed by manipulating the margins
2019
2020 $dm = $this->ez['leftMargin'] - $baseLeftMargin;
2021
2022 foreach ($basePos as $k => $v)
2023 {
2024 $pos[$k] = $v + $dm;
2025 }
2026
2027 // $x0=$x0+$dm;
2028 // $x1=$x1+$dm;
2029 $x0 = $baseX0 + $dm;
2030 $x1 = $baseX1 + $dm;
2031
2032 if ($options['shaded'])
2033 {
2034 $this->saveState();
2035 $textObjectId = $this->openObject();
2036 $this->closeObject();
2037 $this->addObject($textObjectId);
2038 $this->reopenObject($textObjectId);
2039 }
2040
2041 $this->setColor($options['textCol'][0], $options['textCol'][1], $options['textCol'][2], 1);
2042 $y = $this->ez['pageHeight'] - $this->ez['topMargin'];
2043 $y0 = $y + $decender;
2044 $mx = 0;
2045
2046 if ($options['showHeadings'])
2047 {
2048 $this->ezPrvtTableColumnHeadings(
2049 $cols, $pos, $maxWidth, $height, $decender, $options['rowGap'],
2050 $options['fontSize'], $y, $options);
2051 $y1 = $y;
2052 }
2053 else
2054 {
2055 $y1 = $y0;
2056 }
2057
2058 $firstLine = 1;
2059 $y -= $height;
2060 }
2061
2062 $newRow = 0;
2063 // write the actual data
2064 // if these cells need to be split over a page, then $newPage will be set, and the remaining
2065 // text will be placed in $leftOvers
2066 $newPage = 0;
2067 $leftOvers = array(
2068 );
2069
2070 foreach ($cols as $colName => $colTitle)
2071 {
2072 $this->ezSetY($y + $height);
2073 $colNewPage = 0;
2074
2075 if (isset($row[$colName]))
2076 {
2077 if (isset($options['cols'][$colName]) && isset($options['cols'][$colName]['link'])
2078 && strlen($options['cols'][$colName]['link']))
2079 {
2080 $lines = explode("\n", $row[$colName]);
2081
2082 if (isset($row[$options['cols'][$colName]['link']])
2083 && strlen($row[$options['cols'][$colName]['link']]))
2084 {
2085 foreach ($lines as $k => $v)
2086 {
2087 $lines[$k]
2088 = '<c:alink:' . $row[$options['cols'][$colName]['link']] . '>' . $v
2089 . '</c:alink>';
2090 }
2091 }
2092 }
2093 else
2094 {
2095 $lines = explode("\n", $row[$colName]);
2096 }
2097 }
2098 else
2099 {
2100 $lines = array(
2101 );
2102 }
2103
2104 $this->y -= $options['rowGap'];
2105
2106 foreach ($lines as $line)
2107 {
2108 $line = $this->ezProcessText($line);
2109 $start = 1;
2110
2111 while (strlen($line) || $start)
2112 {
2113 $start = 0;
2114
2115 if (!$colNewPage)
2116 {
2117 $this->y = $this->y - $height;
2118 }
2119
2120 if ($this->y < $this->ez['bottomMargin'])
2121 {
2122 // $this->ezNewPage();
2123 $newPage = 1; // whether a new page is required for any of the columns
2124 $colNewPage = 1; // whether a new page is required for this column
2125 }
2126
2127 if ($colNewPage)
2128 {
2129 if (isset($leftOvers[$colName]))
2130 {
2131 $leftOvers[$colName] .= "\n" . $line;
2132 }
2133 else
2134 {
2135 $leftOvers[$colName] = $line;
2136 }
2137
2138 $line = '';
2139 }
2140 else
2141 {
2142 if (isset($options['cols'][$colName]) && isset(
2143 $options['cols'][$colName]['justification']))
2144 {
2145 $just = $options['cols'][$colName]['justification'];
2146 }
2147 else
2148 {
2149 $just = 'left';
2150 }
2151
2152 $line = $this->addTextWrap(
2153 $pos[$colName], $this->y, $maxWidth[$colName], $options['fontSize'],
2154 $line, $just);
2155 }
2156 }
2157 }
2158
2159 $dy = $y + $height - $this->y + $options['rowGap'];
2160
2161 if ($dy - $height * $newPage > $mx)
2162 {
2163 $mx = $dy - $height * $newPage;
2164 }
2165 }
2166
2167 // set $row to $leftOvers so that they will be processed onto the new page
2168 $row = $leftOvers;
2169
2170 // now add the shading underneath
2171 if ($options['shaded'] && $cnt % 2 == 0)
2172 {
2173 $this->closeObject();
2174 $this->setColor($options['shadeCol'][0], $options['shadeCol'][1], $options['shadeCol'][2],
2175 1);
2176 $this->filledRectangle($x0 - $options['gap'] / 2, $y + $decender + $height - $mx, $x1 - $x0,
2177 $mx);
2178 $this->reopenObject($textObjectId);
2179 }
2180
2181 if ($options['shaded'] == 2 && $cnt % 2 == 1)
2182 {
2183 $this->closeObject();
2184 $this->setColor($options['shadeCol2'][0], $options['shadeCol2'][1],
2185 $options['shadeCol2'][2], 1);
2186 $this->filledRectangle($x0 - $options['gap'] / 2, $y + $decender + $height - $mx, $x1 - $x0,
2187 $mx);
2188 $this->reopenObject($textObjectId);
2189 }
2190
2191 if ($options['showLines'] > 1)
2192 {
2193 // then draw a line on the top of each block
2194 // $this->closeObject();
2195 $this->saveState();
2196 $this->setStrokeColor($options['lineCol'][0], $options['lineCol'][1],
2197 $options['lineCol'][2], 1);
2198
2199 // $this->line($x0-$options['gap']/2,$y+$decender+$height-$mx,$x1-$x0,$mx);
2200 if ($firstLine)
2201 {
2202 $this->setLineStyle($options['outerLineThickness']);
2203 $firstLine = 0;
2204 }
2205 else
2206 {
2207 $this->setLineStyle($options['innerLineThickness']);
2208 }
2209
2210 $this->line($x0 - $options['gap'] / 2, $y + $decender + $height, $x1 - $options['gap'] / 2,
2211 $y + $decender + $height);
2212 $this->restoreState();
2213 // $this->reopenObject($textObjectId);
2214 }
2215 } // end of while
2216
2217 $y = $y - $mx + $height;
2218
2219 // checking row split over pages
2220 if ($options['splitRows'] == 0)
2221 {
2222 if ((($this->ezPageCount != $pageStart) || (isset($this->ez['columns'])
2223 && $this->ez['columns']['on'] == 1
2224 && $columnStart
2225 != $this->ez['columns']['colNum']))
2226 && $secondTurn == 0)
2227 {
2228 // then we need to go back and try that again !
2229 $newPage = 1;
2230 $secondTurn = 1;
2231 $this->transaction('rewind');
2232 $row = $row_orig;
2233 $y = $y_orig;
2234 $y0 = $y0_orig;
2235 $y1 = $y1_orig;
2236 $ok = 0;
2237
2238 $dm = $this->ez['leftMargin'] - $baseLeftMargin;
2239
2240 foreach ($basePos as $k => $v)
2241 {
2242 $pos[$k] = $v + $dm;
2243 }
2244
2245 $x0 = $baseX0 + $dm;
2246 $x1 = $baseX1 + $dm;
2247 }
2248 else
2249 {
2250 $this->transaction('commit');
2251 $ok = 1;
2252 }
2253 }
2254 else
2255 {
2256 $ok = 1; // don't go round the loop if splitting rows is allowed
2257 }
2258 } // end of while to check for row splitting
2259
2260 if ($abortTable)
2261 {
2262 if ($ok == 0)
2263 {
2264 $this->transaction('abort');
2265 }
2266
2267 // only the outer transaction should be operational
2268 $this->transaction('rewind');
2269 $this->ezNewPage();
2270 break;
2271 }
2272 } // end of foreach ($data as $row)
2273 } // end of while ($abortTable)
2274
2275 // table has been put on the page, the rows guarded as required, commit.
2276 $this->transaction('commit');
2277
2278 $y2 = $y + $decender;
2279
2280 if ($options['showLines'])
2281 {
2282 if (!$options['showHeadings'])
2283 {
2284 $y0 = $y1;
2285 }
2286
2287 $this->ezPrvtTableDrawLines($pos, $options['gap'],
2288 $x0, $x1,
2289 $y0, $y1,
2290 $y2, $options['lineCol'],
2291 $options['innerLineThickness'], $options['outerLineThickness'],
2292 $options['showLines']);
2293 }
2294
2295 // close the object for drawing the text on top
2296 if ($options['shaded'])
2297 {
2298 $this->closeObject();
2299 $this->restoreState();
2300 }
2301
2302 $this->y = $y;
2303 return $y;
2304 }
2305
2306 // ------------------------------------------------------------------------------
2307 function ezProcessText($text)
2308 {
2309 // this function will intially be used to implement underlining support, but could be used for a range of other
2310 // purposes
2311 $search = array
2312 (
2313 '<u>',
2314 '<U>',
2315 '</u>',
2316 '</U>'
2317 );
2318
2319 $replace = array
2320 (
2321 '<c:uline>',
2322 '<c:uline>',
2323 '</c:uline>',
2324 '</c:uline>'
2325 );
2326
2327 return str_replace($search, $replace, $text);
2328 }
2329
2330 // ------------------------------------------------------------------------------
2331
2332 function ezText($text, $size = 0, $options = array(
2333 ), $test = 0)
2334 {
2335 // this will add a string of text to the document, starting at the current drawing
2336 // position.
2337 // it will wrap to keep within the margins, including optional offsets from the left
2338 // and the right, if $size is not specified, then it will be the last one used, or
2339 // the default value (12 I think).
2340 // the text will go to the start of the next line when a return code "\n" is found.
2341 // possible options are:
2342 // 'left'=> number, gap to leave from the left margin
2343 // 'right'=> number, gap to leave from the right margin
2344 // 'aleft'=> number, absolute left position (overrides 'left')
2345 // 'aright'=> number, absolute right position (overrides 'right')
2346 // 'justification' => 'left','right','center','centre','full'
2347
2348 // only set one of the next two items (leading overrides spacing)
2349 // 'leading' => number, defines the total height taken by the line, independent of the font height.
2350 // 'spacing' => a real number, though usually set to one of 1, 1.5, 2 (line spacing as used in word processing)
2351
2352 // if $test is set then this should just check if the text is going to flow onto a new page or not, returning true or false
2353
2354 // apply the filtering which will make the underlining function.
2355 $text = $this->ezProcessText($text);
2356
2357 $newPage = false;
2358 $store_y = $this->y;
2359
2360 if (is_array($options) && isset($options['aleft']))
2361 {
2362 $left = $options['aleft'];
2363 }
2364 else
2365 {
2366 $left = $this->ez['leftMargin'] + ((is_array($options) && isset($options['left'])) ? $options['left'] : 0);
2367 }
2368
2369 if (is_array($options) && isset($options['aright']))
2370 {
2371 $right = $options['aright'];
2372 }
2373 else
2374 {
2375 $right = $this->ez['pageWidth'] - $this->ez['rightMargin'] - ((is_array(
2376 $options) && isset($options['right']))
2377 ? $options['right'] : 0);
2378 }
2379
2380 if ($size <= 0)
2381 {
2382 $size = $this->ez['fontSize'];
2383 }
2384 else
2385 {
2386 $this->ez['fontSize'] = $size;
2387 }
2388
2389 if (is_array($options) && isset($options['justification']))
2390 {
2391 $just = $options['justification'];
2392 }
2393 else
2394 {
2395 $just = 'left';
2396 }
2397
2398 // modifications to give leading and spacing based on those given by Craig Heydenburg 1/1/02
2399 if (is_array($options) && isset($options['leading']))
2400 { ## use leading instead of spacing
2401 $height = $options['leading'];
2402 }
2403 else if (is_array($options) && isset($options['spacing']))
2404 {
2405 $height = $this->getFontHeight($size) * $options['spacing'];
2406 }
2407 else
2408 {
2409 $height = $this->getFontHeight($size);
2410 }
2411
2412 $lines = explode("\n", $text);
2413
2414 foreach ($lines as $line)
2415 {
2416 $start = 1;
2417
2418 while (strlen($line) || $start)
2419 {
2420 $start = 0;
2421 $this->y = $this->y - $height;
2422
2423 if ($this->y < $this->ez['bottomMargin'])
2424 {
2425 if ($test)
2426 {
2427 $newPage = true;
2428 }
2429 else
2430 {
2431 $this->ezNewPage();
2432 // and then re-calc the left and right, in case they have changed due to columns
2433 }
2434 }
2435
2436 if (is_array($options) && isset($options['aleft']))
2437 {
2438 $left = $options['aleft'];
2439 }
2440 else
2441 {
2442 $left = $this->ez['leftMargin'] + ((is_array(
2443 $options) && isset(
2444 $options['left'])) ? $options['left'] : 0);
2445 }
2446
2447 if (is_array($options) && isset($options['aright']))
2448 {
2449 $right = $options['aright'];
2450 }
2451 else
2452 {
2453 $right = $this->ez['pageWidth'] - $this->ez['rightMargin'] - ((is_array($options)
2454 && isset($options['right']))
2455 ? $options['right'] : 0);
2456 }
2457
2458 $line = $this->addTextWrap($left, $this->y, $right - $left, $size, $line, $just, 0, $test);
2459 }
2460 }
2461
2462 if ($test)
2463 {
2464 $this->y = $store_y;
2465 return $newPage;
2466 }
2467 else
2468 {
2469 return $this->y;
2470 }
2471 }
2472
2473 // ------------------------------------------------------------------------------
2474
2475 function ezImage($image, $pad = 5, $width = 0, $resize = 'full', $just = 'center', $border = '')
2476 {
2477 //beta ezimage function
2478 if (stristr($image, '://')) //copy to temp file
2479 {
2480 $fp = @fopen($image, "rb");
2481
2482 while (!feof($fp))
2483 {
2484 $cont .= fread($fp, 1024);
2485 }
2486
2487 fclose ($fp);
2488 $image = tempnam("/tmp", "php-pdf");
2489 $fp2 = @fopen($image, "w");
2490 fwrite($fp2, $cont);
2491 fclose ($fp2);
2492 $temp = true;
2493 }
2494
2495 if (!(file_exists($image)))
2496 return false; //return immediately if image file does not exist
2497
2498 $imageInfo = getimagesize($image);
2499
2500 switch ($imageInfo[2])
2501 {
2502 case 2:
2503 $type = "jpeg";
2504
2505 break;
2506
2507 case 3:
2508 $type = "png";
2509
2510 break;
2511
2512 default: return false; //return if file is not jpg or png
2513 }
2514
2515 if ($width == 0)
2516 $width = $imageInfo[0]; //set width
2517
2518 $ratio = $imageInfo[0] / $imageInfo[1];
2519
2520 //get maximum width of image
2521 if (isset($this->ez['columns']) && $this->ez['columns']['on'] == 1)
2522 {
2523 $bigwidth = $this->ez['columns']['width'] - ($pad * 2);
2524 }
2525 else
2526 {
2527 $bigwidth = $this->ez['pageWidth'] - ($pad * 2);
2528 }
2529
2530 //fix width if larger than maximum or if $resize=full
2531 if ($resize == 'full' || $resize == 'width' || $width > $bigwidth)
2532 {
2533 $width = $bigwidth;
2534 }
2535
2536 $height = ($width / $ratio); //set height
2537
2538 //fix size if runs off page
2539 if ($height > ($this->y - $this->ez['bottomMargin'] - ($pad * 2)))
2540 {
2541 if ($resize != 'full')
2542 {
2543 $this->ezNewPage();
2544 }
2545 else
2546 {
2547 $height = ($this->y - $this->ez['bottomMargin'] - ($pad * 2)); //shrink height
2548 $width = ($height * $ratio); //fix width
2549 }
2550 }
2551
2552 //fix x-offset if image smaller than bigwidth
2553 if ($width < $bigwidth)
2554 {
2555 //center if justification=center
2556 if ($just == 'center')
2557 {
2558 $offset = ($bigwidth - $width) / 2;
2559 }
2560
2561 //move to right if justification=right
2562 if ($just == 'right')
2563 {
2564 $offset = ($bigwidth - $width);
2565 }
2566
2567 //leave at left if justification=left
2568 if ($just == 'left')
2569 {
2570 $offset = 0;
2571 }
2572 }
2573
2574 //call appropriate function
2575 if ($type == "jpeg")
2576 {
2577 $this->addJpegFromFile($image,
2578 $this->ez['leftMargin'] + $pad + $offset,
2579 $this->y + $this->getFontHeight($this->ez['fontSize']) - $pad - $height,
2580 $width);
2581 }
2582
2583 if ($type == "png")
2584 {
2585 $this->addPngFromFile($image,
2586 $this->ez['leftMargin'] + $pad + $offset,
2587 $this->y + $this->getFontHeight($this->ez['fontSize']) - $pad - $height,
2588 $width);
2589 }
2590
2591 //draw border
2592 if ($border != '')
2593 {
2594 if (!(isset($border['color'])))
2595 {
2596 $border['color']['red'] = .5;
2597 $border['color']['blue'] = .5;
2598 $border['color']['green'] = .5;
2599 }
2600
2601 if (!(isset($border['width'])))
2602 $border['width'] = 1;
2603
2604 if (!(isset($border['cap'])))
2605 $border['cap'] = 'round';
2606
2607 if (!(isset($border['join'])))
2608 $border['join'] = 'round';
2609
2610 $this->setStrokeColor($border['color']['red'], $border['color']['green'], $border['color']['blue']);
2611 $this->setLineStyle($border['width'], $border['cap'], $border['join']);
2612 $this->rectangle($this->ez['leftMargin'] + $pad + $offset,
2613 $this->y + $this->getFontHeight($this->ez['fontSize']) - $pad - $height,
2614 $width,
2615 $height);
2616 }
2617
2618 // move y below image
2619 $this->y = $this->y - $pad - $height;
2620
2621 //remove tempfile for remote images
2622 if ($temp == true)
2623 unlink ($image);
2624 }
2625
2626 // ------------------------------------------------------------------------------
2627
2628 // note that templating code is still considered developmental - have not really figured
2629 // out a good way of doing this yet.
2630 function loadTemplate($templateFile)
2631 {
2632 // this function will load the requested template ($file includes full or relative pathname)
2633 // the code for the template will be modified to make it name safe, and then stored in
2634 // an array for later use
2635 // The id of the template will be returned for the user to operate on it later
2636 if (!file_exists($templateFile))
2637 {
2638 return -1;
2639 }
2640
2641 $code = implode('', file($templateFile));
2642
2643 if (!strlen($code))
2644 {
2645 return;
2646 }
2647
2648 $code = trim($code);
2649
2650 if (substr($code, 0, 5) == '<?php')
2651 {
2652 $code = substr($code, 5);
2653 }
2654
2655 if (substr($code, -2) == '?>')
2656 {
2657 $code = substr($code, 0, strlen($code) - 2);
2658 }
2659
2660 if (isset($this->ez['numTemplates']))
2661 {
2662 $newNum = $this->ez['numTemplates'];
2663 $this->ez['numTemplates']++;
2664 }
2665 else
2666 {
2667 $newNum = 0;
2668 $this->ez['numTemplates'] = 1;
2669 $this->ez['templates'] = array(
2670 );
2671 }
2672
2673 $this->ez['templates'][$newNum]['code'] = $code;
2674
2675 return $newNum;
2676 }
2677
2678 // ------------------------------------------------------------------------------
2679
2680 function execTemplate($id, $data = array(
2681 ), $options = array(
2682 ))
2683 {
2684 // execute the given template on the current document.
2685 if (!isset($this->ez['templates'][$id]))
2686 {
2687 return;
2688 }
2689
2690 eval ($this->ez['templates'][$id]['code']);
2691 }
2692
2693 // ------------------------------------------------------------------------------
2694 function ilink($info)
2695 {
2696 $this->alink($info, 1);
2697 }
2698
2699 function alink($info, $internal = 0)
2700 {
2701 // a callback function to support the formation of clickable links within the document
2702 $lineFactor = 0.05; // the thickness of the line as a proportion of the height. also the drop of the line.
2703
2704 switch ($info['status'])
2705 {
2706 case 'start':
2707 case 'sol':
2708 // the beginning of the link
2709 // this should contain the URl for the link as the 'p' entry, and will also contain the value of 'nCallback'
2710 if (!isset($this->ez['links']))
2711 {
2712 $this->ez['links'] = array(
2713 );
2714 }
2715
2716 $i = $info['nCallback'];
2717 $this->ez['links'][$i] = array
2718 (
2719 'x' => $info['x'],
2720 'y' => $info['y'],
2721 'angle' => $info['angle'],
2722 'decender' => $info['decender'],
2723 'height' => $info['height'],
2724 'url' => $info['p']
2725 );
2726
2727 if ($internal == 0)
2728 {
2729 $this->saveState();
2730 $this->setColor(0, 0, 1);
2731 $this->setStrokeColor(0, 0, 1);
2732 $thick = $info['height'] * $lineFactor;
2733 $this->setLineStyle($thick);
2734 }
2735
2736 break;
2737
2738 case 'end':
2739 case 'eol':
2740 // the end of the link
2741 // assume that it is the most recent opening which has closed
2742 $i = $info['nCallback'];
2743
2744 $start = $this->ez['links'][$i];
2745
2746 // add underlining
2747 if ($internal)
2748 {
2749 $this->addInternalLink($start['url'], $start['x'], $start['y'] + $start['decender'], $info['x'],
2750 $start['y'] + $start['decender'] + $start['height']);
2751 }
2752 else
2753 {
2754 $a = deg2rad((float)$start['angle'] - 90.0);
2755 $drop = $start['height'] * $lineFactor * 1.5;
2756 $dropx = cos($a) * $drop;
2757 $dropy = -sin($a) * $drop;
2758 $this->line($start['x'] - $dropx, $start['y'] - $dropy, $info['x'] - $dropx, $info['y'] - $dropy);
2759 $this->addLink($start['url'], $start['x'], $start['y'] + $start['decender'], $info['x'],
2760 $start['y'] + $start['decender'] + $start['height']);
2761 $this->restoreState();
2762 }
2763
2764 break;
2765 }
2766 }
2767
2768 // ------------------------------------------------------------------------------
2769
2770 function uline($info)
2771 {
2772 // a callback function to support underlining
2773 $lineFactor = 0.05; // the thickness of the line as a proportion of the height. also the drop of the line.
2774
2775 switch ($info['status'])
2776 {
2777 case 'start':
2778 case 'sol':
2779
2780 // the beginning of the underline zone
2781 if (!isset($this->ez['links']))
2782 {
2783 $this->ez['links'] = array(
2784 );
2785 }
2786
2787 $i = $info['nCallback'];
2788 $this->ez['links'][$i] = array
2789 (
2790 'x' => $info['x'],
2791 'y' => $info['y'],
2792 'angle' => $info['angle'],
2793 'decender' => $info['decender'],
2794 'height' => $info['height']
2795 );
2796
2797 $this->saveState();
2798 $thick = $info['height'] * $lineFactor;
2799 $this->setLineStyle($thick);
2800 break;
2801
2802 case 'end':
2803 case 'eol':
2804 // the end of the link
2805 // assume that it is the most recent opening which has closed
2806 $i = $info['nCallback'];
2807
2808 $start = $this->ez['links'][$i];
2809 // add underlining
2810 $a = deg2rad((float)$start['angle'] - 90.0);
2811 $drop = $start['height'] * $lineFactor * 1.5;
2812 $dropx = cos($a) * $drop;
2813 $dropy = -sin($a) * $drop;
2814 $this->line($start['x'] - $dropx, $start['y'] - $dropy, $info['x'] - $dropx, $info['y'] - $dropy);
2815 $this->restoreState();
2816 break;
2817 }
2818 }
2819
2820// ------------------------------------------------------------------------------
2821
2822}
2823?>
$title
Definição base.php:3
$id
Definição base.php:5