PluginProbe
PDF & Print by BestWebSoft – WordPress Posts and Pages PDF Generator Plugin / 1.8.1
PDF & Print by BestWebSoft – WordPress Posts and Pages PDF Generator Plugin v1.8.1
trunk 1.5 1.6 1.7 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 1.7.7 1.7.8 1.7.9 1.8.0 1.8.1 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9.0 1.9.1 All 71 releases
pdf-print / mpdf / compress.php

compress.php in PDF & Print by BestWebSoft – WordPress Posts and Pages PDF Generator Plugin 1.8.1, at mpdf/compress.php

171 lines 5.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 $excl = array( 'HTML-CSS', 'DIRECTW', 'TABLES', 'IMAGES-CORE',
4 'IMAGES-BMP', 'IMAGES-WMF', 'TABLES-ADVANCED-BORDERS', 'COLUMNS', 'TOC', 'INDEX', 'BOOKMARKS', 'BARCODES', 'FORMS', 'WATERMARK', 'CJK-FONTS', 'INDIC', 'ANNOTATIONS', 'BACKGROUNDS', 'CSS-FLOAT', 'CSS-IMAGE-FLOAT', 'CSS-POSITION', 'CSS-PAGE', 'BORDER-RADIUS', 'HYPHENATION', 'ENCRYPTION', 'IMPORTS', 'PROGRESS-BAR', 'OTL');
5
6
7 // *DIRECTW* = Write, WriteText, WriteCell, Text, Shaded_box, AutosizeText
8 // IMAGES-CORE = [PNG, GIF, and JPG] NB background-images and watermark images
9
10 // Excluding 'HTML-CSS' will also exclude: 'TABLES', 'LISTS', 'TABLES-ADVANCED-BORDERS', 'FORMS', 'BACKGROUNDS', 'CSS-FLOAT', 'CSS-IMAGE-FLOAT', 'CSS-POSITION', 'CSS-PAGE', 'BORDER-RADIUS'
11
12 // Text is marked in mpdf_source.php with e.g. :
13 /*-- TABLES-ADVANCED-BORDERS --*/
14 /*-- END TABLES-ADVANCED-BORDERS --*/
15 // *TABLES-ADVANCED-BORDERS*
16
17
18 if (!isset($_POST['generate']) || $_POST['generate']!='generate') {
19
20
21 if (!file_exists('mpdf_source.php')) {
22 die("ERROR - Could not find mpdf_source.php file in current directory. Please rename mpdf.php as mpdf_source.php");
23 }
24
25
26
27
28 echo '<html>
29 <head>
30 <script language=javascript>
31 checked=false;
32 function checkedAll (frm1) {
33 var aa= document.getElementById("frm1");
34 if (checked == false)
35 {
36 checked = true
37 }
38 else
39 {
40 checked = false
41 }
42 for (var i =0; i < aa.elements.length; i++)
43 {
44 aa.elements[i].checked = checked;
45 }
46 }
47 </script>
48 </head>
49 <body>
50 <p><span style="color:red; font-weight: bold;">WARNING</span>: This utility will OVERWRITE mpdf.php file in the current directory.</p>
51 <p>Select the functions you wish to INCLUDE in your mpdf.php program. When you click generate, a new mpdf.php file will be written to the current directory.</p>
52 <div><b>Notes</b>
53 <ul>
54 <li>HTML-CSS is required for many of the other functions to work including: Tables, Lists, Backgrounds, Forms, Border-radius and all other CSS</li>
55 <li>DIRECTW includes the functions to Write directly to the PDF file e.g. Write, WriteText, WriteCell, Text, Shaded_box, AutosizeText</li>
56 <li>You must include either HTML-CSS or DIRECTW</li>
57 <li>JPG, PNG and JPG images are supported with IMAGES-CORE</li>
58 <li>For WMF Images, you must include both IMAGES-CORE and IMAGES-WMF</li>
59 <li>IMAGES-CORE are required for BACKGROUNDS (IMAGES) or WATERMARKS to work</li>
60 <li>OTL (OpenType Layout) is required for RTL (right-to-left) scripts to work</li>
61 </ul>
62 </div>
63 <input type="checkbox" name="checkall" onclick="checkedAll(frm1);"> <i>Select/Unselect All</i><br /><br />
64
65 <form id="frm1" action="compress.php" method="POST">
66 ';
67 foreach($excl AS $k=>$ex) {
68 echo '<input type="checkbox" value="1" name="inc['.$ex.']"';
69 if ($k==0 || ($k > 1 && $k < 5)) {
70 echo ' checked="checked"';
71 }
72 echo ' /> '.$ex.'<br />';
73 }
74
75 echo '<br />
76 <input type="submit" name="generate" value="generate" />
77 </form>
78 </body>
79 </html>';
80 exit;
81 }
82
83 $inc = $_POST['inc'];
84 if (is_array($inc) && count($inc)>0 ) {
85 foreach($inc AS $i=>$v) {
86 $key = array_search($i, $excl);
87 unset($excl[$key]);
88 }
89 }
90
91 if (!defined('PHP_VERSION_ID')) {
92 $version = explode('.', PHP_VERSION);
93 define('PHP_VERSION_ID', ($version[0] * 10000 + $version[1] * 100 + $version[2]));
94 }
95 if (PHP_VERSION_ID < 50300) { $mqr = @get_magic_quotes_runtime(); }
96 else { $mqr=0; }
97 if ($mqr) { set_magic_quotes_runtime(0); }
98
99 $l = file('mpdf_source.php');
100 if (!count($l)) { die("ERROR - Could not find mpdf_source.php file in current directory"); }
101 $exclflags = array();
102 $x = '';
103
104 // Excluding 'HTML-CSS' will also exclude: 'TABLES', 'LISTS', 'TABLES-ADVANCED-BORDERS', 'HTMLHEADERS-FOOTERS', 'FORMS', 'BACKGROUNDS', 'CSS-FLOAT', 'CSS-IMAGE-FLOAT', 'CSS-POSITION', 'CSS-PAGE', 'BORDER-RADIUS'
105 if (isset($excl[0]) && $excl[0]=='HTML-CSS') {
106 $excl[] = 'TABLES';
107 $excl[] = 'TABLES-ADVANCED-BORDERS';
108 $excl[] = 'FORMS';
109 $excl[] = 'BACKGROUNDS';
110 $excl[] = 'CSS-FLOAT';
111 $excl[] = 'CSS-IMAGE-FLOAT';
112 $excl[] = 'CSS-POSITION';
113 $excl[] = 'CSS-PAGE';
114 $excl[] = 'BORDER-RADIUS';
115 }
116 $excl = array_unique($excl);
117
118 foreach($l AS $k=>$ln) {
119 $exclude = false;
120 // *XXXXX*
121 preg_match_all("/\/\/ \*([A-Za-z\-]+)\*/", $ln, $m);
122 foreach($m[1] AS $mm) {
123 if (in_array($mm, $excl)) {
124 $exclude = true;
125 }
126 }
127 /*-- XXXXX --*/
128 preg_match_all("/\/\*-- ([A-Za-z\-]+) --\*\//", $ln, $m);
129 foreach($m[1] AS $mm) {
130 if (in_array($mm, $excl)) {
131 $exclflags[$mm] = true;
132 }
133 $exclude = true;
134 }
135 $exclflags = array_unique($exclflags);
136 /*-- END XXXX --*/
137 preg_match_all("/\/\*-- END ([A-Za-z\-]+) --\*\//", $ln, $m);
138 foreach($m[1] AS $mm) {
139 if (in_array($mm, $excl)) {
140 unset($exclflags[$mm]);
141 }
142 $exclude = true;
143 }
144 if (count($exclflags)==0 && !$exclude) {
145 $x .= $ln;
146 }
147 }
148 // mPDF 5.0
149 if (function_exists('file_put_contents')) {
150 $check = file_put_contents('mpdf.php', $x);
151 }
152 else {
153 $f=fopen('mpdf.php', 'w');
154 $check = fwrite($f, $x);
155 fclose($f);
156 }
157 if (!$check) { die("ERROR - Could not write to mpdf.php file. Are permissions correctly set?"); }
158 echo '<p><b>mPDF file generated successfully!</b></p>';
159 echo '<div>mPDF file size '.number_format((strlen($x)/1024)).' kB</div>';
160
161 unset($l);
162 unset($x);
163
164 include('mpdf.php');
165 $mpdf = new mPDF();
166
167 echo '<div>Memory usage on loading mPDF class '.number_format((memory_get_usage(true)/(1024*1024)),2).' MB</div>';
168
169 exit;
170
171 ?>