Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Tools / August 2004

Tip: Looking for answers? Try searching our database.

Dynamic PDF - which method?

Thread view: 
Rob Martin - 19 Aug 2004 01:10 GMT
Greetings

There seems to be two main ways of creating PDF from java - 1. via HTML to
PDF and 2. using an API (e.g. iText).

What are your thoughts - is there an adopted 'standard' method of the two
above, or personal/company preference. Want to go the most supported and
commonly accepted method for the future.

Thanks!
Rob

ps - converting a Powerbuilder web application that contains datawindow to
PDF via Amyuni print driver on windows.
Lothar Kimmeringer - 20 Aug 2004 15:54 GMT
> There seems to be two main ways of creating PDF from java - 1. via HTML to
> PDF and 2. using an API (e.g. iText).
>
> What are your thoughts - is there an adopted 'standard' method of the two
> above, or personal/company preference. Want to go the most supported and
> commonly accepted method for the future.

HTML2PDF is never a good idea, because HTML is not a format for
content following a specific design, e.g. headers (showing the
current chapter) or footer (showing the page-number).

Good results I received with the FOP-implementation of the
Apache-group (there are some restrictions to be regarded, but
it's working) but I also heard good things about iText, too.

Regards, Lothar
Signature

Lothar Kimmeringer                E-Mail: spamfang@kimmeringer.de
              PGP-encrypted mails preferred (Key-ID: 0x8BC3CD81)

Always remember: The answer is forty-two, there can only be wrong
                questions!

RobM - 21 Aug 2004 04:49 GMT
> > There seems to be two main ways of creating PDF from java - 1. via HTML to
> > PDF and 2. using an API (e.g. iText).
[quoted text clipped - 12 lines]
>
> Regards, Lothar

Thanks Lothar - good reply. In that sense using HTML does sound a bit
'mickeymouse' to make a document.

One reason I was interested is in the existing web app the document is shown
on the page for a preview (before the user confirms and a PDF is made) so we
have the HTML to start with, as well as the CGI Powerbuilder where the PDF
is generated from.

iText looks interesting - API calls to add text and tables to a document.
Just wonder how complicated that would be.

Interested in what you say about Apache FOP; I've not read in depth yet, but
have looked at XMLMill http://www.xmlmill.com/products/xmlmillforjava.html
that is based on Apache FOP which seems to use XML (the page data) and XSL -
which I've not used before but seems to be HTML with tags referring to the
XML file to obtain the data placed at the proper places in the HTML. So is
still basically HTML but split data (which is easy as we can export XML from
the database). Did you use Apache FOP in a similar way?

examples of our documents:
http://users.bigpond.net.au/snootfrog/wip/pdf/app.pdf
http://users.bigpond.net.au/snootfrog/wip/pdf/aff.pdf

Cheers und danke
Rob
Melbourne, Australia
Lothar Kimmeringer - 21 Aug 2004 11:07 GMT
> One reason I was interested is in the existing web app the document is shown
> on the page for a preview (before the user confirms and a PDF is made) so we
> have the HTML to start with, as well as the CGI Powerbuilder where the PDF
> is generated from.

[...]

> Interested in what you say about Apache FOP; I've not read in depth yet, but
> have looked at XMLMill http://www.xmlmill.com/products/xmlmillforjava.html
[quoted text clipped - 3 lines]
> still basically HTML but split data (which is easy as we can export XML from
> the database). Did you use Apache FOP in a similar way?

Apache FOP uses a Formatted Object (FO) to create PDF, SVG or
other formats. FO is XML-based and is generally created out
of a XML containing the data and a XSL-file that contains the
rules how the data should be "transformed" to whatever you
want.

In your case, XML with XSL would be a quite good fitting solution,
because you "only" need two XSL-files for your preview/PDF-creation-
scenario. One XSL is used for creating the HTML-preview, the other
one is used for creating the FO-file used by Apache-FOP to create
PDF or other target-formats.

With iText you would need two different mechanisms to create
HTML on the one side and PDF on the other. So I think FOP
would be the better solution for you in this case.

Regards, Lothar
Signature

Lothar Kimmeringer                E-Mail: spamfang@kimmeringer.de
              PGP-encrypted mails preferred (Key-ID: 0x8BC3CD81)

Always remember: The answer is forty-two, there can only be wrong
                questions!

RobM - 21 Aug 2004 13:43 GMT
> > One reason I was interested is in the existing web app the document is shown
> > on the page for a preview (before the user confirms and a PDF is made) so we
[quoted text clipped - 28 lines]
>
> Regards, Lothar

Cheers and thanks
Best regards to Zaphod
Rob.
Rob Martin - 25 Aug 2004 00:59 GMT
> > One reason I was interested is in the existing web app the document is shown
> > on the page for a preview (before the user confirms and a PDF is made) so we
[quoted text clipped - 28 lines]
>
> Regards, Lothar

Ahhh... Lothar... I thought I could use the existing HMTL amended to be XSL
like below - but seems I cant use HTML tags, the XSL has to have <fo ...>
tags instead. Have you found that learning curve OK? I've looking at
http://www.w3schools.com/xslfo/xslfo_intro.asp.

(Seems iText looks simpler now!)
Cheers
Rob

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
 <html>
 <body>
   <h2>My CD Collection</h2>
   <table border="1">
   <tr bgcolor="#9acd32">
     <th align="left">Title</th>
     <th align="left">Artist</th>
     <th align="left">Price</th>
   </tr>
   <xsl:for-each select="catalog/cd">
   <tr>
     <td><xsl:value-of select="title"/></td>
     <td><xsl:value-of select="artist"/></td>
     <td><xsl:value-of select="price"/></td>
   </tr>
   </xsl:for-each>
   </table>
 </body>
 </html>
</xsl:template>
</xsl:stylesheet


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.