Has anyone successfully rendered Font Awesome icon...
# adobe
d
Has anyone successfully rendered Font Awesome icons in a PDF using CFHTMLTOPDF in ACF2023? It works fine in WKHTMLTOPDF, but switching to CFHTMLTOPDF the icons no longer show. It doesn't seem isolated to Font Awesome. I've tried a handful of icon fonts and they all don't show. I thought the CF2023 PDF engine would be up to the task. Anyone got any ideas? Thanks in advance. We want to move 'forward' with CFHTMLTOPDF as WKHTMLTOPDF is stuck on an older rendering engine and lacks modern CSS features.
g
Which version of the Font Awesome library are you using? (I'll test CF2023 when I have some time available.) Could you provide some basic, sample HTML? Which modern CSS features does CFHTMLTOPDF support that WKHTMLTOPDF doesn't? (I know that WK doesn't work when embedding a Google Map, but that's because Google's feature detection doesn't pass some tests that were added to restrict older HTML renderers.)
d
@gamesover We're using the latest FA library (v6). I'll try and get a basic example for you to try shortly. With WK we have to develop using some HTML/CSS from the caveman days. Lots of inline styles etc. We want to utilise modern CSS3 stuff. Also feeds like WK is not developed any more.
g
We don't use many inline styles with WK. I'd say it's a lot more modern than anything we attempted using CFDocument. I thought that CFHTMLTOPDF was very similar to WK (if not the same). Are you generating valid HTML? We encountered some rendering issues in the past and use jsoup to enforce valid HTML. I wrote a test script that fetches header, body & footer HTML to generate PDF (& thumbnail) samples using CFDocument, CFHTMLTOPDF and WKHTMLTOPDF. Once I have some of your sample code, I can review. I'm not sure what to do about CFHTMLTOPDF as we support various versions of CF and using WK provides us with a baseline that consistently works & looks the same (and can be run/troubleshot offline.)
d
@gamesover in particular we're wanting to use grid layouts etc. It's early days in our testing. It seems to render a bit faster than WK too. Trying to put an example together is a bit tricky as it requires local assets (font awesome kits, css etc) @Mark Takata (Adobe) I see you've done some examples with https://github.com/MarkRTakata/CF2023/tree/main/html2pdf, do you know any reason why it won't render icon fonts? Would be good to have a matrix on the current CSS/HTML/JS that CFHTMLTOPDF on CF2023 supports.
👍 2
m
interesting, it could be a license issue? are font awesome fonts licensed for delivery/deployment via PDF/print? if this is currently a missing feature @Charvi might be able to look into adding it. There are still a lot of checkboxes to turn on in the PDF engine potentially...
d
@Mark Takata (Adobe) @Charvi It would be really helpful if you could get this incorporated. Font Awesome is a very popular (if not the most popular) icon font out there. Would only take you a few mins to get a html doc rendering it to test. We're currently having to strip out all our icons to make it work 😞 Also, there seems to be a bug with unit="cm" on cfhtmltopdf, seems to think it's inches or something. I know there was a bug fixed (not released yet) for orientation, this may have been fixed too?
@gamesover @Mark Takata (Adobe) @Charvi Ok got an example to try where cfhtmltopdf breaks down. If you try render this as a pdf:
<html>
<head>
<link rel="stylesheet" href="<https://kit.fontawesome.com/2023952664.css>" crossorigin="anonymous">
</head>
<body>
<h1>There should be a star, a building and a phone icon showing below:</h1>
<h2><i class="far fa-user"></i></h2>
<h2><i class="far fa-building"></i></h2>
<h2><i class="far fa-phone-alt"></i></h2>
</body>
</html>
You'll see that only the first icon (star) gets rendered, this is a screenshot of what I get in CF2023: https://drive.google.com/file/d/1AIOnarVq1ibrNrEnmHtvi_R5knGnBVjX/view?usp=drive_link
m
oh weird that just the first renders... that CSS for FA included the 2nd two icons I am assuming?
g
We still use self-hosted FAv4 library with WKHTMLTOPDF and it outputs 3 icons from our library, but CFHTMLTOPDF on CF2023 isn't rendering anything for us when using either FA self-hosted v4 or remote v6. (I can also render FA icons using our self-hosted V6 libraries w/shims.) When using WKHTMLTOPDF, there a "javascript delay" option that we often use, but notice that there's no similar option for CFHTMLTOPDF. I wonder if FA is performing a lazy load of the libraries & progressively updating the icons "after" the conversion to PDF has already initiated.
d
@Mark Takata (Adobe) yep that css includes all icons, you can see it works by just putting it in a .html file and opening it.