Skip to main content

How to convert HTML to PDF?

12 replies [Last post]
tokajac
Offline
Joined: 2008-06-11
Points: 0

Hello!

I'm developing Tomcat/Struts application.
I want to convert, for example, http://www.google.com to PDF.
I found iText solutions, but i still haven't made them to work. Any experience with this? Any other suggestion?

All useful hints are welcome!

Regards

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
dannycat
Offline
Joined: 2013-05-17
Points: 0

you can use an image converter to do that , I do this almost daily. I use a PDF converter driver found on the internet . Install it and it becomes a selectable converter option.Then you can convert PDFs to many forms in any program at all, including Adobe Acrobat . Just open a PDF, select convert, and choice a form you want,then you can convert html to pdf,the task will be finished in several seconds. if you haven't found a good choice , you can have a try. best wishes.

barralex
Offline
Joined: 2013-03-14
Points: 0

I would suggest this online tool for web to pdf conversions: http://kitpdf.com/web_to_pdf/. For me it does a great job.

tkdchamp
Offline
Joined: 2013-02-27
Points: 0

Hi tokajac,

There's a very easy to use HTML to PDF API for Java at http://www.htm2pdf.co.uk/html-to-pdf-api and it has sample code in Java on how to use it.

It works by simply sending a HTTP request containing the URL (in your case http://www.google.com) and an API key. You'd just open a connection to the URL of the API and then read the result.

You can also find an example of the HTML to PDF API in JAVA here.

Good luck!

zxfr
Offline
Joined: 2010-01-18
Points: 0

Also give a try to PD4ML (100% Java HTML+CSS->PDF converting API): http://pd4ml.com/jnindex.htm

markusn
Offline
Joined: 2005-11-10
Points: 0

Re: How to convert HTML to PDF?

Have you tried RealObjects PDFreactor yet? This is a fairly robust and powerful Java HTML to PDF conversion engine which supports CSS3, HTML5 and JavaScript with the latest release. It runs pretty well in Tomcat and I think it includes a SOAP API.

They have a free eval version at http://www.realobjects.com/pdfreactor

fchivu
Offline
Joined: 2010-01-05
Points: 0

Try the HTML to PDF converter from http://www.winnovative-software.com/

kac
Offline
Joined: 2009-12-08
Points: 0

Hi, jtidy, xhtmlrenderer and itext solution that worked for me
http://kac-ani.xt.pl/en/node/27

mloayzagahona
Offline
Joined: 2007-07-06
Points: 0

Hi.

You could review this post

http://mloayzagahona.blogspot.com/2007/07/convert-html-to-pdf-online.html

Greetings.

Have a great day

greeneyed
Offline
Joined: 2003-06-10
Points: 0

I'm not aware of a direct path to do it but...
.- XHTMLRenderer (a.k.a. the Flying Saucer) is a library that allows you to convert XHTML to PDF quite easily (https://xhtmlrenderer.dev.java.net/)
.- HTMLCleaner is a library that can "clean" a given HTML page and turn it into an XHTML page (http://htmlcleaner.sourceforge.net/)

I've used them separately and they worked fine for me, so you just have to connect both and voilà :).

S!

tokajac
Offline
Joined: 2008-06-11
Points: 0

Thank you for your answer greeneyed!

I tried http://htmlcleaner.sourceforge.net/javause.php
but have no success so far.

How to use http://htmlcleaner.sourceforge.net/ in Java? Is there any working example?

Regards

P.S.
I also posted this topic on:
https://sourceforge.net/forum/forum.php?thread_id=3123464&forum_id=637246

greeneyed
Offline
Joined: 2003-06-10
Points: 0

Well, the basic example is the page that you show, that's the most basic "stuff".

For a more complex example, you can have a look at the filter I implemented for our framework:

http://fisheye5.cenqua.com/browse/webleaf/source/org/leaf/filters/HTMLCl...

Basically the code you are looking for is the code inside the doFilterMethod:
http://fisheye5.cenqua.com/browse/webleaf/source/org/leaf/filters/HTMLCl...

and also the init method where the objects are initialised:
http://fisheye5.cenqua.com/browse/webleaf/source/org/leaf/filters/HTMLCl...

The rest of the code is parameter reading so the filter can be configured with all the options that HTMLCleaner can use.

We use this filter in combination with other filters to get content in HTML external to the application and convert it to XHTML so it can be used as XML for several purposes.

S!

fchivu
Offline
Joined: 2010-01-05
Points: 0

I recommend you this html to pdf converter.