source: sandbox/filemanager/tp/dompdf/www/examples.php @ 1575

Revision 1575, 2.6 KB checked in by amuller, 14 years ago (diff)

Ticket #597 - Implentação, melhorias do modulo gerenciador de arquivos

RevLine 
[1575]1<?php
2require_once("../dompdf_config.inc.php");
3if ( 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 &amp; CSS for
34these files is included in the test/ directory of the distribution
35package.)</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/");
41foreach ( $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
55PDF: (Note by default, remote stylesheets, images &amp; 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
62foreach ( 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&lt;html&gt;
74&lt;head&gt;
75&lt;style&gt;
76
77/* Type some style rules here */
78
79&lt;/style&gt;
80&lt;/head&gt;
81
82&lt;body&gt;
83
84&lt;!-- Type some HTML here --&gt;
85
86&lt;/body&gt;
87&lt;/html&gt;
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
96based browser and are having difficulties loading the sample output, try
97saving it to a file first.)</p>
98
99<?php include("foot.inc"); ?>
Note: See TracBrowser for help on using the repository browser.