Agregada instruccion para reiniciar tablas de horarios.
[CLab.git] / include / dompdf / www / faq.php
blob77f1a9e0b2b65ea3e179f462ac9c7d7211186aff
1 <?php include("head.inc"); ?>
2 <a name="FAQ"> </a>
3 <h2>Frequently Asked Questions</h2>
5 <ol>
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
15 on line 146</a></li>
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
19 on line XXX</a></li>
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
25 ...
26 </a></li>
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
38 </a></li>
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>
44 </ol>
46 <div class="divider1">&nbsp;</div>
47 <div class="answers">
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:
52 <pre>
53 &lt;?php
54 require_once("dompdf_config.inc.php");
55 $html =
56 '&lt;html&gt;&lt;body&gt;'.
57 '&lt;p&gt;Hello World!&lt;/p&gt;'.
58 '&lt;/body&gt;&lt;/html&gt;';
60 $dompdf = new DOMPDF();
61 $dompdf-&gt;load_html($html);
63 $dompdf-&gt;render();
64 $dompdf-&gt;stream("hello_world.pdf");
66 ?&gt;
67 </pre>
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%">&nbsp;</div>
76 <a name="save"> </a>
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-&gt;output()</code>:</p>
85 <pre>
86 require_once("dompdf_config.inc.php");
87 $html =
88 '&lt;html&gt;&lt;body&gt;'.
89 '&lt;p&gt;Foo&lt;/p&gt;'.
90 '&lt;/body&gt;&lt;/html&gt;';
92 $dompdf = new DOMPDF();
93 $dompdf-&gt;load_html($html);
95 $dompdf-&gt;render();
97 // The next call will store the entire PDF as a string in $pdf
99 $pdf = $dompdf-&gt;output();
101 // You can now write $pdf to disk, store it in a database or stream it
102 // to the client.
104 file_put_contents("saved_pdf.pdf", $pdf);
105 </pre>
107 <p>Note that typically <code>dompdf-&gt;stream()</code> and
108 <code>dompdf-&gt;output()</code> are mutually exclusive.</p>
110 <a href="#FAQ">[back to top]</a>
111 <div class="divider1" style="background-position: 721px 0%">&nbsp;</div>
114 <a name="dom"> </a>
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
120 on line 146</h3>
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%">&nbsp;</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
139 on line XXX</h3>
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%">&nbsp;</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
152 ...</h3>
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%">&nbsp;</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%">&nbsp;</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&amp;OS, in that you can draw lines, boxes and text
176 directly on the PDF. Here are step by step instructions:</p>
178 <ol>
179 <li> Somewhere in your html file, near the top, open a script tag with a "text/php" type:
180 <pre>
181 &lt;script type="text/php"&gt;
182 </pre>
183 </li>
185 <li> Check if the $pdf variable is set. dompdf sets this variable when evaluating embedded PHP.
186 <pre>
187 &lt;script type="text/php"&gt;
189 if ( isset($pdf) ) {
190 </pre>
191 </li>
193 <li> Pick a font:
194 <pre>
195 &lt;script type="text/php"&gt;
197 if ( isset($pdf) ) {
199 $font = Font_Metrics::get_font("verdana", "bold");
200 </pre>
201 </li>
203 <li> Use the CPDF_Adapter::page_text() method to set text that will be
204 displayed on every page:
206 <pre>
207 &lt;script type="text/php"&gt;
209 if ( isset($pdf) ) {
211 $font = Font_Metrics::get_font("verdana", "bold");
212 $pdf-&gt;page_text(72, 18, "Fancy Header", $font, 6, array(0,0,0));
215 &lt;/script&gt;
216 </pre>
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
222 0.0 and 1.0. </li>
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>
233 </ol>
235 <a href="#FAQ">[back to top]</a>
236 <div class="divider2" style="background-position: 12px 0%">&nbsp;</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>
243 and
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%">&nbsp;</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%">&nbsp;</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>
271 <pre>
272 require_once("dompdf_config.inc.php");
273 $html =
274 '&lt;html&gt;&lt;body&gt;'.
275 '&lt;p&gt;Some text&lt;/p&gt;'.
276 '&lt;/body&gt;&lt;/html&gt;';
278 $dompdf = new DOMPDF();
279 $dompdf-&gt;load_html($html);
281 $dompdf-&gt;render();
282 $domper-&gt;stream("my_pdf.pdf", array("Attachment" =&gt; 0));
284 </pre>
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%">&nbsp;</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
295 using margins:</p>
297 <pre>
298 &lt;table style="margin-left: auto; margin-right: auto"&gt;
299 &lt;tr&gt;
300 &lt;td&gt; ... &lt;/td&gt;
301 &lt;/tr&gt;
302 &lt;/table&gt;
303 </pre>
305 <a href="#FAQ">[back to top]</a>
306 <div class="divider1" style="background-position: 884px 0%">&nbsp;</div>
308 </div> <?php include "foot.inc" ?>