views:

2066

answers:

4

Hi guys,

I wanna to a pop over content to PDF. I am using GWT. I think client side its impossible. But any budy here know how browser can print into PDF file? And is there any way to print a HTML content into PDF on server side? I have a HTML content with CSS on adding this content to PDF the view should remain same as it appear in HTML.

Is there any HTML to PDF file converter available for java? I tried pd4ml its not prodicing good PDF.

+1  A: 

PDF printing is a capability often added to browsers, but there is no way to trigger it from GWT or any other Javascript framework. The best you can do is call the page's print functionality, and hope the user has a PDF printer driver installed and can figure out how to use it.

To be 100% certain and user-friendly, you will need to generate the PDF on the server though.

levik
Actually, you are wrong. http://code.google.com/p/jspdf/ Note, however this may not work in some *modern* browsers like IE.
JP
A: 

Take a look at FlyingSaucer if you want to render HTML to PDF server side.

ChssPly76
A: 

You can use pure Javascript (client-side) to generate a simple PDF. http://code.google.com/p/jspdf/ However, I don't believe it works in IE. http://code.google.com/p/jspdf/

I would recommend checking out the this HTML to PDF program for a good server-side solution: http://github.com/antialize/wkhtmltopdf

Good luck.

-JP

JP
A: 

You may use iText.jar liabrary to generate PDF file in GWT

Tushar Ahirrao
Hi Tushar,I know iText can be used for PDF generation. As I don't just need a PDF generator I need all HTML component in PDF its tedious with iText.Can you tell me how you can print HTML component in PDF with iText?
Jprogyog