By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,034 Members | 819 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,034 IT Pros & Developers. It's quick & easy.

Pure Java method for HTML to PDF conversion...

P: n/a
I am currently looking for a way to convert HTML to PDF in Java. I
cannot:

1) use anything which is MS-Windows specific.
2) Use an external server which processes the HTML -> PDF.

Keeping these two requirements in mind, does anyone know of any
product, or project which can do this?

Also, I've tried Apache-FOP and it doesn't work very well. It *must*
look the same way or at least very similar to how it does on the
browser.

Thanks in advance for any help you can offer. Please don't hesitate
to email me at: gr************@yahoo.com if you know of something
which may help.

Thanks, GJC
Jul 17 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a

"Gregory Casamento" <gr************@yahoo.com> wrote in message
news:eb*************************@posting.google.co m...
I am currently looking for a way to convert HTML to PDF in Java. I
cannot:

1) use anything which is MS-Windows specific.
2) Use an external server which processes the HTML -> PDF.

Keeping these two requirements in mind, does anyone know of any
product, or project which can do this?

Also, I've tried Apache-FOP and it doesn't work very well. It *must*
look the same way or at least very similar to how it does on the
browser.

Thanks in advance for any help you can offer. Please don't hesitate
to email me at: gr************@yahoo.com if you know of something
which may help.

Thanks, GJC


I assume you mean open source? You can get pretty good results from FOP if
you put in enough time getting the XSLT stylesheets right. But other than
that I'm not aware of any projects that allow generic HTML -> PDF
conversion. I'd be VERY interested if you find one though ...

If you have money to burn, one product I've tried is Corda Highwire (trial
version) - http://www.corda.com/products/highwire/ While it is intended to
run as a server, IIRC it is possible to access its functionality directly
through an API
Jul 17 '05 #2

P: n/a
zef
> I'm not aware of any projects that allow generic HTML -> PDF
conversion. I'd be VERY interested if you find one though ...


Try PD4ML! It's pure Java, it supports HTML 3.2 and CSS (to some
extend). Free trial. Affordable price. http://pd4ml.zefer.org
Jul 17 '05 #3

P: n/a

"zef" <pd*@zefer.org> wrote in message
news:2b**************************@posting.google.c om...
I'm not aware of any projects that allow generic HTML -> PDF
conversion. I'd be VERY interested if you find one though ...


Try PD4ML! It's pure Java, it supports HTML 3.2 and CSS (to some
extend). Free trial. Affordable price. http://pd4ml.zefer.org


That's probably the cheapest all-in-one offering I've seen, but it's limited
by the fairly basic HTML and CSS support of Swing's HTMLEditorKit. Do you
have any plans to offer full HTML 4 compliance?

I did something similar to your product a while ago using Swing and the
freeware gnujpdf
/ Retep PDF II but was unhappy with the CSS limitations

Jul 17 '05 #4

P: n/a
zef
> Do you have any plans to offer full HTML 4 compliance?

Currently we have no such plans. The philosophy of PD4ML (if we can
call it so) is to offer a sufficient and easy-to-use set of means to
author PDF documents. First we are focused on the ability to get a
desired end result, and only then on the acceptable input formats.

HTML 3.2 is a bit outdated now, but it still allows to create using
PD4ML a PDF layouts of almost any reasonable level of complexity. Our
current customers successfully use PD4ML for dynamic generation of
invoices, bank statements and phone bills.

An ability to render any single HTML page you can find in Internet is
not our goal in principle. For that deal fits better a variety of
print drivers and converting tools based on MS IE or Mozilla rendering
engines (although I am not sure, if there are any converting tools
based on Mozilla).

Zef
Jul 17 '05 #5

P: n/a

"zef" <pd*@zefer.org> wrote in message
news:2b**************************@posting.google.c om...
Do you have any plans to offer full HTML 4 compliance?


Currently we have no such plans. The philosophy of PD4ML (if we can
call it so) is to offer a sufficient and easy-to-use set of means to
author PDF documents. First we are focused on the ability to get a
desired end result, and only then on the acceptable input formats.


