1 | <?php |
---|
2 | require_once("../dompdf_config.inc.php"); |
---|
3 | if ( isset( $_POST["html"] ) ) { |
---|
4 | |
---|
5 | if ( get_magic_quotes_gpc() ) |
---|
6 | $_POST["html"] = stripslashes($_POST["html"]); |
---|
7 | |
---|
8 | $old_limit = ini_set("memory_limit", "16M"); |
---|
9 | |
---|
10 | $dompdf = new DOMPDF(); |
---|
11 | $dompdf->load_html($_POST["html"]); |
---|
12 | $dompdf->set_paper($_POST["paper"], $_POST["orientation"]); |
---|
13 | $dompdf->render(); |
---|
14 | |
---|
15 | $dompdf->stream("dompdf_out.pdf"); |
---|
16 | |
---|
17 | exit(0); |
---|
18 | } |
---|
19 | |
---|
20 | ?> |
---|
21 | <?php include("head.inc"); ?> |
---|
22 | <div id="toc"> |
---|
23 | <h2>On this page:</h2> |
---|
24 | <ul> |
---|
25 | <?php echo li_arrow() ?><a href="#samples">Samples</a></li> |
---|
26 | <?php echo li_arrow() ?><a href="#demo">Demo</a></li> |
---|
27 | </ul> |
---|
28 | </div> |
---|
29 | |
---|
30 | <a name="samples"> </a> |
---|
31 | <h2>Samples</h2> |
---|
32 | |
---|
33 | <p>Below are some sample files. The PDF version is generated on the fly by dompdf. (The source HTML & CSS for |
---|
34 | these files is included in the test/ directory of the distribution |
---|
35 | package.)</p> |
---|
36 | |
---|
37 | <ul class="samples"> |
---|
38 | <?php |
---|
39 | $test_files = glob(dirname(__FILE__) . "/test/*.{html,php}", GLOB_BRACE); |
---|
40 | $dompdf = dirname(dirname($_SERVER["PHP_SELF"])) . "/dompdf.php?base_path=" . rawurlencode("www/test/"); |
---|
41 | foreach ( $test_files as $file ) { |
---|
42 | $file = basename($file); |
---|
43 | $arrow = "images/arrow_0" . rand(1, 6) . ".gif"; |
---|
44 | echo "<li style=\"list-style-image: url('$arrow');\">\n"; |
---|
45 | echo $file; |
---|
46 | echo " [<a class=\"button\" target=\"blank\" href=\"test/$file\">HTML</a>] [<a class=\"button\" href=\"$dompdf&input_file=" . rawurlencode("www/test/$file") . "\">PDF</a>]\n"; |
---|
47 | echo "</li>\n"; |
---|
48 | } |
---|
49 | ?> |
---|
50 | </ul> |
---|
51 | |
---|
52 | <a name="demo"> </a> |
---|
53 | <h2>Demo</h2> |
---|
54 | <p>Enter your html snippet in the text box below to see it rendered as a |
---|
55 | PDF: (Note by default, remote stylesheets, images & are disabled.)</p> |
---|
56 | |
---|
57 | <form action="<?php echo $_SERVER["PHP_SELF"];?>" method="post"> |
---|
58 | <div> |
---|
59 | <p>Paper size and orientaion: |
---|
60 | <select name="paper"> |
---|
61 | <?php |
---|
62 | foreach ( array_keys(CPDF_Adapter::$PAPER_SIZES) as $size ) |
---|
63 | echo "<option ". ($size == "letter" ? "selected " : "" ) . "value=\"$size\">$size</option>\n"; |
---|
64 | ?> |
---|
65 | </select> |
---|
66 | <select name="orientation"> |
---|
67 | <option value="portrait">portrait</option> |
---|
68 | <option value="landscape">landscape</option> |
---|
69 | </select> |
---|
70 | </p> |
---|
71 | |
---|
72 | <textarea name="html" cols="60" rows="20"> |
---|
73 | <html> |
---|
74 | <head> |
---|
75 | <style> |
---|
76 | |
---|
77 | /* Type some style rules here */ |
---|
78 | |
---|
79 | </style> |
---|
80 | </head> |
---|
81 | |
---|
82 | <body> |
---|
83 | |
---|
84 | <!-- Type some HTML here --> |
---|
85 | |
---|
86 | </body> |
---|
87 | </html> |
---|
88 | </textarea> |
---|
89 | |
---|
90 | <div style="text-align: center; margin-top: 1em;"> |
---|
91 | <input type="submit" name="submit" value="submit"/> |
---|
92 | </div> |
---|
93 | </div> |
---|
94 | </form> |
---|
95 | <p style="font-size: 0.65em; text-align: center;">(Note: if you use a KHTML |
---|
96 | based browser and are having difficulties loading the sample output, try |
---|
97 | saving it to a file first.)</p> |
---|
98 | |
---|
99 | <?php include("foot.inc"); ?> |
---|