| 1 |
<?xml version="1.0"?> |
| 2 |
|
| 3 |
<!-- |
| 4 |
|
| 5 |
Licensed to the Apache Software Foundation (ASF) under one or more |
| 6 |
contributor license agreements. See the NOTICE file distributed with |
| 7 |
this work for additional information regarding copyright ownership. |
| 8 |
The ASF licenses this file to You under the Apache License, Version 2.0 |
| 9 |
(the "License"); you may not use this file except in compliance with |
| 10 |
the License. You may obtain a copy of the License at |
| 11 |
|
| 12 |
http://www.apache.org/licenses/LICENSE-2.0 |
| 13 |
|
| 14 |
Unless required by applicable law or agreed to in writing, software |
| 15 |
distributed under the License is distributed on an "AS IS" BASIS, |
| 16 |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 |
See the License for the specific language governing permissions and |
| 18 |
limitations under the License. |
| 19 |
|
| 20 |
--> |
| 21 |
|
| 22 |
<!-- ========================================================================= --> |
| 23 |
<!-- author [email protected] --> |
| 24 |
<!-- version $Id$ --> |
| 25 |
<!-- ========================================================================= --> |
| 26 |
|
| 27 |
<!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V2.0//EN" "http://forrest.apache.org/dtd/document-v20.dtd"> |
| 28 |
<document> |
| 29 |
<header> |
| 30 |
<title>SVG Rasterizer</title> |
| 31 |
</header> |
| 32 |
|
| 33 |
<body> |
| 34 |
<p> |
| 35 |
This page describes the features of the SVG Rasterizer utility that |
| 36 |
comes with the Batik distribution. The SVG Rasterizer is a utility that |
| 37 |
can convert SVG files to a raster format. The tool can convert individual |
| 38 |
files or sets of files, making it easy to convert entire directories of |
| 39 |
SVG files. The provided formats are |
| 40 |
<abbr title="Joint Photography Expert Group">JPEG</abbr>, |
| 41 |
<abbr title="Portable Network Graphics">PNG</abbr> and |
| 42 |
<abbr title="Tagged Image File Format">TIFF</abbr>, however the design |
| 43 |
allows new formats to be added easily. In addition, the rasterizer can |
| 44 |
(despite its name) transcode to |
| 45 |
<abbr title="Portable Document Format">PDF</abbr>. |
| 46 |
</p> |
| 47 |
|
| 48 |
<section id="downloading"> |
| 49 |
<title>Downloading the rasterizer</title> |
| 50 |
|
| 51 |
<p> |
| 52 |
Refer to the <a href="site:install">install page</a> and |
| 53 |
the <a href="site:download">download area</a> to find out what to |
| 54 |
download and how to install it. Remember that you can get either the |
| 55 |
source or binary distribution. |
| 56 |
</p> |
| 57 |
</section> |
| 58 |
|
| 59 |
<section id="using"> |
| 60 |
<title>Rasterizing one or several SVG files</title> |
| 61 |
<p> |
| 62 |
The method for starting the rasterizer depends on the distribution of Batik |
| 63 |
that you chose to download. The following describes how to start the viewer |
| 64 |
for each distribution. |
| 65 |
</p> |
| 66 |
|
| 67 |
<section id="using-binary"> |
| 68 |
<title>Using the binary distribution</title> |
| 69 |
|
| 70 |
<p> |
| 71 |
If you downloaded the binary distribution of Batik, you should have |
| 72 |
a file called <code>batik-1.6.zip</code> (or similar), and, after |
| 73 |
expanding that file, a jar file called |
| 74 |
<code>batik-rasterizer.jar</code>. To start the rasterizer, open a |
| 75 |
console, go to the directory where you expanded the distribution (and |
| 76 |
where <code>batik-rasterizer.jar</code> is located) and simply type |
| 77 |
the following at the command prompt: |
| 78 |
</p> |
| 79 |
<source>java -jar batik-rasterizer.jar <em>FILES</em></source> |
| 80 |
<p> |
| 81 |
For example, if you type: |
| 82 |
</p> |
| 83 |
<source>java -jar batik-rasterizer.jar samples/batikFX.svg</source> |
| 84 |
<p> |
| 85 |
you will see the following printout: |
| 86 |
</p> |
| 87 |
<source>Converting file: samples/BatikFX.svg to samples/BatikFX.png</source> |
| 88 |
<p> |
| 89 |
Once the conversion is complete, you will find a |
| 90 |
<code>batikFX.png</code> file in the samples directory. |
| 91 |
</p> |
| 92 |
<p> |
| 93 |
You can pass options on the command line: |
| 94 |
</p> |
| 95 |
<source>java -jar batik-rasterizer.jar <em>[OPTIONS] FILES</em></source> |
| 96 |
<p> |
| 97 |
where, as options: |
| 98 |
</p> |
| 99 |
<dl class="options"> |
| 100 |
<dt><strong>-d</strong> <em>dir|file</em></dt> |
| 101 |
<dd> |
| 102 |
<p> |
| 103 |
specifies the output directory, or the output file if there is |
| 104 |
only a single input file, |
| 105 |
</p> |
| 106 |
</dd> |
| 107 |
<dt><strong>-m</strong> <em>mime-type</em></dt> |
| 108 |
<dd> |
| 109 |
<p> |
| 110 |
specifies the output MIME type, which should be one of |
| 111 |
<code>image/png</code>, <code>image/jpeg</code>, |
| 112 |
<code>image/tiff</code> or <code>application/pdf</code>, |
| 113 |
</p> |
| 114 |
</dd> |
| 115 |
<dt><strong>-w</strong> <em>width</em></dt> |
| 116 |
<dd> |
| 117 |
<p> |
| 118 |
specifies the output width as a floating point value, |
| 119 |
</p> |
| 120 |
</dd> |
| 121 |
<dt><strong>-h</strong> <em>height</em></dt> |
| 122 |
<dd> |
| 123 |
<p> |
| 124 |
specifies the output height as a floating point value, |
| 125 |
</p> |
| 126 |
</dd> |
| 127 |
<dt><strong>-maxw</strong> <em>width</em></dt> |
| 128 |
<dd> |
| 129 |
<p> |
| 130 |
specifies the maximum output width as a floating point value, |
| 131 |
</p> |
| 132 |
</dd> |
| 133 |
<dt><strong>-maxh</strong> <em>height</em></dt> |
| 134 |
<dd> |
| 135 |
<p> |
| 136 |
specifies the maximum output height as a floating point value, |
| 137 |
</p> |
| 138 |
</dd> |
| 139 |
<dt><strong>-a</strong> <em>x</em><strong>,</strong><em>y</em><strong>,</strong><em>width</em><strong>,</strong><em>height</em></dt> |
| 140 |
<dd> |
| 141 |
<p>specifies the area of interest (as floating point values) of the |
| 142 |
SVG file to rasterize (and if not specified, will be determined |
| 143 |
by the <code>width</code>/<code>height</code>/<code>viewBox</code> |
| 144 |
attributes if specified in the document, and be 0,0,400,400 otherwise),</p> |
| 145 |
</dd> |
| 146 |
<dt><strong>-bg</strong> <em>alpha</em><strong>.</strong><em>red</em><strong>.</strong><em>green</em><strong>.</strong><em>blue</em></dt> |
| 147 |
<dd> |
| 148 |
<p>specifies the background fill color as an ARGB quadruple, where |
| 149 |
each component is an integer in the range 0—255,</p> |
| 150 |
</dd> |
| 151 |
<dt><strong>-cssMedia</strong> <em>media</em></dt> |
| 152 |
<dd> |
| 153 |
<p>specifies the CSS media type used for matching CSS rules,</p> |
| 154 |
</dd> |
| 155 |
<dt><strong>-cssAlternate</strong> <em>file|uri</em></dt> |
| 156 |
<dd> |
| 157 |
<p>specifies the CSS alternate stylesheet to use,</p> |
| 158 |
</dd> |
| 159 |
<dt><strong>-cssUser</strong> <em>file|uri</em></dt> |
| 160 |
<dd> |
| 161 |
<p>specifies the CSS user stylesheet to use in addition to any |
| 162 |
other referenced or embedded stylesheets,</p> |
| 163 |
</dd> |
| 164 |
<dt><strong>-font-family</strong> <em>defaultFontFamily</em></dt> |
| 165 |
<dd> |
| 166 |
<p>specifies default font family to be used when none is specified,</p> |
| 167 |
</dd> |
| 168 |
<dt><strong>-lang</strong> <em>language-code</em></dt> |
| 169 |
<dd> |
| 170 |
<p>specifies the |
| 171 |
<a href="http://www.faqs.org/rfcs/rfc3066.html">RFC 3066</a> |
| 172 |
language code to use,</p> |
| 173 |
</dd> |
| 174 |
<dt><strong>-q</strong> <em>quality</em></dt> |
| 175 |
<dd> |
| 176 |
<p>specifies the quality of the output image, as a floating point |
| 177 |
number in the range 0 < <em>quality</em> < 1 when generating |
| 178 |
JPEG images,</p> |
| 179 |
</dd> |
| 180 |
<dt><strong>-indexed</strong> <em>1|2|4|8</em></dt> |
| 181 |
<dd> |
| 182 |
<p>specifies the number of bits per pixel of the output image, |
| 183 |
using an adaptive pallete, resulting in an indexed image when |
| 184 |
generating PNG images,</p> |
| 185 |
</dd> |
| 186 |
<dt><strong>-dpi</strong> <em>resolution</em></dt> |
| 187 |
<dd> |
| 188 |
<p>specifies the resolution of the output image in dots per inch,</p> |
| 189 |
</dd> |
| 190 |
<dt><strong>-validate</strong></dt> |
| 191 |
<dd> |
| 192 |
<p>specifies that the source SVG files must be validated against |
| 193 |
their DTDs,</p> |
| 194 |
</dd> |
| 195 |
<dt><strong>-onload</strong></dt> |
| 196 |
<dd> |
| 197 |
<p>specifies that the SVG files should be rasterized after |
| 198 |
dispatching the SVG load event,</p> |
| 199 |
</dd> |
| 200 |
<dt><strong>-snapshotTime</strong></dt> |
| 201 |
<dd> |
| 202 |
<p>specifies the document time that should be seeked to before |
| 203 |
rasterizing the document, implying -onload,</p> |
| 204 |
</dd> |
| 205 |
<dt><strong>-scriptSecurityOff</strong></dt> |
| 206 |
<dd> |
| 207 |
<p>specifies that any security checks on the scripts running as a |
| 208 |
result of dispatching the SVG load event will be bypassed,</p> |
| 209 |
</dd> |
| 210 |
<dt><strong>-anyScriptOrigin</strong></dt> |
| 211 |
<dd> |
| 212 |
<p>specifies that scripts can be loaded from any location, while by |
| 213 |
default they can only be loaded from the same location as the document, and</p> |
| 214 |
</dd> |
| 215 |
<dt><strong>-scripts</strong> <em>allowed-script-types</em></dt> |
| 216 |
<dd> |
| 217 |
<p>specifies a list of script types (i.e., values for the |
| 218 |
<code>type</code> attribute on <code>script</code> elements) |
| 219 |
that should be loaded.</p> |
| 220 |
</dd> |
| 221 |
</dl> |
| 222 |
|
| 223 |
<p> |
| 224 |
For example: |
| 225 |
</p> |
| 226 |
<source>java -jar batik-rasterizer.jar -d myDir -m image/jpeg samples/*.svg</source> |
| 227 |
<p> |
| 228 |
will generate JPEG images for all the SVG files found in the samples |
| 229 |
directory. |
| 230 |
</p> |
| 231 |
</section> |
| 232 |
|
| 233 |
<section id="usingSource"> |
| 234 |
<title>Using the source distribution</title> |
| 235 |
|
| 236 |
<p> |
| 237 |
If you downloaded the source distribution of Batik, you got a zip or |
| 238 |
tar file that expanded into a directory called <code>xml-batik</code> |
| 239 |
or <code>batik-<em>version</em></code>. In that directory, you can |
| 240 |
find build scripts for the platform you are running on. For example, |
| 241 |
there is a <code>build.bat</code> script for users of the Windows |
| 242 |
platform and there is a <code>build.sh</code> script for UNIX users. |
| 243 |
</p> |
| 244 |
<p> |
| 245 |
To start the rasterizer you should: |
| 246 |
</p> |
| 247 |
<ul> |
| 248 |
<li> |
| 249 |
Make sure that your <code>JAVA_HOME</code> environment variable is |
| 250 |
set to your JDK installation directory. |
| 251 |
</li> |
| 252 |
<li> |
| 253 |
Open a command line window and go to the <code>xml-batik</code> |
| 254 |
or <code>batik-<em>version</em></code> directory where the Batik |
| 255 |
distribution was expanded. |
| 256 |
</li> |
| 257 |
<li> |
| 258 |
<p>For Windows, type the following at the command prompt:</p> |
| 259 |
<source>build svgrasterizer</source> |
| 260 |
<p>and for Unix:</p> |
| 261 |
<source>./build.sh svgrasterizer</source> |
| 262 |
<p>This will print out a help message for the rasterizer.</p> |
| 263 |
</li> |
| 264 |
</ul> |
| 265 |
<p> |
| 266 |
You can pass options to the rasterizer as follows, for Windows: |
| 267 |
</p> |
| 268 |
<source>build svgrasterizer <em>[OPTIONS] FILES</em></source> |
| 269 |
<p> |
| 270 |
and for Unix: |
| 271 |
</p> |
| 272 |
<source>./build.sh svgrasterizer <em>[OPTIONS] FILES</em></source> |
| 273 |
<p> |
| 274 |
Refer to <a href="#using-binary">“Using the binary distribution”</a> |
| 275 |
for an explanation of the options. |
| 276 |
</p> |
| 277 |
</section> |
| 278 |
|
| 279 |
</section> |
| 280 |
|
| 281 |
<section id="task"> |
| 282 |
<title>Rasterizer Ant task</title> |
| 283 |
<p> |
| 284 |
The Rasterizer task is an <a href="http://ant.apache.org/">Ant</a> |
| 285 |
version of the rasterizer utility. It fulfills the same basic |
| 286 |
purpose as the utility but has a different syntax and a |
| 287 |
slightly different set of features. |
| 288 |
</p> |
| 289 |
|
| 290 |
<p> |
| 291 |
The task is able to produce four raster formats: |
| 292 |
<abbr title="Portable Network Graphics">PNG</abbr>, |
| 293 |
<abbr title="Joint Photographic Expert Group">JPEG</abbr>, |
| 294 |
<abbr title="Tagged Image File Format">TIFF</abbr> and |
| 295 |
<abbr title="Portable Document Format">PDF</abbr>. |
| 296 |
</p> |
| 297 |
|
| 298 |
<section id="initTask"> |
| 299 |
<title>Using the rasterizer task</title> |
| 300 |
|
| 301 |
<p> |
| 302 |
The first thing to do is to compile rasterizer task classes. |
| 303 |
Download the source distribution of Batik and see the |
| 304 |
<code>README</code> file in the |
| 305 |
<code>contrib/rasterizertask</code> directory for more |
| 306 |
instructions. The build procedure works the same way as when building |
| 307 |
Batik itself. |
| 308 |
</p> |
| 309 |
|
| 310 |
<p> |
| 311 |
After building, ensure that the generated |
| 312 |
<code>batik-rasterizer.jar</code> and the classes (or jar file) of the |
| 313 |
rasterizer task are in your <code>CLASSPATH</code>. |
| 314 |
</p> |
| 315 |
|
| 316 |
<p> |
| 317 |
Next you have to define the task in your Ant project. To do this, add |
| 318 |
the following line either after the <code>project</code> start tag or |
| 319 |
after the <code>target</code> start tag in the target you are using |
| 320 |
the rasterizer task: |
| 321 |
</p> |
| 322 |
|
| 323 |
<source> <taskdef name="rasterize" |
| 324 |
classname="org.apache.tools.ant.taskdefs.optional.RasterizerTask"/></source> |
| 325 |
|
| 326 |
<p> |
| 327 |
Now you can use the rasterizer task in your project. See the |
| 328 |
<a href="#taskParameters">parameters section</a> for an explanation of |
| 329 |
the available parameters or the |
| 330 |
<a href="#taskExamples">examples section</a> to see few usage examples. |
| 331 |
</p> |
| 332 |
</section> |
| 333 |
|
| 334 |
<section id="taskParameters"> |
| 335 |
<title>Parameters of the Ant task</title> |
| 336 |
<p> |
| 337 |
The following table lists the attributes that may be specified on |
| 338 |
the <code>rasterize</code> task element. |
| 339 |
</p> |
| 340 |
<table> |
| 341 |
<tr> |
| 342 |
<th>Attribute</th> |
| 343 |
<th>Description</th> |
| 344 |
<th>Required</th> |
| 345 |
</tr> |
| 346 |
<tr> |
| 347 |
<td>result</td> |
| 348 |
<td> |
| 349 |
Sets the type of the result image. Only one of the |
| 350 |
following values must be used: <code>image/png</code>, |
| 351 |
<code>image/jpeg</code>, <code>image/tiff</code> and |
| 352 |
<code>application/pdf</code>. The value must be in |
| 353 |
lowercase letters. |
| 354 |
</td> |
| 355 |
<td>Yes</td> |
| 356 |
</tr> |
| 357 |
<tr> |
| 358 |
<td>height</td> |
| 359 |
<td> |
| 360 |
Sets the height of the result image in pixels. The task |
| 361 |
calculates the height from the SVG file if this parameter has not |
| 362 |
been set. The rasterizer keeps the aspect ratio of the SVG file |
| 363 |
even if the both <code>height</code> and <code>width</code> have |
| 364 |
been set. |
| 365 |
</td> |
| 366 |
<td>No</td> |
| 367 |
</tr> |
| 368 |
<tr> |
| 369 |
<td>width</td> |
| 370 |
<td> |
| 371 |
Sets the width of the result image in pixels. The task calculates |
| 372 |
the width from the SVG file if this parameter has not been set. |
| 373 |
The rasterizer keeps the aspect ratio of the SVG file even if the |
| 374 |
both <code>height</code> and <code>width</code> have been set. |
| 375 |
</td> |
| 376 |
<td>No</td> |
| 377 |
</tr> |
| 378 |
<tr> |
| 379 |
<td>maxheight</td> |
| 380 |
<td> |
| 381 |
Sets the maximum height of the result image in pixels. The image |
| 382 |
won’t be higher than defined in this parameter, regardless of the |
| 383 |
size set in the image itself or in other parameters. This is a |
| 384 |
floating point value. |
| 385 |
</td> |
| 386 |
<td>No</td> |
| 387 |
</tr> |
| 388 |
<tr> |
| 389 |
<td>maxwidth</td> |
| 390 |
<td> |
| 391 |
Sets the maximum width of the result image in pixels. The image |
| 392 |
won’t be wider than defined in this parameter, regardless of the |
| 393 |
size set in the image itself or in other parameters. This is a |
| 394 |
floating point value. |
| 395 |
</td> |
| 396 |
<td>No</td> |
| 397 |
</tr> |
| 398 |
<tr> |
| 399 |
<td>quality</td> |
| 400 |
<td> |
| 401 |
Sets the quality of the produced image. The value must be |
| 402 |
greater than 0 but smaller than 1, larger numbers meaning higher |
| 403 |
quality. The quality value is used only with JPEG images. |
| 404 |
The default quality value is 0.99. |
| 405 |
</td> |
| 406 |
<td>No</td> |
| 407 |
</tr> |
| 408 |
<tr> |
| 409 |
<td>area</td> |
| 410 |
<td> |
| 411 |
Defines the area in the SVG file which will be rasterized. Parts |
| 412 |
outside this area are discarded and don’t show in the result |
| 413 |
image. The area attribute value has four integers separated by |
| 414 |
commas. The first two integers set the x and y coordinates of |
| 415 |
the upper left corner of the area, respectively. The last two |
| 416 |
integers set the width and height of the area, respectively. For |
| 417 |
example, <code>10, 20, 100, 200</code> sets the |
| 418 |
rectangular area from point <code>10, 10</code> to point |
| 419 |
<code>110, 220</code>. The specified area is applied to all |
| 420 |
images if more than one file is rasterized during one task. |
| 421 |
</td> |
| 422 |
<td>No</td> |
| 423 |
</tr> |
| 424 |
<tr> |
| 425 |
<td>bg</td> |
| 426 |
<td> |
| 427 |
Sets the background color of the result image. The |
| 428 |
<code>bg</code> attribute value is either three or four integers |
| 429 |
separated with commas. The four values are alpha channel, red, |
| 430 |
green, and blue, respectively. If only three values are given, |
| 431 |
then the values are red, green, and blue and the alpha channel |
| 432 |
is automatically set to 255 (opaque). All values have to between |
| 433 |
0 and 255. The default value is none which means that background |
| 434 |
is transparent and not filled with any color. |
| 435 |
</td> |
| 436 |
<td>No</td> |
| 437 |
</tr> |
| 438 |
<tr> |
| 439 |
<td>media</td> |
| 440 |
<td> |
| 441 |
CSS media type that is used to select a CSS stylesheet. The |
| 442 |
selected stylesheet is then used to rasterize the SVG files. Only |
| 443 |
the visual media group is supported (see the |
| 444 |
<a href="site:css2">CSS2 specification</a> for more information |
| 445 |
about media groups). The default value is <code>screen</code>. |
| 446 |
</td> |
| 447 |
<td>No</td> |
| 448 |
</tr> |
| 449 |
<tr> |
| 450 |
<td>dpi</td> |
| 451 |
<td> |
| 452 |
Resolution for the result image. The attribute value is used to |
| 453 |
compute the “pixel to millimeter” ratio used when processing SVG |
| 454 |
files. The default value is 96. |
| 455 |
</td> |
| 456 |
<td>No</td> |
| 457 |
</tr> |
| 458 |
<tr> |
| 459 |
<td>lang</td> |
| 460 |
<td> |
| 461 |
Language which is used select language specific areas from the |
| 462 |
SVG file during the rasterizing process. The valid values are |
| 463 |
defined in |
| 464 |
<a href="http://www.faqs.org/rfcs/rfc3066.html">RFC3066</a>. The |
| 465 |
default value is <code>en</code>. |
| 466 |
</td> |
| 467 |
<td>No</td> |
| 468 |
</tr> |
| 469 |
<tr> |
| 470 |
<td>src</td> |
| 471 |
<td> |
| 472 |
Name of a one input file. Use this parameter to convert just one |
| 473 |
file whose name and location are known. The <code>dest</code> |
| 474 |
parameter must also be given. |
| 475 |
</td> |
| 476 |
<td> |
| 477 |
One of the following is required: <code>src</code> attribute, |
| 478 |
<code>srcdir</code> attribute or <code>fileset</code> element(s). |
| 479 |
</td> |
| 480 |
</tr> |
| 481 |
<tr> |
| 482 |
<td>dest</td> |
| 483 |
<td> |
| 484 |
Name of a one output file. Used this with <code>src</code> |
| 485 |
parameter only. The output directory is created if it doesn’t |
| 486 |
exist. |
| 487 |
</td> |
| 488 |
<td>Required if <code>src</code> is used.</td> |
| 489 |
</tr> |
| 490 |
<tr> |
| 491 |
<td>srcdir</td> |
| 492 |
<td> |
| 493 |
Name of the input directory. <code>srcdir</code> and |
| 494 |
<code>fileset</code> elements can be combined and |
| 495 |
<code>srcdir</code> can be omitted if there is at least one |
| 496 |
<code>fileset</code> child element. <code>srcdir</code> file |
| 497 |
selection can be controlled with <code>include</code>, |
| 498 |
<code>exclude</code>, etc. child elements. Note that without |
| 499 |
control parameters the task tries to rasterize <em>all</em> files |
| 500 |
in the given directory. |
| 501 |
</td> |
| 502 |
<td> |
| 503 |
One of the following is required: <code>src</code> attribute, |
| 504 |
<code>srcdir</code> attribute or <code>fileset</code> element(s). |
| 505 |
</td> |
| 506 |
</tr> |
| 507 |
<tr> |
| 508 |
<td>destdir</td> |
| 509 |
<td> |
| 510 |
Name of an output directory. Use this with the <code>srcdir</code> |
| 511 |
attribute or <code>fileset</code> elements. The task generates |
| 512 |
the names of the output images by changing the suffix of the |
| 513 |
input file names to correspond the result image type. A suffix is |
| 514 |
added if the input file doesn’t have one. Output directories are |
| 515 |
created if they don’t exist. |
| 516 |
</td> |
| 517 |
<td> |
| 518 |
Required if <code>srcdir</code> attribute or |
| 519 |
<code>fileset</code> elements are used. |
| 520 |
</td> |
| 521 |
</tr> |
| 522 |
<tr> |
| 523 |
<td>classname</td> |
| 524 |
<td> |
| 525 |
Class name of the XML parser used to parse SVG images. The value |
| 526 |
can be either the complete classname with package information |
| 527 |
included or the special name <code>jaxp</code>, which means any |
| 528 |
available parser in the <code>CLASSPATH</code> that supports JAXP. |
| 529 |
See the Batik code for the default value. |
| 530 |
</td> |
| 531 |
<td>No</td> |
| 532 |
</tr> |
| 533 |
</table> |
| 534 |
<p> |
| 535 |
You can use <code>fileset</code> elements to select input |
| 536 |
files and directories. See the |
| 537 |
<a href="http://ant.apache.org/">Ant</a> documentation to learn how |
| 538 |
to use |
| 539 |
<a href="http://ant.apache.org/manual/CoreTypes/fileset.html">filesets</a>. |
| 540 |
</p> |
| 541 |
</section> |
| 542 |
|
| 543 |
<section id="taskExamples"> |
| 544 |
<title>Examples of using the rasterizer task</title> |
| 545 |
|
| 546 |
<p> |
| 547 |
The following example is the complete Ant project that converts an SVG |
| 548 |
image (called <code>input.svg</code>) to a PNG image (called |
| 549 |
<code>output.png</code>): |
| 550 |
</p> |
| 551 |
|
| 552 |
<source><![CDATA[<?xml version="1.0"?> |
| 553 |
|
| 554 |
<project name="RasterizerExample" default="main" basedir="."> |
| 555 |
|
| 556 |
<taskdef name="rasterize" |
| 557 |
classname="org.apache.tools.ant.taskdefs.optional.RasterizerTask"/> |
| 558 |
|
| 559 |
<target name="main"> |
| 560 |
<rasterize result="image/png" src="input.svg" dest="output.png"/> |
| 561 |
</target> |
| 562 |
</project>]]></source> |
| 563 |
|
| 564 |
<p> |
| 565 |
The next example is just one task in a project. It converts all files |
| 566 |
with a <code>.svg</code> suffix in the <code>images</code> directory and |
| 567 |
all files in the <code>images2</code> directory to TIFF images. The |
| 568 |
resulting image files are placed in the <code>results</code> directory. |
| 569 |
</p> |
| 570 |
|
| 571 |
<source><![CDATA[ <rasterize result="image/tiff" destdir="results"> |
| 572 |
<fileset dir="images"> |
| 573 |
<include name="**/*.svg"/> |
| 574 |
</fileset> |
| 575 |
<fileset dir="images2"/> |
| 576 |
</rasterize>]]></source> |
| 577 |
|
| 578 |
</section> |
| 579 |
</section> |
| 580 |
|
| 581 |
</body> |
| 582 |
</document> |