aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc/3rdparty/libraries/mpdf/examples/example44_MPDFI_yearbook.php
diff options
context:
space:
mode:
Diffstat (limited to 'inc/3rdparty/libraries/mpdf/examples/example44_MPDFI_yearbook.php')
-rw-r--r--inc/3rdparty/libraries/mpdf/examples/example44_MPDFI_yearbook.php150
1 files changed, 0 insertions, 150 deletions
diff --git a/inc/3rdparty/libraries/mpdf/examples/example44_MPDFI_yearbook.php b/inc/3rdparty/libraries/mpdf/examples/example44_MPDFI_yearbook.php
deleted file mode 100644
index 2420b9f3..00000000
--- a/inc/3rdparty/libraries/mpdf/examples/example44_MPDFI_yearbook.php
+++ /dev/null
@@ -1,150 +0,0 @@
1<?php
2
3// First write all your entries to a PDF file, forcing each entry to fit on one page
4include("../mpdf.php");
5
6// Define the maximum containing box width & height for each text box as it will appear on the final page (no padding or margin here)
7$pw = 80;
8$ph = 110;
9$minK = 0.7; // Maximum scaling factor 0.7 = 70%
10$inc = 0.01; // Increment to change scaling factor 0.05 = 5%
11$spacing = 10; // millimetres (vertically and horizonatlly between boxes in output) shrinks if boxes too big
12$border = 3; // millimetres round final boxes (-1 for no border)
13$align = 'T'; // T(op) or M(iddle) for content of final output boxes
14
15// Only change the first parameter of the next line e.g. utf-8
16$mpdf = new mPDF('', array(($pw*(1/$minK)),($ph*(1/$minK))), '','', 0,($pw*(1/$minK))-$pw,0,($ph*(1/$minK))-$ph,0,0);
17
18$pph = array();
19
20
21// FOR EACH ENTRY FOR YOUR YEARBOOK saving the page height in $pph (where $html is the HTML code for the entry):
22// $pph[$i] = SinglePage($html, $pw, $ph, $minK);
23
24//==============================================================
25// .. but we will use this for an example
26
27$html1 = '
28<style>
29div { text-align: justify; }
30</style>
31<h2>Joanne Smith 2002-2007</h2><div>This is the normal text in the div: Nulla felis erat, imperdiet eu, ullamcorper non, nonummy quis, elit. Suspendisse potenti. Ut a eros orci. Morbi feugiat pulvinar dolor. Cras odio. Donec mattis, nisi id euismod auctor, neque metus pellentesque, <img src="tiger.wmf" width="100" style="float: right; margin: 4px; " /> risus at eleifend lacus sapien et risus. Phasellus metus. Phasellus feugiat, lectus ac aliquam molestie, leo lacus tincidunt turpis, vel aliquam quam odio et sapien. Mauris ante pede, auctor ac, suscipit quis, malesuada sed,<img src="tiger.jpg" width="100" style="float: left; margin: 4px; " /> nulla. Integer sit amet odio sit amet lectus luctus euismod. Donec et nulla. Sed quis orci. </div>
32';
33
34$html2 = '
35<style>
36div { text-align: justify; }
37</style>
38<h2>Tim Another 2001-2007</h2><div>This is the normal text in the div: Nulla felis erat, imperdiet eu, ullamcorper non, nonummy quis, elit. Suspendisse potenti. Ut a eros at ligula vehicula pretium. Maecenas feugiat pede vel risus. et lectus. Fusce eleifend neque sit amet erat. Integer consectetuer nulla non orci. Morbi feugiat pulvinar dolor. Cras odio. Donec mattis, nisi id euismod auctor, neque metus pellentesque, <img src="tiger.jpg" width="100" style="float: right; margin: 4px; " /> risus at eleifend lacus sapien et risus. Phasellus metus, suscipit quis, malesuada sed, nulla. Integer sit amet odio sit amet lectus luctus euismod. Donec et nulla. Sed quis orci. <br />
39Morbi feugiat pulvinar dolor. Cras odio. Donec mattis, nisi id euismod auctor, neque metus pellentesque risus, at eleifend lacus sapien et risus. Phasellus metus. Phasellus feugiat, lectus ac aliquam molestie, leo lacus tincidunt turpis, vel aliquam quam odio et sapien. Mauris ante pede, auctor ac, suscipit quis, malesuada sed, nulla. Integer sit amet odio sit amet lectus luctus euismod. Donec et nulla. Sed quis orci. </div>
40';
41
42for($i=1; $i<=10; $i++) {
43 // $html = $html;
44 if ($i % 3 == 1) { $html = $html2; }
45 else { $html = $html1; }
46 $pph[$i] = SinglePage($html, $pw, $ph, $minK) ; // $pph saves the actual height of each page
47}
48//==============================================================
49// Save the pages to a file
50$mpdf->Output('test.pdf','F');
51
52// Now collate those pages using IMPORT - 4 pages to one page
53
54$mpdf=new mPDF();
55$mpdf->SetImportUse();
56$mpdf->SetDisplayMode('fullpage');
57
58$mpdf->SetHeader('{DATE j-m-Y}|My Yearbook 2005|{PAGENO}');
59$mpdf->SetFooter('|Printed using mPDF|');
60
61$pagecount = $mpdf->SetSourceFile('test.pdf');
62for($i=1; $i<=$pagecount; $i++) {
63 if ($i % 4 == 1) { $mpdf->AddPage(); }
64 $pgheight = $mpdf->h - $mpdf->tMargin - $mpdf->bMargin;
65 $hspacing = min($spacing,($mpdf->pgwidth - $pw*2) );
66 $vspacing = min($spacing,($pgheight - $ph*2) );
67 $x1 = $mpdf->lMargin + ($mpdf->pgwidth/2 - $hspacing/2 - $pw)/2;
68 $x2 = $mpdf->lMargin + $mpdf->pgwidth/2 + $hspacing/2 + ($mpdf->pgwidth/2 - $hspacing/2 - $pw)/2;
69 $y1 = $mpdf->tMargin + ($pgheight /2 - $vspacing/2 - $ph)/2;
70 $y2 = $mpdf->tMargin + $pgheight /2 + $vspacing/2 + ($pgheight /2 - $vspacing/2 - $ph)/2;
71 if ($i % 4 == 1) { $x = $x1; $y = $y1; }
72 else if ($i % 4 == 2) { $x = $x2; $y = $y1; }
73 else if ($i % 4 == 3) { $x = $x1; $y = $y2; }
74 else if ($i % 4 == 0) { $x = $x2; $y = $y2; }
75 $tplIdx = $mpdf->ImportPage($i, 0,0,$pw,$pph[$i]);
76
77 if ($align=='T') { $mpdf->UseTemplate($tplIdx, $x, $y, $pw, $pph[$i]); }
78 else { $mpdf->UseTemplate($tplIdx, $x, ($y + (($ph - $pph[$i])/2)), $pw, $pph[$i]); }
79
80 if ($border >= 0) { $mpdf->Rect($x-$border, $y-$border, $pw+2*$border, $ph+2*$border); }
81}
82
83$mpdf->Output();
84
85exit;
86
87//==============================================================
88function SinglePage($html, $pw, $ph, $minK=1, $inc=0.1) {
89// returns height of page
90global $mpdf;
91 $mpdf->AddPage('','','','','','',($mpdf->w - $pw),'',($mpdf->h - $ph),0,0);
92 $k = 1;
93
94 $currpage = $mpdf->page;
95 $mpdf->WriteHTML($html);
96
97 $newpage = $mpdf->page;
98 while($currpage != $newpage) {
99 for($u=0;$u<=($newpage-$currpage);$u++) {
100 // DELETE PAGE - the added page
101 unset($mpdf->pages[$mpdf->page]);
102 if (isset($mpdf->ktAnnots[$mpdf->page])) { unset( $mpdf->ktAnnots[$mpdf->page] ); }
103 if (isset($mpdf->tbrot_Annots[$mpdf->page])) { unset( $mpdf->tbrot_Annots[$mpdf->page] ); }
104 if (isset($mpdf->kwt_Annots[$mpdf->page])) { unset( $mpdf->kwt_Annots[$mpdf->page] ); }
105 if (isset($mpdf->PageAnnots[$mpdf->page])) { unset( $mpdf->PageAnnots[$mpdf->page] ); }
106 if (isset($mpdf->ktBlock[$mpdf->page])) { unset( $mpdf->ktBlock[$mpdf->page] ); }
107 if (isset($mpdf->PageLinks[$mpdf->page])) { unset( $mpdf->PageLinks[$mpdf->page] ); }
108 if (isset($mpdf->pageoutput[$mpdf->page])) { unset( $mpdf->pageoutput[$mpdf->page] ); }
109 // Go to page before - so can addpage
110 $mpdf->page--;
111 }
112 // mPDF 2.4 Float Images
113 if (count($mpdf->floatbuffer)) {
114 $mpdf->objectbuffer[] = $mpdf->floatbuffer['objattr'];
115 $mpdf->printobjectbuffer(false);
116 $mpdf->objectbuffer = array();
117 $mpdf->floatbuffer = array();
118 $mpdf->float = false;
119 }
120
121
122 $k += $inc;
123 if ((1/$k) < $minK) { die("Page no. ".$mpdf->page." is too large to fit"); }
124 $w = $pw * $k;
125 $h = $ph * $k;
126 $mpdf->_beginpage('','',($mpdf->w - $w),'',($mpdf->h - $h));
127 $currpage = $mpdf->page;
128
129 $mpdf->_out('2 J');
130 $mpdf->_out(sprintf('%.2f w',0.1*$mpdf->k));
131 $mpdf->SetFont($mpdf->default_font,'',$mpdf->default_font_size ,true,true); // forces write
132 $mpdf->SetDrawColor(0);
133 $mpdf->SetFillColor(255);
134 $mpdf->SetTextColor(0);
135 $mpdf->ColorFlag=false;
136
137 // Start Transformation
138 $mpdf->StartTransform();
139 $mpdf->transformScale((100/$k), (100/$k), 0, 0);
140
141 $mpdf->WriteHTML($html);
142
143 $newpage = $mpdf->page;
144
145 //Stop Transformation
146 $mpdf->StopTransform();
147 }
148 return ($mpdf->y / $k);
149}
150?> \ No newline at end of file