/usr/share/doc/python-plastex-doc/html/sect0043.html is in python-plastex-doc 0.9.2-1.2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta name="generator" content="plasTeX" />
<meta content="text/html; charset=utf-8" http-equiv="content-type" />
<title>plasTeX — A Python Framework for Processing LaTeX Documents: Imager Objects</title>
<link href="sect0044.html" title="Image Objects" rel="next" />
<link href="module-plasTeX-Imagers.html" title="plasTeX.Imagers — The plasImaging Framework" rel="prev" />
<link href="module-plasTeX-Imagers.html" title="plasTeX.Imagers — The plasImaging Framework" rel="up" />
<link rel="stylesheet" href="styles/styles.css" />
</head>
<body>
<div class="navigation">
<table cellspacing="2" cellpadding="0" width="100%">
<tr>
<td><a href="module-plasTeX-Imagers.html" title="plasTeX.Imagers — The plasTeX Imaging Framework"><img alt="Previous: plasTeX.Imagers — The plasTeX Imaging Framework" border="0" src="icons/previous.gif" width="32" height="32" /></a></td>
<td><a href="module-plasTeX-Imagers.html" title="plasTeX.Imagers — The plasTeX Imaging Framework"><img alt="Up: plasTeX.Imagers — The plasTeX Imaging Framework" border="0" src="icons/up.gif" width="32" height="32" /></a></td>
<td><a href="sect0044.html" title="Image Objects"><img alt="Next: Image Objects" border="0" src="icons/next.gif" width="32" height="32" /></a></td>
<td class="navtitle" align="center">plasTeX — A Python Framework for Processing LaTeX Documents</td>
<td><a href="index.html" title="Table of Contents"><img border="0" alt="" src="icons/contents.gif" width="32" height="32" /></a></td>
<td><img border="0" alt="" src="icons/blank.gif" width="32" height="32" /></td>
<td><img border="0" alt="" src="icons/blank.gif" width="32" height="32" /></td>
</tr>
</table>
</div>
<div class="breadcrumbs">
<span>
<span>
<a href="index.html">plasTeX — A Python Framework for Processing LaTeX Documents</a> <b>:</b>
</span>
</span><span>
<span>
<a href="sect0024.html">plasT<sub style="text-transform:uppercase; margin-left:-0.2em">e</sub>X Frameworks and APIs</a> <b>:</b>
</span>
</span><span>
<span>
<a href="module-plasTeX-Imagers.html"><tt class="ttfamily">plasTeX.Imagers</tt> — The plasT<sub style="text-transform:uppercase; margin-left:-0.2em">e</sub>X Imaging Framework</a> <b>:</b>
</span>
</span><span>
<span>
<b class="current">Imager Objects</b>
</span>
</span>
<hr />
</div>
<div><h2 id="a0000000044">6.7.1 Imager Objects</h2>
<p> <dl class="description">
<dt></dt>
<dd></dd>
<dt></dt>
<dd></dd>
<dt></dt>
<dd></dd>
<dt><b class="bf">class </b><span class="rmfamily"><tt class="ttfamily"><b class="bfseries">Imager</b></tt></span><span class="rmfamily"><tt class="ttfamily">(</tt></span><span style="width:0.0pt" class="parbox"><span class="rmfamily"><i class="itshape">document</i></span><span class="rmfamily"><tt class="ttfamily">)</tt></span></span></dt>
<dd><p><a name="a0000000342" id="a0000000342"></a> Instantiate the imager class. </p><p><span class="rmfamily"><i class="itshape">document</i></span> the document object that is being rendered. </p><p>The <tt class="ttfamily">Imager</tt> class is responsible for creating a L<sup style="font-variant:small-caps; margin-left:-0.3em">a</sup>T<sub style="text-transform:uppercase; margin-left:-0.2em">e</sub>X document of requested images, compiling it, and generating images from each page in the document. </p></dd>
</dl> </p><p> <dl class="description">
<dt></dt>
<dd></dd>
<dt></dt>
<dd> </dd>
<dt><span class="rmfamily"><tt class="ttfamily"><b class="bfseries">command</b></tt></span></dt>
<dd><p><a name="a0000000343" id="a0000000343"></a> specifies the converter that translates the output from the L<sup style="font-variant:small-caps; margin-left:-0.3em">a</sup>T<sub style="text-transform:uppercase; margin-left:-0.2em">e</sub>X document compiler (e.g. PDF, DVI, PS) into images (e.g. PNG, JPEG, GIF). The only requirement is that the basename of each image is of the form ‘<span class="sffamily">img%d</span>’ where ‘<span class="sffamily">%d</span>’ is the number of the image. </p><p><b class="bf">Note:</b> This is a class attribute. </p><p>Writing a renderer requires you to at least override the command that creates images. It can be as simple as the example below. </p><pre>
import plasTeX.Imagers
class DVIPNG(plasTeX.Imagers.Imager):
""" Imager that uses dvipng """
command = 'dvipng -o img%d.png -D 110'
</pre></dd>
</dl> </p><p> <dl class="description">
<dt></dt>
<dd></dd>
<dt></dt>
<dd> </dd>
<dt><span class="rmfamily"><tt class="ttfamily"><b class="bfseries">compiler</b></tt></span></dt>
<dd><p><a name="a0000000344" id="a0000000344"></a> specifies the L<sup style="font-variant:small-caps; margin-left:-0.3em">a</sup>T<sub style="text-transform:uppercase; margin-left:-0.2em">e</sub>X document compiler (i.e. latex, pdflatex) command. </p><p><b class="bf">Note:</b> This is a class attribute. </p></dd>
</dl> </p><p> <dl class="description">
<dt></dt>
<dd></dd>
<dt></dt>
<dd> </dd>
<dt><span class="rmfamily"><tt class="ttfamily"><b class="bfseries">config</b></tt></span></dt>
<dd><p><a name="a0000000345" id="a0000000345"></a> contains the “images” section of the document configuration. </p></dd>
</dl> </p><p> <dl class="description">
<dt></dt>
<dd></dd>
<dt></dt>
<dd> </dd>
<dt><span class="rmfamily"><tt class="ttfamily"><b class="bfseries">fileExtension</b></tt></span></dt>
<dd><p><a name="a0000000346" id="a0000000346"></a> contains the file extension to use if no extension is supplied by the filename generator. </p></dd>
</dl> </p><p> <dl class="description">
<dt></dt>
<dd></dd>
<dt></dt>
<dd> </dd>
<dt><span class="rmfamily"><tt class="ttfamily"><b class="bfseries">imageAttrs</b></tt></span></dt>
<dd><p><a name="a0000000347" id="a0000000347"></a> contains a string template that will be used as a placeholder in the output document for the image height, width, and depth. These attributes cannot be determined in real-time because images are not generated until after the document has been fully rendered. This template generates a string that is put into the output document so that the image attributes can be post-processed in. For example, the default template (which is rather XML/HTML biased) is: </p><pre>
&${filename}-${attr};
</pre><p> The two variables available are <span class="rmfamily"><i class="itshape">filename</i></span>, the filename of the image, and <span class="rmfamily"><i class="itshape">attr</i></span>, the name of the attr (i.e. width, height, or depth). </p></dd>
</dl> </p><p> <dl class="description">
<dt></dt>
<dd></dd>
<dt></dt>
<dd> </dd>
<dt><span class="rmfamily"><tt class="ttfamily"><b class="bfseries">imageUnits</b></tt></span></dt>
<dd><p><a name="a0000000348" id="a0000000348"></a> contains a string template that will be used as a placeholder in the output document for the image units. This template generates a string that is put into the output document so that the image attribute units can be post-processed in. For example, the default template (which is rather XML/HTML biased) is: </p><pre>
&${units);
</pre><p> The only variable available is <span class="rmfamily"><i class="itshape">units</i></span> and contains the CSS unit that was requested. The generate string will always occur immediately after the string generated by <tt class="ttfamily">imageAttrs</tt>. </p></dd>
</dl> </p><p> <dl class="description">
<dt></dt>
<dd></dd>
<dt></dt>
<dd> </dd>
<dt><span class="rmfamily"><tt class="ttfamily"><b class="bfseries">images</b></tt></span></dt>
<dd><p><a name="a0000000349" id="a0000000349"></a> dictionary that contains the <tt class="ttfamily">Image</tt> objects corresponding to the requested images. The keys are the image filenames. </p></dd>
</dl> </p><p> <dl class="description">
<dt></dt>
<dd></dd>
<dt></dt>
<dd> </dd>
<dt><span class="rmfamily"><tt class="ttfamily"><b class="bfseries">newFilename</b></tt></span></dt>
<dd><p><a name="a0000000350" id="a0000000350"></a> callable iterator that generates filenames according to the filename template in the configuration. </p></dd>
</dl> </p><p> <dl class="description">
<dt></dt>
<dd></dd>
<dt></dt>
<dd> </dd>
<dt><span class="rmfamily"><tt class="ttfamily"><b class="bfseries">source</b></tt></span></dt>
<dd><p><a name="a0000000351" id="a0000000351"></a> file object where the image L<sup style="font-variant:small-caps; margin-left:-0.3em">a</sup>T<sub style="text-transform:uppercase; margin-left:-0.2em">e</sub>X document is written to. </p></dd>
</dl> </p><p> <dl class="description">
<dt></dt>
<dd></dd>
<dt></dt>
<dd> </dd>
<dt><span class="rmfamily"><tt class="ttfamily"><b class="bfseries">verification</b></tt></span></dt>
<dd><p><a name="a0000000352" id="a0000000352"></a> command that verifies the existence of the image converter on the current machine. If <tt class="ttfamily">verification</tt> is not specified, the executable specified in <tt class="ttfamily">command</tt> is executed with the <b class="bf">--help</b>. If the return code is zero, the imager is considered valid. If the return code is anything else, the imager is not considered valid. </p></dd>
</dl> </p><p> <dl class="description">
<dt></dt>
<dd></dd>
<dt></dt>
<dd> </dd>
<dt></dt>
<dd></dd>
<dt></dt>
<dd></dd>
<dt></dt>
<dd></dd>
<dt><span class="rmfamily"><tt class="ttfamily"><b class="bfseries">close</b></tt></span><span class="rmfamily"><tt class="ttfamily">(</tt></span><span style="width:0.0pt" class="parbox"><span class="rmfamily"><i class="itshape"></i></span><span class="rmfamily"><tt class="ttfamily">)</tt></span></span></dt>
<dd><p><a name="a0000000353" id="a0000000353"></a> closes the generated L<sup style="font-variant:small-caps; margin-left:-0.3em">a</sup>T<sub style="text-transform:uppercase; margin-left:-0.2em">e</sub>X document and starts the image generation routine. </p></dd>
</dl> </p><p> <dl class="description">
<dt></dt>
<dd></dd>
<dt></dt>
<dd> </dd>
<dt></dt>
<dd></dd>
<dt></dt>
<dd></dd>
<dt></dt>
<dd></dd>
<dt><span class="rmfamily"><tt class="ttfamily"><b class="bfseries">compileLatex</b></tt></span><span class="rmfamily"><tt class="ttfamily">(</tt></span><span style="width:0.0pt" class="parbox"><span class="rmfamily"><i class="itshape">source</i></span><span class="rmfamily"><tt class="ttfamily">)</tt></span></span></dt>
<dd><p><a name="a0000000354" id="a0000000354"></a> the method responsible for compiling the L<sup style="font-variant:small-caps; margin-left:-0.3em">a</sup>T<sub style="text-transform:uppercase; margin-left:-0.2em">e</sub>X source. </p><p><span class="rmfamily"><i class="itshape">source</i></span> is a file object containing the L<sup style="font-variant:small-caps; margin-left:-0.3em">a</sup>T<sub style="text-transform:uppercase; margin-left:-0.2em">e</sub>X document. </p></dd>
</dl> </p><p> <dl class="description">
<dt></dt>
<dd></dd>
<dt></dt>
<dd> </dd>
<dt></dt>
<dd></dd>
<dt></dt>
<dd></dd>
<dt></dt>
<dd></dd>
<dt><span class="rmfamily"><tt class="ttfamily"><b class="bfseries">convert</b></tt></span><span class="rmfamily"><tt class="ttfamily">(</tt></span><span style="width:0.0pt" class="parbox"><span class="rmfamily"><i class="itshape">output</i></span><span class="rmfamily"><tt class="ttfamily">)</tt></span></span></dt>
<dd><p><a name="a0000000355" id="a0000000355"></a> sets up the temporary environment for the image converter, then executes <tt class="ttfamily">executeConverter</tt>. It also moves the generated images into their final location specified in the configuration. </p></dd>
</dl> </p><p> <dl class="description">
<dt></dt>
<dd></dd>
<dt></dt>
<dd> </dd>
<dt></dt>
<dd></dd>
<dt></dt>
<dd></dd>
<dt></dt>
<dd></dd>
<dt><span class="rmfamily"><tt class="ttfamily"><b class="bfseries">executeConverter</b></tt></span><span class="rmfamily"><tt class="ttfamily">(</tt></span><span style="width:0.0pt" class="parbox"><span class="rmfamily"><i class="itshape">output</i></span><span class="rmfamily"><tt class="ttfamily">)</tt></span></span></dt>
<dd><p><a name="a0000000356" id="a0000000356"></a> executes the command that converts the output from the L<sup style="font-variant:small-caps; margin-left:-0.3em">a</sup>T<sub style="text-transform:uppercase; margin-left:-0.2em">e</sub>X compiler into image files. </p><p><span class="rmfamily"><i class="itshape">output</i></span> is a file object containing the compiled output of the L<sup style="font-variant:small-caps; margin-left:-0.3em">a</sup>T<sub style="text-transform:uppercase; margin-left:-0.2em">e</sub>X document. </p></dd>
</dl> </p><p> <dl class="description">
<dt></dt>
<dd></dd>
<dt></dt>
<dd> </dd>
<dt></dt>
<dd></dd>
<dt></dt>
<dd></dd>
<dt></dt>
<dd></dd>
<dt><span class="rmfamily"><tt class="ttfamily"><b class="bfseries">getImage</b></tt></span><span class="rmfamily"><tt class="ttfamily">(</tt></span><span style="width:0.0pt" class="parbox"><span class="rmfamily"><i class="itshape">node</i></span><span class="rmfamily"><tt class="ttfamily">)</tt></span></span></dt>
<dd><p><a name="a0000000357" id="a0000000357"></a> get an image for <span class="rmfamily"><i class="itshape">node</i></span> in any way possible. The node is first checked to see if the <tt class="ttfamily">imageoverride</tt> attribute is set. If it is, that image is copied to the image directory. If <tt class="ttfamily">imageoverride</tt> is not set, or there was a problem in saving the image in the correct format, an image is generated using the source of <span class="rmfamily"><i class="itshape">node</i></span>. </p></dd>
</dl> </p><p> <dl class="description">
<dt></dt>
<dd></dd>
<dt></dt>
<dd> </dd>
<dt></dt>
<dd></dd>
<dt></dt>
<dd></dd>
<dt></dt>
<dd></dd>
<dt><span class="rmfamily"><tt class="ttfamily"><b class="bfseries">newImage</b></tt></span><span class="rmfamily"><tt class="ttfamily">(</tt></span><span style="width:0.0pt" class="parbox"><span class="rmfamily"><i class="itshape">text, <span class="textnormal"><big class="xlarge">[</big></span>context, filename<span class="textnormal"><big class="xlarge">]</big></span></i></span><span class="rmfamily"><tt class="ttfamily">)</tt></span></span></dt>
<dd><p><a name="a0000000358" id="a0000000358"></a> invokes the creation of an image using the L<sup style="font-variant:small-caps; margin-left:-0.3em">a</sup>T<sub style="text-transform:uppercase; margin-left:-0.2em">e</sub>X content in <span class="rmfamily"><i class="itshape">text</i></span>. </p><p><span class="rmfamily"><i class="itshape">context</i></span> is the L<sup style="font-variant:small-caps; margin-left:-0.3em">a</sup>T<sub style="text-transform:uppercase; margin-left:-0.2em">e</sub>X code that sets up the context of the document. This generally includes the setting of counters so that counters used within the image code are correct. </p><p><span class="rmfamily"><i class="itshape">filename</i></span> is an optional filename for the output image. Generally, image filenames are generated automatically, but they can be overridden with this argument. </p></dd>
</dl> </p><p> <dl class="description">
<dt></dt>
<dd></dd>
<dt></dt>
<dd> </dd>
<dt></dt>
<dd></dd>
<dt></dt>
<dd></dd>
<dt></dt>
<dd></dd>
<dt><span class="rmfamily"><tt class="ttfamily"><b class="bfseries">verify</b></tt></span><span class="rmfamily"><tt class="ttfamily">(</tt></span><span style="width:0.0pt" class="parbox"><span class="rmfamily"><i class="itshape"></i></span><span class="rmfamily"><tt class="ttfamily">)</tt></span></span></dt>
<dd><p><a name="a0000000359" id="a0000000359"></a> verifies that the command in <tt class="ttfamily">command</tt> is valid for the current machine. The <tt class="ttfamily">verify</tt> method returns <span class="rmfamily"><i class="itshape">True</i></span> if the command will work, or <span class="rmfamily"><i class="itshape">False</i></span> if it will not. </p></dd>
</dl> </p><p> <dl class="description">
<dt></dt>
<dd></dd>
<dt></dt>
<dd> </dd>
<dt></dt>
<dd></dd>
<dt></dt>
<dd></dd>
<dt></dt>
<dd></dd>
<dt><span class="rmfamily"><tt class="ttfamily"><b class="bfseries">writeImage</b></tt></span><span class="rmfamily"><tt class="ttfamily">(</tt></span><span style="width:0.0pt" class="parbox"><span class="rmfamily"><i class="itshape">filename, code, context</i></span><span class="rmfamily"><tt class="ttfamily">)</tt></span></span></dt>
<dd><p><a name="a0000000360" id="a0000000360"></a> writes the L<sup style="font-variant:small-caps; margin-left:-0.3em">a</sup>T<sub style="text-transform:uppercase; margin-left:-0.2em">e</sub>X code to the generated document that creates the image content. </p><p><span class="rmfamily"><i class="itshape">filename</i></span> is the final filename of the image. This is not actually used in the document, but can be handy for debugging. </p><p><span class="rmfamily"><i class="itshape">code</i></span> is the L<sup style="font-variant:small-caps; margin-left:-0.3em">a</sup>T<sub style="text-transform:uppercase; margin-left:-0.2em">e</sub>X code that an image is needed of. </p><p><span class="rmfamily"><i class="itshape">context</i></span> is the L<sup style="font-variant:small-caps; margin-left:-0.3em">a</sup>T<sub style="text-transform:uppercase; margin-left:-0.2em">e</sub>X code that sets up the context of the document. This generally includes the setting of counters so that counters used within the image code are correct. </p></dd>
</dl> </p><p> <dl class="description">
<dt></dt>
<dd></dd>
<dt></dt>
<dd> </dd>
<dt></dt>
<dd></dd>
<dt></dt>
<dd></dd>
<dt></dt>
<dd></dd>
<dt><span class="rmfamily"><tt class="ttfamily"><b class="bfseries">writePreamble</b></tt></span><span class="rmfamily"><tt class="ttfamily">(</tt></span><span style="width:0.0pt" class="parbox"><span class="rmfamily"><i class="itshape">document</i></span><span class="rmfamily"><tt class="ttfamily">)</tt></span></span></dt>
<dd><p><a name="a0000000361" id="a0000000361"></a> this method is called when the imager is instantiated and is used to write any extra information to the preamble. If overridden, the subclass needs to make sure that <span class="rmfamily"><i class="itshape">document.preamble.source</i></span> is the first thing written to the preamble. </p></dd>
</dl> </p></div>
<div class="navigation">
<table cellspacing="2" cellpadding="0" width="100%">
<tr>
<td><a href="module-plasTeX-Imagers.html" title="plasTeX.Imagers — The plasTeX Imaging Framework"><img alt="Previous: plasTeX.Imagers — The plasTeX Imaging Framework" border="0" src="icons/previous.gif" width="32" height="32" /></a></td>
<td><a href="module-plasTeX-Imagers.html" title="plasTeX.Imagers — The plasTeX Imaging Framework"><img alt="Up: plasTeX.Imagers — The plasTeX Imaging Framework" border="0" src="icons/up.gif" width="32" height="32" /></a></td>
<td><a href="sect0044.html" title="Image Objects"><img alt="Next: Image Objects" border="0" src="icons/next.gif" width="32" height="32" /></a></td>
<td class="navtitle" align="center">plasTeX — A Python Framework for Processing LaTeX Documents</td>
<td><a href="index.html" title="Table of Contents"><img border="0" alt="" src="icons/contents.gif" width="32" height="32" /></a></td>
<td><img border="0" alt="" src="icons/blank.gif" width="32" height="32" /></td>
<td><img border="0" alt="" src="icons/blank.gif" width="32" height="32" /></td>
</tr>
</table>
</div>
<script language="javascript" src="icons/imgadjust.js" type="text/javascript"></script>
</body>
</html>
|