blob: 375d319672e159a6be93b3acb705d6c9f3215a10 (
plain)
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
|
<?xml version="1.0" standalone="no"?>
<!-- SVG in FOP -->
<s1 title="SVG in FOP">
<s2 title="Introduction">
<p>
FOP uses the SVG library from <jump href="http://xml.apache.org/batik/">Batik</jump> to handle SVG.
This format can be handled as an <code>fo:instream-foreign-object</code> or in a separate
file referenced with <code>fo:external-graphic</code>. Either way the SVG document will be
read in and converted into a DOM in Batik. This DOM will then be used by the renderer to
create the graphical image.
</p>
<p>
The AWT and Print renderers simply use batik to draw the SVG into a graphic.
</p>
<p>
In the case of the PDF renderer there is a PDFGraphics2D class that Batik uses
to render the image into. This class converts the drawing instructions into
PDF markup which is placed into the current PDF document.
</p>
</s2>
<s2 title="Converting SVG to a PDF Document">
<p>
It is possible to convert a standalone SVG document directly into a simple page PDF document.
This is possible through the use of Batik's transcoder mechanism.<br/>
<code>java org.apache.batik.apps.rasterizer.Main -m application/pdf document.svg</code>
<br/>
This will output the svg document as "document.pdf" containing a PDF rendering of
the SVG file.
</p>
<p>
It is also possible to specify the width and/or height of the PDF document.
Currently the SVG image is simply scaled in PDF so the result my not be the best possible.
</p>
<p>
For more information see <jump href="http://xml.apache.org/batik/">Batik</jump> for
how transcoders work.
</p>
<p>
These are the relevant classes, found in the package org.apache.fop.svg :
</p>
<p>
<ul>
<li><em>PDFGraphics2D</em>
<br/>
used for drawing onto a Graphics2D into an existing pdf document, used
internally to draw the svg.
</li>
<li><em>PDFDocumentGraphics2D</em>
<br/>
used to create a pdf document and inherits from PDFGraphics2D to do the
rest of the drawing. Used by the transcoder to create a standalone pdf
document from an svg. Can be used independantly the same as any Graphics2D.
</li>
<li><em>PDFTranscoder</em>
<br/>
used to transcode an svg document into a standalone pdf, via
PDFDocumentGraphics2D.
</li>
</ul>
</p>
</s2>
</s1>
|