Converting JavaScript generated documents/pages to PDF - java

I'm using xhtmlrenderer + iText in Java to generate PDFs for some pages in my application. I've managed to convert some pages already. However, I came across a limitation to this approach where it can't convert pages dynamically created using JavaScript scripts (some by JQuery). Are there other available tools for this?
Thanks.

Your best bet is wkhtmltopdf. It's a PDF converter sitting on top of web kit, complete with its JS environment. I haven't tried it myself (yet).

Related

Opensource PDF generator for Angular and Java

I'm looking for the best PDF generators for Angular and JAVA. If there's one that can be used in both would be great. The requirements I have on these PDF creators are:
OpenSource
Easy to use
Can be used on Enterprise level
Generate custom PDFs (not just print-outs of what’s on the screen)
So far I have on my list:
iText (discarded)
Apache POI
Aspose (discarded)
PDFBox
PDF Clown (discarded)
In angular if you have data on UI then you can use following libraries which have good provision to export pdf:
"jspdf": "^1.4.1"
"jspdf-autotable": "^2.3.4"
If you need customized reports and have dependency on backend then you can use Jasper Reports which can give more reach appearance.

Creating Docx, PDF, XSL-FO

[Background Info]
We had a solution in place to use Word automation serverside to convert HTM documents into Docx, PDF or Print documents. This solution broke in the latest version of Windows Server 2012. We learned that MS does not intend on Word working in this manner and after trouble shooting with MS support Engineers we have come to the conclusion that it will never work.
[Currently]
I am currently researching potential technologies and tools that my company can use to regain this functionality. We need to be able to create Docx, PDF and print files to a local printer.
I have looked into a number of tool already and I am currently leaning towards Apache FOP this seems to handle PDF and Printing for us.
However, I'm looking for some advice and suggested tools that we could use to implement a pure Java approach. Currently our application creates HTM files with all the required information. So ideally we would like to take these HTM files and "Convert" them into Docx/XLS-FO format.
[Question]
So my question that I'm hoping you will be able to help me with.
What is the best tools that I can use to get from
HTM to Docx
HTM to PDF
Or what would be the best process for achieving this? has anyone had success finding a solution for this in the past?
Thank You
It depends on the level of control and the complexity of the source HTML. There are HTML to FO stylesheets but you might find them wanting for your specific need.
So you could use the Jericho parser to read the HTML and generate FO. Or you generate the target format directly using Apache PDFBox and Apache POI
It all boils down to the level of control you want/need
docx4j-ImportXHTML will get you from XHTML to docx. From there, you can use docx4j (or some other solution eg LibreOffice/OpenOffice) to do docx to PDF.
docx4j supports docx to XSL FO, and by default uses FOP.

Convert html+css+js to PDF

I want to create something like this (code is here):
in pdf format. I'm using google charts and regarding to this forum converting chart to pdf is impossible. I've already tryied iText+XMLWorker, but there is some problem with css and any js supporting at all, I think.
So, the questions are: How can I convert html+css+js to .pdf file? Or, may be, the issue have other variants?
As promised in the comment, I've asked Raf. This was his answer:
One way to use XML Worker for HTML+CSS+JS is to use a browser engine to preprocess the HTML. Examples of such a browser engine are WebKit (Chrome, Safari) and Gecko (Firefox). These can interpret the CSS and JS and give you HTML that is ready to be parsed by XML Worker.
Examples of competing products are:
wkhtmltopdf, a command line tool that uses WebKit as its rendering engine.
Prince XML supports HTML+CSS+JS to PDF using their own engine.
Maybe there are others, but this is what Raf told me. I hope this helps.

Using templates for creating PDF files

I have some PDF template (with header and footer). I want to generate documents that are based on that template.
Is there any way to do that with iText? Thank you
P.S. Right now I am generate a document on-fly i.e. every time I generate header, footer and the context itself.
UPDATE: I have found incredible library called PD4ML. It's not free, but not such expensive, BUT it has really cool features such as HTML2PDF conversion on fly, supports a lot of HTML-CSS tags and has even its own jsp tags library! So I really suggest it when you need something instead of heavy and memory-eating JasperReports.
You can use JasperReports library and the iReport visual designer.
JasperReports use iText to produce PDFs from "jasper" templates, that are XML files (following the jrxml DTD) compiled in java classes, but allows you to use the template for generating MS Office files (with POI), html, etc.
Im not sure with iText, but you can use BIRT for this purpose. http://www.eclipse.org/birt/ Its too much using it just for PDF creation, you can do a lot (more than you can imagine) with it.
If you can choose your template format. I would go with JODReport and JODConverter.
JODReport use an ODT template and fill the mapping in the template with your java code.
JODConverter use LibreOffice to convert such template in PDF or whatever fortmat LibreOffice can handle to export.
You have to be able to use LibreOffice as a service installed remotely on a machine.
I used it back in 2012 but not sure if the project is still active

html to pdf in java plugin [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Converting HTML files to PDF
List of HTML to PDF converters
We want an java plugin to convert html to pdf, that will integrate with our app. is that possible with any java plugins?, we dont want to purchase it every time especially number of users for one app something like that. we will integrate that plugin with our app. we are not going to show that there plugin inside our app.but there is need of printing html on browser and as well need to produce pdf for that HTML in our app. we want plugin for our application. is there any java /java server plugin .
Please let us know that if this suitable to our requirements. any reply that would be great help.
Thanks and Regards
kumar kasimala
You can use itext library for this purpose
Try the PDF Converter services. It supports loads of formats including HTML and works from any Web Services capable environment including Java and .net.
Here are some examples:
Converting using the web services interface
Converting HTML
Note that the articles may mention SharePoint a couple of times. Don't worry, the product is not tied to SharePoint, it just happens to be used a lot in that environment.
Big disclaimer, I worked on the product so I am obviously biased about how fantastic the product is :-)

Categories

Resources