File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Other Java Products and Servers and the fly likes HTML to PDF using Apache FOP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Java Products and Servers
Bookmark "HTML to PDF using Apache FOP" Watch "HTML to PDF using Apache FOP" New topic

HTML to PDF using Apache FOP

Pankaj Upadhyay

Joined: Nov 06, 2008
Posts: 21
Dear All

I am using Apache FOP technology to convery an HTML document into a PDF. Since the day this functionality was developed, it is broken and I found out that if generated HTML contains "nbsp;" Pdf generation fails and I get the message that the file is damaged.

I am using xhtml2fo.xsl for rendering of the FO elements which is an open source tool for rendering onto PDF document.

I think I have to customize the xsl but I dont know how to do that. Can anyone suggest a way to achieve that? Are any other tools available in the market? Howz iText in converting HTML to PDF?

Let me know if you need more details from my side.


Pankaj Upadhyay (SCJP 1.6 == 86%)
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

I'm just guessing here, because you didn't post any error messages. And you didn't tell us what you were using to parse the HTML either. Or what version of HTML it was. So all I can suggest is that you use a proper HTML parser instead of an XML parser (if that's what you are doing) or make sure your parser accesses the DTD properly (the one which contains the definitions of all the HTML entities).
Pankaj Upadhyay

Joined: Nov 06, 2008
Posts: 21
Hi Paul

I am using iFrame's DesignMode property to show an editor. User performs some operation which generates default HTML elements. I just add HTML and BODY tage beafore and after the content and then use Tidy to verify my HTML and then use FOP.

Hope I am clear, if not let me know what else info you require.

Consider Paul's rocket mass heater.
subject: HTML to PDF using Apache FOP
jQuery in Action, 3rd edition