Oliver Charlet wrote:
I too have a problem embedding fop in my application.
The standard procedure in case of trouble with an embedded
- Run the transformation from the command line in order
to generate a FO file. This ensures the transformation is
- Run the produced FO file from the command line and see
whether it produces the desired PDF. This ensures that
the FO is correct and that you didn't hit any FOP bugs.
- Put som code into your application which runs the FO
file through FOP, *without* the transformation. This
way you'll see whether you have problems with the
FO setup in the embedding and whether you can reference
ell external ressources (fonts, graphics etc.)
- Try to run the transfomation *without* the formatting
step. The code is a one-liner :)
new StreamSource(new File("foo.xsl"))).transform(
new StreamSource(new File("foo.xml")),
new StreamResult(new File("foo.fo")));
This will catch problems with the XSLT processor setup
and access to ressources referenced during the transformation
(DTD and external entities in the original XML, ressources
accessed with document(), extensions etc.)
- Run FOP+XSLT embedded as the final step.
> the following code (used inside a servlet) produces a zero byte pdf-file.
> xmlFile and xslFile hold an absolute Path to the input-files.
> It seems to me, that the generation is not started at all.
1. If you have a DOCTYPE declaration referring to an external
DTD in your original XML or a PI linking the document to an
XSchema, either remove it or check whether the ressources are
2. Close the PDF file explicitely, or flush it:
The Java runtime closes files upon garbage collecting them,
and this wont happen as long as the Driver object is