/var/www/hkosl.com/littleark/webadmin/libraies/dompdf/dompdf/www/examples.php


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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php

require_once "../dompdf_config.inc.php";

//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.

$dompdf dirname(dirname($_SERVER["PHP_SELF"]));
if ( 
$dompdf == '/' || $dompdf == '\\') {
  
$dompdf '';
}

$dompdf .= "/dompdf.php?base_path=" rawurlencode("www/test/");

include 
"head.inc"

?>

<script type="text/javascript">
function resizePreview(){
  var preview = $("#preview");
  preview.height($(window).height() - preview.offset().top - 2);
}

function getPath(hash) {
  var file, type;
  var parts = hash.split(/,/);
  
  file = parts[0];
  
  if (parts.length == 2) {
    type = parts[1];
  }
  
  switch(type) {
    default:
    case "html": 
      return "test/"+file;
    case "pdf":
      return "<?php echo $dompdf?>&options[Attachment]=0&input_file="+file+"#toolbar=0&view=FitH&statusbar=0&messages=0&navpanes=0";
  }
}

function setHash(hash) {
  location.hash = "#"+hash;
}

$(function(){
  var preview = $("#preview");
  resizePreview();

  $(window).scroll(function() {
    var scrollTop = Math.min($(this).scrollTop(), preview.height()+preview.parent().offset().top) - 2;
    preview.css("margin-top", scrollTop + "px");
  });

  $(window).resize(resizePreview);
  
  var hash = location.hash;
  var type = "html";
  if (hash) {
    hash = hash.substr(1);
    preview.attr("src", getPath(hash));
  }
});
</script>
<iframe id="preview" name="preview" src="about:blank" frameborder="0" marginheight="0" marginwidth="0"></iframe>

<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 &amp; CSS for
these files is included in the test/ directory of the distribution
package.)</p>

<?php

$extensions 
= array("html");
if ( 
DOMPDF_ENABLE_PHP ) {
  
$extensions[] = "php";
}

// To be compatible with non-GNU systems
if (!defined("GLOB_BRACE")) {
  
$test_files glob("test/*");
  
$test_files preg_grep("/(" implode("|",$extensions) . ")/i"$test_files);
}
else {
  
$test_files glob("test/*.{".implode(","$extensions)."}"GLOB_BRACE);
}

$sections = array(
  
"print"    => array(), 
  
"css"      => array(), 
  
"dom"      => array(), 
  
"image"    => array(), 
  
"page"     => array(),
  
"encoding" => array(), 
  
"script"   => array(), 
  
"quirks"   => array(), 
  
"other"    => array(), 
);

foreach ( 
$test_files as $file ) {
  
preg_match("@[\\/](([^_]+)_?(.*))\.(".implode("|"$extensions).")$@i"$file$matches);
  
$prefix $matches[2];

  if ( 
array_key_exists($prefix$sections) ) {
    
$sections[$prefix][] = array($file$matches[3]);
  }
  else {
    
$sections["other"][] = array($file$matches[1]);
  }
}

foreach ( 
$sections as $section => $files ) {
  echo 
"<h3>$section</h3>";
  
  echo 
"<ul class=\"samples\">";
  foreach ( 
$files as $file ) {
    
$filename basename($file[0]);
    
$title $file[1];
    
$arrow "images/arrow_0" rand(16) . ".gif";  
    echo 
"<li style=\"list-style-image: url('$arrow');\">\n";
    echo 

  [<a class=\"button\" target=\"preview\" onclick=\"setHash('
$filename,html')\" href=\"test/$filename\">HTML</a>] 
  [<a class=\"button\" target=\"preview\" onclick=\"setHash('
$filename,pdf')\" href=\"$dompdf&amp;options[Attachment]=0&amp;input_file=" rawurlencode($filename) . "#toolbar=0&amp;view=FitH&amp;statusbar=0&amp;messages=0&amp;navpanes=0\">PDF</a>] ";
    echo 
$title;
    echo 
"</li>\n";
  }
  echo 
"</ul>";
}

include 
"foot.inc"