| 1 |
lars |
1 |
<html>
|
|
|
2 |
<head>
|
|
|
3 |
<title>Minimal code samples</title>
|
|
|
4 |
<link rel="stylesheet" type="text/css" medial="all" title="Default" href="css/help.css"/>
|
|
|
5 |
<style type="text/css">
|
|
|
6 |
div.note {
|
|
|
7 |
margin: 0.5em 0;
|
|
|
8 |
}
|
|
|
9 |
|
|
|
10 |
div.class {
|
|
|
11 |
margin: 0.5em 0 0.5em 2em;
|
|
|
12 |
}
|
|
|
13 |
|
|
|
14 |
div.interface {
|
|
|
15 |
margin: 1em 0 0.5em 0;
|
|
|
16 |
padding: 2px 5px;
|
|
|
17 |
background-color: #f0f0f0;
|
|
|
18 |
}
|
|
|
19 |
|
|
|
20 |
span.interface_name {
|
|
|
21 |
font-weight: bold;
|
|
|
22 |
}
|
|
|
23 |
|
|
|
24 |
span.method_name {
|
|
|
25 |
font-weight: bold;
|
|
|
26 |
}
|
|
|
27 |
</style>
|
|
|
28 |
</head>
|
|
|
29 |
<body>
|
|
|
30 |
|
|
|
31 |
<h1>Minimal code</h1>
|
|
|
32 |
<h2>Using the default pipeline</h2>
|
|
|
33 |
<pre class="code">
|
|
|
34 |
require_once('pipeline.factory.class.php');
|
|
|
35 |
parse_config_file('./html2ps.config');
|
|
|
36 |
|
|
|
37 |
global $g_config;
|
|
|
38 |
$g_config = array(
|
|
|
39 |
'cssmedia' => 'screen',
|
|
|
40 |
'renderimages' => true,
|
|
|
41 |
'renderforms' => false,
|
|
|
42 |
'renderlinks' => true,
|
|
|
43 |
'mode' => 'html',
|
|
|
44 |
'debugbox' => false,
|
|
|
45 |
'draw_page_border' => false
|
|
|
46 |
);
|
|
|
47 |
|
|
|
48 |
$media = Media::predefined('A4');
|
|
|
49 |
$media->set_landscape(false);
|
|
|
50 |
$media->set_margins(array('left' => 0,
|
|
|
51 |
'right' => 0,
|
|
|
52 |
'top' => 0,
|
|
|
53 |
'bottom' => 0));
|
|
|
54 |
$media->set_pixels(1024);
|
|
|
55 |
|
|
|
56 |
global $g_px_scale;
|
|
|
57 |
$g_px_scale = mm2pt($media->width() - $media->margins['left'] - $media->margins['right']) / $media->pixels;
|
|
|
58 |
|
|
|
59 |
global $g_pt_scale;
|
|
|
60 |
$g_pt_scale = $g_px_scale * 1.43;
|
|
|
61 |
|
|
|
62 |
$pipeline = PipelineFactory::create_default_pipeline("","");
|
|
|
63 |
$pipeline->process('http://www.google.com', $media);
|
|
|
64 |
</pre>
|
|
|
65 |
|
|
|
66 |
<h2>Building your own conversion pipeline</h2>
|
|
|
67 |
<pre class="code">
|
|
|
68 |
require_once('pipeline.class.php');
|
|
|
69 |
parse_config_file('html2ps.config');
|
|
|
70 |
|
|
|
71 |
$g_config = array(
|
|
|
72 |
'cssmedia' => 'screen',
|
|
|
73 |
'renderimages' => true,
|
|
|
74 |
'renderforms' => false,
|
|
|
75 |
'renderlinks' => true,
|
|
|
76 |
'mode' => 'html',
|
|
|
77 |
'debugbox' => false,
|
|
|
78 |
'draw_page_border' => false
|
|
|
79 |
);
|
|
|
80 |
|
|
|
81 |
$media = Media::predefined('A4');
|
|
|
82 |
$media->set_landscape(false);
|
|
|
83 |
$media->set_margins(array('left' => 0,
|
|
|
84 |
'right' => 0,
|
|
|
85 |
'top' => 0,
|
|
|
86 |
'bottom' => 0));
|
|
|
87 |
$media->set_pixels(1024);
|
|
|
88 |
|
|
|
89 |
$g_px_scale = mm2pt($media->width() - $media->margins['left'] - $media->margins['right']) / $media->pixels;
|
|
|
90 |
$g_pt_scale = $g_px_scale * 1.43;
|
|
|
91 |
|
|
|
92 |
$pipeline = new Pipeline;
|
|
|
93 |
$pipeline->fetchers[] = new FetcherURL;
|
|
|
94 |
$pipeline->data_filters[] = new DataFilterHTML2XHTML;
|
|
|
95 |
$pipeline->parser = new ParserXHTML;
|
|
|
96 |
$pipeline->layout_engine = new LayoutEngineDefault;
|
|
|
97 |
$pipeline->output_driver = new OutputDriverFPDF($media);
|
|
|
98 |
$pipeline->destination = new DestinationFile(null);
|
|
|
99 |
|
|
|
100 |
$pipeline->process('http://www.yahoo.com', $media);
|
|
|
101 |
</pre>
|
|
|
102 |
|
|
|
103 |
<h2>Running the script in batch mode</h2>
|
|
|
104 |
<pre class="code">
|
|
|
105 |
require_once('pipeline.factory.class.php');
|
|
|
106 |
parse_config_file('./html2ps.config');
|
|
|
107 |
|
|
|
108 |
global $g_config;
|
|
|
109 |
$g_config = array(
|
|
|
110 |
'cssmedia' => 'screen',
|
|
|
111 |
'renderimages' => true,
|
|
|
112 |
'renderforms' => false,
|
|
|
113 |
'renderlinks' => true,
|
|
|
114 |
'mode' => 'html',
|
|
|
115 |
'debugbox' => false,
|
|
|
116 |
'draw_page_border' => false
|
|
|
117 |
);
|
|
|
118 |
|
|
|
119 |
$media = Media::predefined('A4');
|
|
|
120 |
$media->set_landscape(false);
|
|
|
121 |
$media->set_margins(array('left' => 0,
|
|
|
122 |
'right' => 0,
|
|
|
123 |
'top' => 0,
|
|
|
124 |
'bottom' => 0));
|
|
|
125 |
$media->set_pixels(1024);
|
|
|
126 |
|
|
|
127 |
global $g_px_scale;
|
|
|
128 |
$g_px_scale = mm2pt($media->width() - $media->margins['left'] - $media->margins['right']) / $media->pixels;
|
|
|
129 |
|
|
|
130 |
global $g_pt_scale;
|
|
|
131 |
$g_pt_scale = $g_px_scale * 1.43;
|
|
|
132 |
|
|
|
133 |
$pipeline = PipelineFactory::create_default_pipeline("","");
|
|
|
134 |
$pipeline->process_batch(array('http://www.google.com',
|
|
|
135 |
'http://www.yahoo.com'), $media);
|
|
|
136 |
</pre>
|
|
|
137 |
|
|
|
138 |
</body>
|
|
|
139 |
</html>
|