1 <?php
include("head.inc"); ?
>
3 <h2
>Frequently Asked Questions
</h2
>
6 <li
><a href
="#hello_world">Is there a
'hello world' script
for dompdf?
</a
></li
>
8 <li
><a href
="#save">How
do I save a PDF to disk?
</a
></li
>
10 <li
><a href
="#dom">I
'm getting the following error: <br/>
11 Fatal error: DOMPDF_autoload() [function.require]: Failed opening required
12 '/var/www
/dompdf
/include/domdocument
.cls
.php
'
13 (include_path='.:') in
14 /var/www/dompdf/dompdf_config.inc.php
17 <li><a href="#exec_time">I'm getting the following error
: <br
/> Fatal error
:
18 Maximum execution time of
30 seconds exceeded in
/var/www
/dompdf
/dompdf
.php
21 <li
><a href
="#no_block_parent">I
'm getting the following error:<br/>
22 Fatal error: Uncaught exception 'DOMPDF_Exception
' with message 'No
23 block
-level parent found
. Not good
.' in
24 C:\Program Files\Apache\htdocs\dompdf\include\inline_positioner.cls.php:68
28 <li><a href="#tables">I have a big table and it's broken
!</a
></li
>
30 <li
><a href
="#footers">Is there a way to add headers
and footers?
</a
></li
>
32 <li
><a href
="#page_break">How
do I insert page breaks?
</a
></li
>
34 <li
><a href
="#zend_optimizer">I
'm getting the following error:<br/>
35 Cannot access undefined property for object with
36 overloaded property access in
37 /var/www/dompdf/include/frame_tree.cls.php on line 160
40 <li><a href="#new_window">How can I make PDFs open in the browser window instead of
41 opening the download dialog?</a></li>
43 <li><a href="#centre">How do I centre a table, paragraph or div?</li>
46 <div class="divider1"> </div>
48 <a name="hello_world"> </a>
49 <h3>Is there a 'hello world
' script for dompdf?</h3>
51 <p>Here's a hello world script
:
54 require_once("dompdf_config.inc.php");
56 '<html><body>'.
57 '<p>Hello World!</p>'.
58 '</body></html>';
60 $dompdf = new DOMPDF();
61 $dompdf->
;load_html($html);
64 $dompdf->
;stream("hello_world.pdf");
69 <p
>Put this script in the same directory
as
70 dompdf_config
.inc
.php
. You
'll have to change the paths in
71 dompdf_config.inc.php to match your installation.</p>
73 <a href="#FAQ">[back to top]</a>
74 <div class="divider2" style="background-position: 25% 0%"> </div>
77 <h3>How do I save a PDF to disk?</h3>
79 <p>If you are using the included <a href="usage.php#web">dompdf.php</a> script you
80 can pass it the "save_file" option in conjunction with the "output_file" option.</p>
82 <p>If you are using the DOMPDF class, you can save the generated PDF
83 by calling <code>$dompdf->output()</code>:</p>
86 require_once("dompdf_config.inc.php");
88 '<
;html
>
;<
;body
>
;'.
89 '<
;p
>
;Foo
<
;/p
>
;'.
90 '<
;/body
>
;<
;/html
>
;';
92 $dompdf = new DOMPDF();
93 $dompdf->load_html($html);
97 // The next call will store the entire PDF as a string in $pdf
99 $pdf = $dompdf->output();
101 // You can now write $pdf to disk, store it in a database or stream it
104 file_put_contents("saved_pdf.pdf", $pdf);
107 <p>Note that typically <code>dompdf->stream()</code> and
108 <code>dompdf->output()</code> are mutually exclusive.</p>
110 <a href="#FAQ">[back to top]</a>
111 <div class="divider1" style="background-position: 721px 0%"> </div>
115 <h3>I'm getting the following error
: <br
/>
116 Fatal error
: DOMPDF_autoload() [function.require]: Failed opening required
117 '/var/www/dompdf/include/domdocument.cls.php'
118 (include_path
='.:') in
119 /var/www
/dompdf
/dompdf_config
.inc
.php
122 <p
>This error occurs when the version of PHP that you are using does not have
123 the DOM extension enabled
. You can check which extensions are enabled by
124 examning the output of
<code
>phpinfo()</code
>.</p
>
126 <p
>There are a couple of ways that the DOM extension could have been
127 disabled
. DOM uses libxml
, so
if libxml is not present on your server
128 then the DOM extension will not work
. Alternatively
, if PHP was compiled
129 with the
'--disable-dom' switch or the
'--disable-xml' switch, DOM support
130 will also be removed
. You can check which switches were used to compile
131 PHP with
<code
>phpinfo()</code
>.</p
>
133 <a href
="#FAQ">[back to top
]</a
>
134 <div
class="divider1" style
="background-position: 239px 0%"> 
;</div
>
136 <a name
="exec_time"> </a
>
137 <h3
>I
'm getting the following error: <br/> Fatal error:
138 Maximum execution time of 30 seconds exceeded in /var/www/dompdf/dompdf.php
141 <p>Nested tables are not supported yet (v0.4.3) and can cause dompdf to enter an
142 endless loop, thus giving rise to this error.</p>
144 <a href="#FAQ">[back to top]</a>
145 <div class="divider1" style="background-position: 300px 0%"> </div>
147 <a name="no_block_parent"> </a>
148 <h3>I'm getting the following error
:<br
/>
149 Fatal error
: Uncaught exception
'DOMPDF_Exception' with message
'No
150 block-level parent found. Not good.' in
151 C
:\Program Files\Apache\htdocs\dompdf\
include\inline_positioner
.cls
.php
:68
154 <p
>This should be fixed in versions
0.4.1 and up
. The error was
155 caused by
<code
>parse_url()</code
> thinking that the
'c' in
'c:\' was
156 a protocol. Version 0.4.1 works around this issue.</p>
158 <a href="#FAQ">[back to top]</a>
159 <div class="divider2" style="background-position: 130px 0%"> </div>
161 <a name="tables"> </a>
162 <h3>I have a big table and it's broken
!</h3
>
164 <p
>This is fixed in versions
0.4 and higher
. Previous versions did not support tables that spanned pages
.</p
>
166 <a href
="#FAQ">[back to top
]</a
>
167 <div
class="divider1" style
="background-position: 812px 0%"> 
;</div
>
169 <a name
="footers"> </a
>
170 <h3
>Is there a way to add headers
and footers?
</h3
>
172 <p
>Yes
, you can add headers
and footers using inline PHP
. Headers
and
173 footers are added by accessing the PDF renderer directly using inline
174 PHP embedded in your HTML file
. This is similar to creating PDFs with
175 FPDF
or ezPDF from R
&
;OS
, in that you can draw lines
, boxes
and text
176 directly on the PDF
. Here are step by step instructions
:</p
>
179 <li
> Somewhere in your html file
, near the top
, open a script tag with a
"text/php" type
:
181 <
;script type
="text/php">
;
185 <li
> Check
if the
$pdf variable is set
. dompdf sets this variable when evaluating embedded PHP
.
187 <
;script type
="text/php">
;
195 <
;script type
="text/php">
;
199 $font = Font_Metrics
::get_font("verdana", "bold");
203 <li
> Use the CPDF_Adapter
::page_text() method to set text that will be
204 displayed on every page
:
207 <
;script type
="text/php">
;
211 $font = Font_Metrics
::get_font("verdana", "bold");
212 $pdf->
;page_text(72, 18, "Fancy Header", $font, 6, array(0,0,0));
218 In this example
, the text will be displayed
72pt (1 in
) from the left
219 edge of the page
and 18pt (1/4 in
) from the top of the page
, in
6pt
220 font
. The last argument to
page_text() is the colour which takes an
221 array of the form
array(r
,g
,b
) where each of r
, g
, and b are between
224 <li
> There are several other methods available
. See the API
225 documentation
for the CPDF_Adapter
class (<a
226 href
="doc/">http
://www.digitaljunkies.ca/dompdf/doc</a>) for more
227 details
. Also have a look at the demo_01
.html file in the www
/test
/
228 directory
. It adds a header
and footer using
229 PDF_Adapter
->page_text(). It also adds text superimposed over the
230 rendered text using a PDF
'object'. This
object is added using
231 CPDF_Adapter
->add_object(). See
<a
232 href
="usage.php#inline">usage
.php
</a
> for more info on inline PHP
.</li
>
235 <a href
="#FAQ">[back to top
]</a
>
236 <div
class="divider2" style
="background-position: 12px 0%"> 
;</div
>
238 <a name
="page_break"> </a
>
239 <h3
>How
do I insert page breaks?
</h3
>
241 <p
>Page breaks can be inserted by applying the CSS properties
242 <a href
="http://www.w3.org/TR/CSS21/page.html#propdef-page-break-before">page
-break-before
</a
>
244 <a href
="http://www.w3.org/TR/CSS21/page.html#propdef-page-break-after">page
-break-after
</a
> to
245 any block level element
.</p
>
247 <a href
="#FAQ">[back to top
]</a
>
248 <div
class="divider1" style
="background-position: 44px 0%"> 
;</div
>
250 <a name
="zend_optimizer"> </a
>
251 <h3
>I
'm getting the following error:<br/>
252 Cannot access undefined property for object with
253 overloaded property access in
254 /var/www/dompdf/include/frame_tree.cls.php on line 160</h3>
256 <p>This error is caused by an incompatibility with the Zend Optimizer.
257 Disable the optimizer when using dompdf.</p>
259 <a href="#FAQ">[back to top]</a>
260 <div class="divider1" style="background-position: 991px 0%"> </div>
262 <a name="new_window"> </a>
263 <h3>How can I make PDFs open in the browser window instead of
264 opening the download dialog?</h3>
266 <p>This is controlled by the "Attachment" header sent by dompdf when
267 it streams the PDF to the client. You can modify the headers sent by
268 dompdf by passing additional options to the
269 <code>$dompdf->stream()</code> function:</p>
272 require_once("dompdf_config.inc.php");
274 '<
;html
>
;<
;body
>
;'.
275 '<
;p
>
;Some text
<
;/p
>
;'.
276 '<
;/body
>
;<
;/html
>
;';
278 $dompdf = new DOMPDF();
279 $dompdf->load_html($html);
281 $dompdf->render();
282 $domper->stream("my_pdf.pdf", array("Attachment" => 0));
286 <p>See the <a href="usage.php#methodstream">class reference</a> for full details.</p>
288 <a href="#FAQ">[back to top]</a>
289 <div class="divider2" style="background-position: 237px 0%"> </div>
291 <a name="centre"> </a>
292 <h3>How do I centre a table, paragraph or div?</h3>
294 <p>You can centre any block level element (table, p, div, ul, etc.) by
298 <table style="margin-left: auto; margin-right: auto">
300 <td> ... </td>
305 <a href="#FAQ">[back to top]</a>
306 <div class="divider1" style="background-position: 884px 0%"> </div>
308 </div> <?php include "foot.inc" ?>