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