CFDocument, Flying Saucer, and Background-Images

I’m trying to upgrade to the latest CFDocument PDF extension (1.0.0.8) and I cannot get background-image: url() to work for the life of me. I just wanted to know if they are supported and I’m doing something wrong? Or, if they are simply not supported in the version of Flying Saucer that we are using?

1 Like

These are the available artefacts in flying saucer pdf library used in Lucee:

org.xhtmlrenderer:flying-saucer-pdf - PDF output using iText 2.x
org.xhtmlrenderer:flying-saucer-pdf-itext5 - PDF output using iText 5.x
org.xhtmlrenderer:flying-saucer-pdf-openpdf - PDF output using OpenPDF

The manifest for the PDF tags:

Manifest-Version: 1.0
Export-Package: org.lucee.extension.pdf.tag
Bundle-ManifestVersion: 2
Require-Bundle: bouncycastle.mail;bundle-version=1.38.0,
 bouncycastle.prov;bundle-version=1.38.0,
 bouncycastle.tsp;bundle-version=1.38.0,
 org.lucee.itext;bundle-version=2.1.7,
 org.xhtmlrenderer.flying.saucer.core;bundle-version=9.1.19,
 org.lucee.flyingSaucerPDF;bundle-version=9.1.19,
 org.apache.pdfbox.fontbox;bundle-version=1.8.13,
 org.apache.pdfbox.jempbox;bundle-version=1.8.13,
 org.lucee.pdfbox;bundle-version=1.8.13,
 icepdf.core;bundle-version=3.1.0.3,
 tagsoup;bundle-version=1.2.1.0002L

Which suggests we’re operating on the bare minimum iText 2.x lib for rendering. This might provide some clues as to what might be possible with the current implementation.

We had to move from the old rendering engine for licensing reasons. And i suspect not a lot of thought has been given to how we might leverage the newer library beyond legal compliance at this time.

It’s one of those annoying things that could probably be improved dramatically if we had the capital to more readily direct resources.

I totally get it. PDFs aren’t “sexy” :smiley: Frankly, I’ve barely worked with them in the last few years until just recently. And that’s only because I’m excited at the idea of trying to take a PDF and make it more interesting.

Seems OpenHtmlToPDF may have recently fixed this bug

Yet another good reason for Lucee to switch over from flying saucer
https://lucee.daemonite.io/t/html-to-pdf-question/7120/8?u=zac_spitzer

3 Likes

I know it’s not reccomended to use cfexecute but if your server run under linux wkhtmltopdf solved all my problems with PDF generation.
Here you are with useful commons options:

<cfexecute name="/usr/local/bin/wkhtmltopdf" arguments="--dpi 300 --disable-smart-shrinking --page-size A4 --orientation Portrait --images --background --margin-bottom 10mm --margin-left 10mm --margin-right 10mm --margin-top 10mm #htmlfilein# #pdffileout#" timeout="30"></cfexecute>

Paolo

1 Like

Good timing – I actually just started playing around wkhtmltopdf over the weekend :smiley:

I have ended up using this wrapper for hkhtmltopdf for PDF generation and have found it to work very well, solving most of our PDF rendering issues.

1 Like

Second that, used it for years, never looked back or around for other PDF-tooling.