Ah fair enough, that makes sense. Don't get me wrong, your product sounds
good :-) Just not what I was after. i.e. a generic HTML --> PDF convertor. I
think Sun have added better CSS support to HTMLEditorKit in JDK 1.5, I'll
have to check it out when it's released.

Thanks
Jul 17 '05 #6

P: n/a
"Murray" <pa***@SPAMOFFoptusnet.SPAMMAGE.com.au> wrote in message news:<40***********************@news.optusnet.com. au>...
"Gregory Casamento" <gr************@yahoo.com> wrote in message
news:eb*************************@posting.google.co m...
I am currently looking for a way to convert HTML to PDF in Java. I
cannot:

1) use anything which is MS-Windows specific.
2) Use an external server which processes the HTML -> PDF.

Keeping these two requirements in mind, does anyone know of any
product, or project which can do this?

Also, I've tried Apache-FOP and it doesn't work very well. It *must*
look the same way or at least very similar to how it does on the
browser.

Thanks in advance for any help you can offer. Please don't hesitate
to email me at: gr************@yahoo.com if you know of something
which may help.

Thanks, GJC
I assume you mean open source?


That would be best, but proprietary would do.
You can get pretty good results from FOP if
you put in enough time getting the XSLT stylesheets right. But other than
that I'm not aware of any projects that allow generic HTML -> PDF
conversion. I'd be VERY interested if you find one though ...
I've already tried FOP. It works for straight HTML -> PDF given the
right stylesheet, the best I tried was from Anntenna House. The
issue is that the documents can contain CSS which the stylesheet isn't
set up to read.
If you have money to burn, one product I've tried is Corda Highwire (trial
version) - http://www.corda.com/products/highwire/ While it is intended to
run as a server, IIRC it is possible to access its functionality directly
through an API


I haven't looked at it. Thanks for the URL. :)

GJC
Jul 17 '05 #7

P: n/a
Rob

"Gregory Casamento" <gr************@yahoo.com> wrote in message
news:eb*************************@posting.google.co m...
I am currently looking for a way to convert HTML to PDF in Java. I
cannot:

1) use anything which is MS-Windows specific.
2) Use an external server which processes the HTML -> PDF.

Keeping these two requirements in mind, does anyone know of any
product, or project which can do this?

Also, I've tried Apache-FOP and it doesn't work very well. It *must*
look the same way or at least very similar to how it does on the
browser.

Thanks in advance for any help you can offer. Please don't hesitate
to email me at: gr************@yahoo.com if you know of something
which may help.

Thanks, GJC


Hi -

We've used this in the past, called from a JSP/Servlet (free except for
support)
http://www.easysw.com/htmldoc/

java example
http://www.easysw.com/htmldoc/htmldoc.html#6_6

Not sure if thats what you meant by 'external server', if so, sorry
Cheers
Rob
Jul 17 '05 #8

P: n/a
""Rob" <ro*@home.net.au>" wrote in comp.lang.java:
"Gregory Casamento" <gr************@yahoo.com> wrote in message
news:eb*************************@posting.google.co m...
I am currently looking for a way to convert HTML to PDF in Java. I
cannot:

1) use anything which is MS-Windows specific.
2) Use an external server which processes the HTML -> PDF.

Keeping these two requirements in mind, does anyone know of any
product, or project which can do this?
In addition to Rob's answer, try a Google.Com search; there seem to be
a lot of different options:

Google.Com: +html2pdf +java
http://www.google.com/search?q=%2Bhtml2pdf+%2Bjava
Also, I've tried Apache-FOP and it doesn't work very well. It *must*
look the same way or at least very similar to how it does on the
browser.

[sNip]

Which web browser? The problem is that each web browser renders web
pages somewhat differently, and then on different Operating Systems, which
can have different sets of default fonts and other display mode
differences, you'll see even more variety.

Your best bet will be to convert as close to the specifications as
possible, rather than trying to mimic a specific web browser. The code
that performs the conversion will probably be a lot cleaner too.
Jul 17 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.