<?xml version="1.0" standalone="no"?>
<!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V1.1//EN"
"http://cvs.apache.org/viewcvs.cgi/*checkout*/xml-forrest/src/resources/schema/dtd/document-v11.dtd">
-
<document>
- <header>
- <title>FOP Graphics Formats</title>
- </header>
-
- <body>
-
+ <header>
+ <title>FOP Graphics Formats</title>
+ </header>
+ <body>
<section id="svg">
<title>SVG</title>
- <section id="svg-intro">
- <title>Introduction</title>
- <p>
+ <section id="svg-intro">
+ <title>Introduction</title>
+ <p>
FOP uses the SVG library from <link href="http://xml.apache.org/batik/">Batik</link> 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>
+ </p>
+ <p>
The AWT and Print renderers simply use batik to draw the SVG into a graphic.
- </p>
- <p>
+ </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>
- </section>
-
- <section id="svg-pdf-conversion">
- <title>Converting SVG to a PDF Document</title>
- <p>
+ </p>
+ </section>
+ <section id="svg-pdf-conversion">
+ <title>Converting SVG to a PDF Document</title>
+ <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/>
+ <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>
+ </p>
+ <p>
It is also possible to specify the width and/or height of the PDF document on the command line with -w and -h or if you are using the transcoder api you can use the transcoding hints.
- </p>
- <p>
+ </p>
+ <p>
Currently the SVG image is drawn at the SVG document size and simply scaled in PDF to the new size. So the result may not be the best possible. For example if you have any images or effects it will draw them at the original resolution of the svg document. When this is viewed in the pdf it will have an incorrect resolution for the size of the pdf.
-</p>
- <p>
+ </p>
+ <p>
The size of the pdf file will also remain the same regardless of what size the page is.
- </p>
- <p>
+ </p>
+ <p>
For more information see <link href="http://xml.apache.org/batik/">Batik</link> for
how transcoders work.
- </p>
- </section>
-
- <section id="svg-pdf-graphics">
- <title>Placing SVG Graphics into PDF</title>
- <p>
+ </p>
+ </section>
+ <section id="svg-pdf-graphics">
+ <title>Placing SVG Graphics into PDF</title>
+ <p>
The svg is inserted into PDF by using PDF commands to draw and fill
lines and curves. This means that the graphical objects created with
this remain as vector graphics.
- </p>
- <p>
+ </p>
+ <p>
There are a number of SVG things that cannot be converted directly into
PDF. Parts of the graphic such as effects, patterns and images are inserted
into the PDF as a raster graphic. The resolution of this graphic may not
be ideal depending on the FOP dpi (72dpi) and the scaling for that graphic.
This needs to be improved.</p>
- <p>
+ <p>
Currently transparency is not supported in PDF so many svg images that
contain effects or graphics with transparent areas will not be displayed
correctly.
- </p>
- </section>
- <section id="svg-pdf-text">
- <title>Placing SVG Text into PDF</title>
- <p>If possible, Batik will use normal PDF text when inserting text. It does
+ </p>
+ </section>
+ <section id="svg-pdf-text">
+ <title>Placing SVG Text into PDF</title>
+ <p>If possible, Batik will use normal PDF text when inserting text. It does
this by checking if the text can be drawn normally and the font is
supported. This example svg <link href="dev/svg/text.svg">text.svg</link> /
<link href="dev/svg/text.pdf">text.pdf</link>
shows how various types and effects with text are handled.
Note that tspan and outlined text are not yet implemented.</p>
- <p>
+ <p>
Otherwise, text is converted and drawn as a set of shapes by batik, using the stroking text painter.
This means that a typical character will
have about 10 curves (each curve consists of at least 20 characters).
Smooth Line Art in the Acrobat preferences will fix this).
If the text is inserted into the PDF using the inbuilt text commands
for PDF it will use a single character.
- </p>
- <p>
+ </p>
+ <p>
It is possible to make sure that all text is drawn into PDF using the
PDF text commands (instead of the graphical shapes), by adding the following to the user config:
- </p>
-<source><![CDATA[<entry>
+ </p>
+ <source><![CDATA[<entry>
<key>strokeSVGText</key>
<value>false</value>
</entry>]]></source>
- <p>In a servlet environment, you can set it directly:</p>
- <source>org.apache.fop.configuration.Configuration.put("strokeSVGText", Boolean.FALSE);</source>
- <p>For information on using a configuration file in a servlet, see the <link href="faq.html#usercfg">FAQ</link> on that topic.</p>
- <p>Note that this configuration setting works only for the PDF renderer.</p>
- <p>
+ <p>In a servlet environment, you can set it directly:</p>
+ <source>org.apache.fop.configuration.Configuration.put("strokeSVGText", Boolean.FALSE);</source>
+ <p>For information on using a configuration file in a servlet, see the <link href="faq.html#usercfg">FAQ</link> on that topic.</p>
+ <p>Note that this configuration setting works only for the PDF renderer.</p>
+ <p>
The drawback to forcing text to be rendered as text is that it will be confined to text that is
possible for PDF fonts (including embedded fonts) and implemented with
this workaround. The fonts available are the standard pdf fonts and any
fonts that you have embedded using FOP. The font sizes will be rounded
to an integer value. In future this will be improved.
- </p>
- <p>Note that because SVG text can be rendered as either text or a vector graphic, you may need to consider settings in your viewer for both.
+ </p>
+ <p>Note that because SVG text can be rendered as either text or a vector graphic, you may need to consider settings in your viewer for both.
The Acrobat viewer has both "smooth line art" and "smooth text" settings that may need to be set for SVG images to be displayed nicely on your screen (see Edit / Preferences / Display).
This setting will not affect the printing of your document, which should be OK in any case, but will only affect the quality of the screen display.</p>
- </section>
-
- <section id="svg-problems">
- <title>Known Problems</title>
-<ul>
-<li>
+ </section>
+ <section id="svg-problems">
+ <title>Known Problems</title>
+ <ul>
+ <li>
soft mask transparency is combined with white so that it looks better
on pdf 1.3 viewers but this causes the soft mask to be slightly lighter
or darker on pdf 1.4 viewers
-</li>
-<li>
+ </li>
+ <li>
there is some problem with a gradient inside a pattern causing a pdf
error when viewed in acrobat 5
-</li>
-<li>
+ </li>
+ <li>
text is not always handled correctly, it may select the wrong font
especially if characters have multiple fonts in the font list
-</li>
-<li>
+ </li>
+ <li>
more pdf text handling could be implemented
It could draw the string using the attributed character iterator
to handle tspans and other simple changes of text.
-</li>
-<li>
+ </li>
+ <li>
JPEG images are not inserted directly into the pdf document
This area has not been implemented yet since the appropriate
method in batik is static
-</li>
-<li>
+ </li>
+ <li>
Uniform transparency for images and other svg elements that are converted
into a raster graphic are not drawn properly in PDF. The image is opaque.
-</li>
-</ul>
- </section>
+ </li>
+ </ul>
+ </section>
</section>
- </body>
+ </body>
</document>
-