Spaces:
Sleeping
Sleeping
File size: 2,924 Bytes
07c3cdd | 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 | <html>
<head>
<title>Events</title>
<link rel="stylesheet" type="text/css" medial="all" title="Default" href="css/help.css"/>
<style type="text/css">
div.note {
margin: 0.5em 0;
}
div.class {
margin: 0.5em 0 0.5em 2em;
}
div.interface {
margin: 1em 0 0.5em 0;
padding: 2px 5px;
background-color: #f0f0f0;
}
span.interface_name {
font-weight: bold;
}
span.method_name {
font-weight: bold;
}
</style>
</head>
<body>
<h1>Events</h1>
<p>
Sometimes you'd want to add your own code to the rendering routines; for example, you could want to make your own watermarks,
count pages in the multiple-document batch, add digital signature to the generated PDF file or
perform any other actions requiring low-level access to PDF file at the certain moments. Now you may do this using
HTML2PS events. Pipeline object will fire events at predefined moments while rendering PDF file; you may catch them and
do something useful.
</p>
<p>The code below illustrates installation of a simple callback to be called immediately after
new page was rendered. (If you're using PHP 5, you can write this way more elegant, but we're keeping PHP 4 compatibility here)</p>
<pre>
$dispatcher =& $pipeline->get_dispatcher();
$dispatcher->add_observer('after-page', 'my_watermark_callback_func');
</pre>
<p>
A single parameter is passed to the callback function: an associative array containing information related to event.
</p>
<p>Following events are available:</p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Fired…</th>
<th>Event information</th>
</tr>
</thead>
<tbody>
<tr>
<td class="event-name">after-batch</td>
<td>after all documents in current batch were rendered</td>
<td>pipeline: reference to current pipeline object</td>
</tr>
<tr>
<td class="event-name">after-document</td>
<td>after all pages in a current document were rendered</td>
<td>pipeline: reference to current pipeline object; document: reference to the body box object</td>
</tr>
<tr>
<td class="event-name">after-page</td>
<td>after all elements were rendered on current page, but before new page is added.</td>
<td>pipeline: reference to current pipeline object; document: reference to the body box object; pageno: current page number (1-based)</td>
</tr>
<tr>
<td class="event-name">before-batch</td>
<td>before new document batch starts rendering</td>
<td>pipeline: reference to current pipeline object</td>
</tr>
<tr>
<td class="event-name">before-document</td>
<td>before new document in a batch starts rendering</td>
<td>pipeline: reference to current pipeline object; document: reference to the body box object</td>
</tr>
<tr>
<td class="event-name">before-page</td>
<td>after new blank page is added to the PDF document but before any elements are rendered</td>
<td>pipeline: reference to current pipeline object; document: reference to the body box object; pageno: current page number (1-based)</td>
</tr>
</tbody>
</table>
</body>
</html> |