0

Why the cfhtmltopdf does not display the googleapis font?

<cfhtmltopdf encryption = "AES_128">
<html>
<head>
    <!--Add GoogleFonts-->
  <link href="https://fonts.googleapis.com/css?family=Aguafina+Script|Alex+Brush|Bilbo|Condiment|Great+Vibes|Herr+Von+Muellerhoff|Kristi|Meddon|Monsieur+La+Doulaise|Norican|Nothing+You+Could+Do|Parisienne|Permanent+Marker|Sacramento|Yellowtail" rel="stylesheet">
</head>
<body>

        <p id="displaySignature" style="font-family: Meddon, cursive; font-size: 30px;">Test</p>

</body>

</html>
</cfhtmltopdf>

It ignores the font style.

myTest532 myTest532
  • 2,091
  • 3
  • 35
  • 78
  • It might be a timing issue. Google web fonts need to load before they can be used, and my guess is that cfhtmltopdf is not going to wait until they load, or maybe it doesn’t load external fonts. – Redtopia Feb 21 '19 at 22:42
  • I think it doesn't load external fonts. Do you know any way to display it in a pdf using ColdFusion? – myTest532 myTest532 Feb 21 '19 at 22:48
  • Checkout the answer below... maybe that will work. Seems like you should be able to use external fonts, but you might need to use something else besides cfhtmltopdf. It also might depend on the version of ACF/Lucee you're using. Ortus just came out with a PDF generator for Lucee https://www.ortussolutions.com/products/ortuspdf – Redtopia Feb 21 '19 at 23:03
  • I just tested the initial HTML sample w/GoogleFonts using WKHTMLTOPDF.exe (which I use instead of CFPDF & CFHTMLTOPDF) and it generated a perfect PDF without having to jump through any hoops (adding a JS delay) or even hosting the HTML file on a traditional web server. SYNTAX: `wkhtmltopdf.exe test.htm test.pdf` – James Moberg Feb 22 '19 at 00:38
  • Do I need to install WKHTMLTOPDF in my server? – myTest532 myTest532 Feb 22 '19 at 04:36
  • Maybe not helpful but: Works on my machine. I'm on CF 11, copied your code to an empty .CFM page, added CFOUTPUT tags, opened the page in a browser and got some fancy looking `Test`. Does your server generating the pdf have access to the internet? Can it reach google?You can download the font file from https://github.com/google/fonts/tree/8143a3e2d9f7656bc7e551f96d6294d47882d907/ofl/meddon – Bernhard Döbler Feb 22 '19 at 08:45
  • I think the server has access to the internet because without the cfdocument it displays the fancy Test string. It is the same server – myTest532 myTest532 Feb 22 '19 at 15:54

2 Answers2

1

You can goto the ColdFusion administrator -> Server Settings -> Font Management and import the fonts that are required by you and try.

kz2014
  • 324
  • 1
  • 4
  • 12
0

If you look at this answer, using

@import url('https://fonts.googleapis.com/css?family=Open+Sans');

will import the contents of the CSS file into your HTML. Using @import will actually "defer the loading of the included resource until the file is fetched", which may be exactly what you need.

Adrian J. Moreno
  • 14,350
  • 1
  • 37
  • 44