Skip to content

Commit fef8453

Browse files
author
Raymond Kolbe
committed
* Made package PHP Composer install ready.
* Added appropriate classes to be integrated into Zend's view layer.
1 parent 2a4c4f8 commit fef8453

File tree

10 files changed

+742
-0
lines changed

10 files changed

+742
-0
lines changed

composer.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "dino/DOMPDFModule",
3+
"type": "library",
4+
"description": "A Zend Framework 2 module for incorporating DOMPDF support.",
5+
"keywords": ["pdf","dompdf", "zf2"],
6+
"homepage": "",
7+
"license": "MIT",
8+
"authors": [
9+
{
10+
"name": "Raymond Kolbe",
11+
"email": "raymond.kolbe@maine.edu"
12+
}
13+
],
14+
"require": {
15+
"php": ">=5.3.0",
16+
"dino/dompdf": "0.1.*"
17+
},
18+
"autoload": {
19+
"psr-0": {
20+
"DOMPDFModule": "src/"
21+
}
22+
}
23+
}

config/module.compat.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
/**
4+
* Ensure that PHP is working with text internally using UTF8 character encoding.
5+
*/
6+
mb_internal_encoding('UTF-8');
7+
8+
/**
9+
* Global array of warnings generated by DomDocument parser and
10+
* stylesheet class
11+
*
12+
* @var array
13+
*/
14+
global $_dompdf_warnings;
15+
$_dompdf_warnings = array();
16+
17+
/**
18+
* If true, $_dompdf_warnings is dumped on script termination when using
19+
* dompdf/dompdf.php or after rendering when using the DOMPDF class.
20+
* When using the class, setting this value to true will prevent you from
21+
* streaming the PDF.
22+
*
23+
* @var bool
24+
*/
25+
global $_dompdf_show_warnings;
26+
$_dompdf_show_warnings = false;
27+
28+
/**
29+
* If true, the entire tree is dumped to stdout in dompdf.cls.php.
30+
* Setting this value to true will prevent you from streaming the PDF.
31+
*
32+
* @var bool
33+
*/
34+
global $_dompdf_debug;
35+
$_dompdf_debug = false;
36+
37+
/**
38+
* Array of enabled debug message types
39+
*
40+
* @var array
41+
*/
42+
global $_DOMPDF_DEBUG_TYPES;
43+
$_DOMPDF_DEBUG_TYPES = array(); //array("page-break" => 1);

config/module.config.php

