Discussion:
To convert any image / doc to pdf using FOP
myforums2008
2008-02-21 20:59:03 UTC
Permalink
I have tried converting an image to pdf. But it says there was an error in
opening this document, when I try to open the document. Please let me know
if you know of any solution.

Thanks,
Regards,
Reddy
--
View this message in context: http://www.nabble.com/To-convert-any-image---doc-to-pdf-using-FOP-tp15618950p15618950.html
Sent from the FOP - Users mailing list archive at Nabble.com.
Chris Bowditch
2008-02-22 14:05:16 UTC
Permalink
Post by myforums2008
I have tried converting an image to pdf. But it says there was an error in
opening this document, when I try to open the document. Please let me know
if you know of any solution.
Fop expects XSL-FO files as input. For convenience it also accepts XML
and XSLT files. However, you cannot pass an "image" (e.g. jpeg or gif)
directly to FOP. Perhaps I misunderstood what you meant.

Thanks,

Chris
Jeremias Maerki
2008-02-22 14:12:19 UTC
Permalink
First of all, let's make it clear that Apache FOP is an XSL-FO
implementation, i.e. it expected XSL-FO as input.

Converting an image to PDF is not directly possible with FOP 0.94. It
will be in 0.95 (only from the command-line or with special Java code) as
a side-effect of an additional feature that was added. But this will
never be FOP's primary function.

If you want to convert an image into a PDF, write a minimal XSL-FO
document and use fo:external-graphic to embed the image. Here's such a
minimal FO document:

<?xml version="1.0" encoding="UTF-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="A4" page-height="29.7cm" page-width="21cm">
<fo:region-body/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="A4">
<fo:flow flow-name="xsl-region-body">
<fo:block line-height="1.0" font-size="0pt">
<fo:external-graphic src="images/someimage.png"/>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
Post by myforums2008
I have tried converting an image to pdf. But it says there was an error in
opening this document, when I try to open the document. Please let me know
if you know of any solution.
Thanks,
Regards,
Reddy
--
View this message in context: http://www.nabble.com/To-convert-any-image---doc-to-pdf-using-FOP-tp15618950p15618950.html
Sent from the FOP - Users mailing list archive at Nabble.com.
Jeremias Maerki
Reddy, Prashanth
2008-02-26 20:00:39 UTC
Permalink
Yes, I realized that I am using the Apache FOP 0.94 version. So , I might
have to upgrade to higher version like 0.95. But I have few questions. 1)
will that version work fine with converting all images, word documents,
scanned documents, html. If not which version is better.?
2) In your previous message you have given a minimal document, using
external graphics. Will you be able to tell where it is exactly placed in
the web project folder structure. How is it accessed..

Reddy
Post by Jeremias Maerki
First of all, let's make it clear that Apache FOP is an XSL-FO
implementation, i.e. it expected XSL-FO as input.
Converting an image to PDF is not directly possible with FOP 0.94. It
will be in 0.95 (only from the command-line or with special Java code) as
a side-effect of an additional feature that was added. But this will
never be FOP's primary function.
If you want to convert an image into a PDF, write a minimal XSL-FO
document and use fo:external-graphic to embed the image. Here's such a
<?xml version="1.0" encoding="UTF-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="A4" page-height="29.7cm" page-width="21cm">
<fo:region-body/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="A4">
<fo:flow flow-name="xsl-region-body">
<fo:block line-height="1.0" font-size="0pt">
<fo:external-graphic src="images/someimage.png"/>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
Post by myforums2008
I have tried converting an image to pdf. But it says there was an error in
opening this document, when I try to open the document. Please let me know
if you know of any solution.
Thanks,
Regards,
Reddy
--
http://www.nabble.com/To-convert-any-image---doc-to-pdf-using-FOP-tp15618950p15618950.html
Sent from the FOP - Users mailing list archive at Nabble.com.
Jeremias Maerki
---------------------------------------------------------------------
--
View this message in context: http://www.nabble.com/To-convert-any-image---doc-to-pdf-using-FOP-tp15618950p15681487.html
Sent from the FOP - Users mailing list archive at Nabble.com.
Andreas Delmelle
2008-02-26 20:25:08 UTC
Permalink
On Feb 26, 2008, at 21:00, Reddy, Prashanth wrote:

Hi
Post by Reddy, Prashanth
Yes, I realized that I am using the Apache FOP 0.94 version. So , I might
have to upgrade to higher version like 0.95. But I have few questions.
1) will that version work fine with converting all images, word
documents,
scanned documents, html.
Images, yes (as Jeremias mentioned).
Word documents? Yes, if you mean the WordML-format, but then you have
to take care of transforming WordML to XSL-FO first.
Same for HTML. If it is XHTML, then it can be transformed to FO using
XSLT. You could also achieve a similar transformation via Java code,
with CSS2XSLFO (http://www.re.be/css2xslfo/)

Note that with 0.95, it will also be possible to insert entire PDFs
(provided you have nothing against an additional dependency on
PDFBox, IIC)
Post by Reddy, Prashanth
2) In your previous message you have given a minimal document, using
external graphics. Will you be able to tell where it is exactly placed in
the web project folder structure. How is it accessed..
XSL-FO and FOP are quite flexible in this regard.
You can use absolute URIs for images with a static/central location.
Via the user-configuration, you can also specify a global base-URL
that will be used to resolve all relative URIs (http://
xmlgraphics.apache.org/fop/0.94/configuration.html).
And, on top of that, you could also implement a custom URIResolver of
your own that goes looking for the image wherever you want. This
might be handy if the images are stored as BLOBs in a database.


HTH!

Andreas

Loading...