Question

We are migrating our web app from Adobe Coldfusion/Windows to a Railo/Linux environment, and are having issues with inconsistent PDF rendering with cfdocument between the platforms. As well as default ACF (apparently iText 2.1.0) and the default railo (PD4ML) PDF engines, we have also tried PD4ML Pro v3.8.0fx3 and flying saucer to try and get accurate representation of HTML in a PDF doc (with mixed results).

Some specific issues we are facing relate to font alignment, font size, borders with thickness > 1px, table cell borders, absolute positioning of elements (flying saucer), z-index of images (default ACF).

Although the HTML we are using is user generated by various WYSIWYG editors and far from perfect, none of the aforementioned tools can render PDFs in the same way that any modern browser will.

We are looking for a tool that will generate PDFs that closely match the way HTML is rendered in the browser, has anyone overcome a similar problem who is willing to share which tool they use?

Was it helpful?

Solution

I've been using flying saucer for a couple of years now and have yet to run into any problems. I produce PDFs using ACF 9 and CKeditor. Check it out: https://github.com/flyingsaucerproject/flyingsaucer.

Sorry, just noticed you already tried flying saucer... I also recommend just using iText and XMLWorker.

Demo: http://demo.itextsupport.com/xmlworker/ Docs: http://demo.itextsupport.com/xmlworker/itextdoc/flatsite.html

OTHER TIPS

You can configure OpenOffice to run in headless mode. Then send it the HTML document, and a command to produce a PDF.

My company's built an HTML to PDF API called DocRaptor. We have better CSS support than a lot of other APIs.

All plans come with a 30 day trial and unlimited test documents.

We've got a Java example here: DocRaptor Java example

https://docraptor.com/

You can use WKHTMLTOPDF:

sudo apt-get install xvfb
sudo apt-get install wkhtmltopdf
sudo echo 'xvfb-run --server-args="-screen 0, 1024x768x24" /usr/bin/wkhtmltopdf $*' > /usr/bin/wkhtmltopdf.sh
sudo chmod a+x /usr/bin/wkhtmltopdf.sh
sudo ln -s /usr/bin/wkhtmltopdf.sh /usr/local/bin/wkhtmltopdf
wkhtmltopdf http://www.google.com google.pdf

Credits to http://www.mycodingtips.com/html-page-to-pdf-from-linux/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top