source: branches/2.2/filemanager/tp/dompdf/www/examples.php @ 3019

Revision 3019, 2.9 KB checked in by amuller, 14 years ago (diff)

Ticket #1135 - Corrigindo CSS e adicionando filemanager

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