Lines changed: 279 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,279 @@
1+
<?php
2+
3+
return array(
4+
// Module specific options
5+
'dompdf_module' => array(
6+
/**
7+
* The location of the DOMPDF font directory
8+
*
9+
* If DOMPDF_FONT_DIR identical to DOMPDF_FONT_CACHE or user executing DOMPDF from the CLI,
10+
* this directory must be writable by the webserver process ().
11+
* *Please note the trailing slash.*
12+
*
13+
* Notes regarding fonts:
14+
* Additional .afm font metrics can be added by executing load_font.php from command line.
15+
*
16+
* Only the original "Base 14 fonts" are present on all pdf viewers. Additional fonts must
17+
* be embedded in the pdf file or the PDF may not display correctly. This can significantly
18+
* increase file size and could violate copyright provisions of a font. Font subsetting is
19+
* not currently supported.
20+
*
21+
* Any font specification in the source HTML is translated to the closest font available
22+
* in the font directory.
23+
*
24+
* The pdf standard "Base 14 fonts" are:
25+
* Courier, Courier-Bold, Courier-BoldOblique, Courier-Oblique,
26+
* Helvetica, Helvetica-Bold, Helvetica-BoldOblique, Helvetica-Oblique,
27+
* Times-Roman, Times-Bold, Times-BoldItalic, Times-Italic,
28+
* Symbol,
29+
* ZapfDingbats,
30+
*
31+
* *Please note the trailing slash.*
32+
*/
33+
'font_directory' => __DIR__ . '/../../dompdf/lib/vendor/fonts/',
34+
35+
/**
36+
* The location of the DOMPDF font cache directory
37+
*
38+
* Note this directory must be writable by the webserver process
39+
* This folder must already exist!
40+
* It contains the .afm files, on demand parsed, converted to php syntax and cached
41+
* This folder can be the same as DOMPDF_FONT_DIR
42+
*/
43+
'font_cache_directory' => __DIR__ . '/../../data/dompdf/cache/',
44+
45+
/**
46+
* The location of a temporary directory.
47+
*
48+
* The directory specified must be writeable by the webserver process.
49+
* The temporary directory is required to download remote images and when
50+
* using the PFDLib back end.
51+
*/
52+
'temporary_directory' => sys_get_temp_dir(),
53+
54+
/**
55+
* ==== IMPORTANT ====
56+
*
57+
* dompdf's "chroot": Prevents dompdf from accessing system files or other
58+
* files on the webserver. All local files opened by dompdf must be in a
59+
* subdirectory of this directory. DO NOT set it to '/' since this could
60+
* allow an attacker to use dompdf to read any files on the server. This
61+
* should be an absolute path.
62+
* This is only checked on command line call by dompdf.php, but not by
63+
* direct class use like:
64+
* $dompdf = new DOMPDF(); $dompdf->load_html($htmldata); $dompdf->render(); $pdfdata = $dompdf->output();
65+
*/
66+
'chroot' => realpath(__DIR__ . '/../'),
67+
68+
/**
69+
* Whether to use Unicode fonts or not.
70+
*
71+
* When set to true the PDF backend must be set to "CPDF" and fonts must be
72+
* loaded via load_font.php.
73+
*
74+
* When enabled, dompdf can support all Unicode glyphs. Any glyphs used in a
75+
* document must be present in your fonts, however.
76+
*/
77+
'unicode_enabled' => true,
78+
79+
/**
80+
* Whether to make font subsetting or not.
81+
*/
82+
'enable_fontsubsetting' => false,
83+
84+
/**
85+
* The PDF rendering backend to use
86+
*
87+
* Valid settings are 'PDFLib', 'CPDF' (the bundled R&OS PDF class), 'GD' and
88+
* 'auto'. 'auto' will look for PDFLib and use it if found, or if not it will
89+
* fall back on CPDF. 'GD' renders PDFs to graphic files. {@link
90+
* Canvas_Factory} ultimately determines which rendering class to instantiate
91+
* based on this setting.
92+
*
93+
* Both PDFLib & CPDF rendering backends provide sufficient rendering
94+
* capabilities for dompdf, however additional features (e.g. object,
95+
* image and font support, etc.) differ between backends. Please see
96+
* {@link PDFLib_Adapter} for more information on the PDFLib backend
97+
* and {@link CPDF_Adapter} and lib/class.pdf.php for more information
98+
* on CPDF. Also see the documentation for each backend at the links
99+
* below.
100+
*
101+
* The GD rendering backend is a little different than PDFLib and
102+
* CPDF. Several features of CPDF and PDFLib are not supported or do
103+
* not make any sense when creating image files. For example,
104+
* multiple pages are not supported, nor are PDF 'objects'. Have a
105+
* look at {@link GD_Adapter} for more information. GD support is new
106+
* and experimental, so use it at your own risk.
107+
*
108+
* @link http://www.pdflib.com
109+
* @link http://www.ros.co.nz/pdf
110+
* @link http://www.php.net/image
111+
*/
112+
'pdf_backend' => 'CPDF',
113+
114+
/**
115+
* html target media view which should be rendered into pdf.
116+
* List of types and parsing rules for future extensions:
117+
* http://www.w3.org/TR/REC-html40/types.html
118+
* screen, tty, tv, projection, handheld, print, braille, aural, all
119+
* Note: aural is deprecated in CSS 2.1 because it is replaced by speech in CSS 3.
120+
* Note, even though the generated pdf file is intended for print output,
121+
* the desired content might be different (e.g. screen or projection view of html file).
122+
* Therefore allow specification of content here.
123+
*/
124+
'default_media_type' => 'screen',
125+
126+
/**
127+
* PDFlib license key
128+
*
129+
* If you are using a licensed, commercial version of PDFlib, specify
130+
* your license key here. If you are using PDFlib-Lite or are evaluating
131+
* the commercial version of PDFlib, comment out this setting.
132+
*
133+
* @link http://www.pdflib.com
134+
*
135+
* If pdflib present in web server and auto or selected explicitely above,
136+
* a real license code must exist!
137+
*/
138+
//def("DOMPDF_PDFLIB_LICENSE", "your license key here");
139+
140+
/**
141+
* The default paper size.
142+
*
143+
* North America standard is "letter"; other countries generally "a4"
144+
*
145+
* @see CPDF_Adapter::PAPER_SIZES for valid sizes
146+
*/
147+
'default_paper_size' => 'letter',
148+
149+
/**
150+
* The default font family
151+
*
152+
* Used if no suitable fonts can be found. This must exist in the font folder.
153+
* @var string
154+
*/
155+
'default_font' => 'serif',
156+
157+
/**
158+
* Image DPI setting
159+
*
160+
* This setting determines the default DPI setting for images and fonts. The
161+
* DPI may be overridden for inline images by explictly setting the
162+
* image's width & height style attributes (i.e. if the image's native
163+
* width is 600 pixels and you specify the image's width as 72 points,
164+
* the image will have a DPI of 600 in the rendered PDF. The DPI of
165+
* background images can not be overridden and is controlled entirely
166+
* via this parameter.
167+
*
168+
* For the purposes of DOMPDF, pixels per inch (PPI) = dots per inch (DPI).
169+
* If a size in html is given as px (or without unit as image size),
170+
* this tells the corresponding size in pt.
171+
* This adjusts the relative sizes to be similar to the rendering of the
172+
* html page in a reference browser.
173+
*
174+
* In pdf, always 1 pt = 1/72 inch
175+
*
176+
* Rendering resolution of various browsers in px per inch:
177+
* Windows Firefox and Internet Explorer:
178+
* SystemControl->Display properties->FontResolution: Default:96, largefonts:120, custom:?
179+
* Linux Firefox:
180+
* about:config *resolution: Default:96
181+
* (xorg screen dimension in mm and Desktop font dpi settings are ignored)
182+
*
183+
* Take care about extra font/image zoom factor of browser.
184+
*
185+
* In images, <img> size in pixel attribute, img css style, are overriding
186+
* the real image dimension in px for rendering.
187+
*
188+
* @var int
189+
*/
190+
'dpi' => 96,
191+
192+
/**
193+
* Enable inline PHP
194+
*
195+
* If this setting is set to true then DOMPDF will automatically evaluate
196+
* inline PHP contained within <script type="text/php"> ... </script> tags.
197+
*
198+
* Enabling this for documents you do not trust (e.g. arbitrary remote html
199+
* pages) is a security risk. Set this option to false if you wish to process
200+
* untrusted documents.
201+
*
202+
* @var bool
203+
*/
204+
'enable_php' => false,
205+
206+
/**
207+
* Enable inline Javascript
208+
*
209+
* If this setting is set to true then DOMPDF will automatically insert
210+
* JavaScript code contained within <script type="text/javascript"> ... </script> tags.
211+
*
212+
* @var bool
213+
*/
214+
'enable_javascript' => true,
215+
216+
/**
217+
* Enable remote file access
218+
*
219+
* If this setting is set to true, DOMPDF will access remote sites for
220+
* images and CSS files as required.
221+
* This is required for part of test case www/test/image_variants.html through www/examples.php
222+
*
223+
* Attention!
224+
* This can be a security risk, in particular in combination with DOMPDF_ENABLE_PHP and
225+
* allowing remote access to dompdf.php or on allowing remote html code to be passed to
226+
* $dompdf = new DOMPDF(); $dompdf->load_html(...);
227+
* This allows anonymous users to download legally doubtful internet content which on
228+
* tracing back appears to being downloaded by your server, or allows malicious php code
229+
* in remote html pages to be executed by your server with your account privileges.
230+
*
231+
* @var bool
232+
*/
233+
'enable_remote' => false,
234+
235+
/**
236+
* The debug output log
237+
* @var string
238+
*/
239+
'log_output_file' => __DIR__ . '/../../data/dompdf/log',
240+
241+
/**
242+
* A ratio applied to the fonts height to be more like browsers' line height
243+
*/
244+
'font_height_ratio' => 1.1,
245+
246+
/**
247+
* Enable CSS float
248+
*
249+
* Allows people to disabled CSS float support
250+
* @var bool
251+
*/
252+
'enable_css_float' => false,
253+
254+
/**
255+
* Use the more-than-experimental HTML5 Lib parser
256+
*/
257+
'enable_html5parser' => false,
258+
259+
'debug_png' => false,
260+
'debug_keep_temp' => false,
261+
'debug_css' => false,
262+
'debug_layout' => false,
263+
'debug_layout_links' => false,
264+
'debug_layout_blocks' => false,
265+
'debug_layout_inline' => false,
266+
'debug_layout_padding_box' => false
267+
),
268+
'view_manager' => array(
269+
'strategies' => array(
270+
'ViewPdfStrategy'
271+
)
272+
),
273+
'service_manager' => array(
274+
'factories' => array(
275+
'ViewPdfRenderer' => 'DOMPDFModule\Mvc\Service\ViewPdfRendererFactory',
276+
'ViewPdfStrategy' => 'DOMPDFModule\Mvc\Service\ViewPdfStrategyFactory',
277+
),
278+
),
279+
);

config/module.dompdf.local.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
3+
return array();

0 commit comments

Comments
 (0)