Skip to main content
Adrian Wright
Participant
July 16, 2021
Question

ColdFusion 2021, cfhtmltopdf & SegoeUI Font

  • July 16, 2021
  • 1 reply
  • 886 views

ColdFusion 2021 and cfhtmltopdf fail to correctly render a PDF that uses the SegoeUI font.  ColdFusion Admin indicates the font is installed.  The PDF is generated but there is no visible text.  Inspection of the generated PDF indicates there are no embedded fonts.

 

Code to Reproduce Problem

 

<cfset fntPsName = "SegoeUI">

<cfsavecontent variable="pdfContent">
	<!DOCTYPE html>
	<html>
	<head>
		<style>
			body {
				<cfoutput>
				font-family: #fntPsName# ;
				</cfoutput>
				font-size: 18px;
				color: black;
				font-style: normal;
				font-weight: normal;
				background-color: white;
			}
		</style>
		<title><cfoutput>#fntPsName#</cfoutput></title>
	</head>

	<body>
		<cfoutput>
		<h1>#fntPsName#</h1>
		</cfoutput>

		<!--- https://www.lipsum.com/ --->
		<h1>What is Lorem Ipsum?</h1>
		<p><strong>Lorem Ipsum</strong> is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
	</body>
	</html>
</cfsavecontent>

<cfhtmltopdf 
	name="pdfDoc"
	pageType="letter"
	orientation="portrait"
	destination="#fntPsName#.pdf"
	overwrite="true"
	>

	<cfoutput>#pdfContent#</cfoutput>
</cfhtmltopdf>

 

 

Environment

Server ProductColdFusion 2021
Version2021,0,01,325996
EditionDeveloper  
Operating SystemWindows 7  
OS Version6.1  

 

Question

How do I get ColdFusion 2021 to generate a PDF using the SegoeUI font?

    This topic has been closed for replies.

    1 reply

    Charlie Arehart
    Community Expert
    Community Expert
    July 17, 2021

    Adrian, I have good news: you can get that font to work, with CFHTMLtoPDF.

     

    But the solution is that you should be specifying the "font family" name, not the "postscript name" or "font face" for the font.

     

    If you look at the top of the CF admin page for the fonts, you will see it has those 3 cols. And for Segoe UI, while the "postscript name" value is indeed the "SegoeUI" as you were using, the "font family" value is instead "segoe ui". With the former (as the css font-family), you get the blank page. With the latter, you get what you expect.

     

    BTW, if one tried to use the "font face" of "Segoe UI", that also would result in a blank page, for CFHTMLtoPDF at least . The only difference between what works and what fails there is literally the case.

     

    FWIW, CFDocument WOULD work with this "Segue UI" value. But it's not that it accepts font faces. Instead I think it's just more fogiving about the case. They're indeed different PDF engines. 

     

    And you may wonder why this wasn't a problem if you just used cfoutput todisplay your pdfContent variable to the browser instead. Indeed, some browsers are more lax and let you get away with naming a font-face or postscript name in the cff font-family element. CFHTMLtoPDF does not. (To be clear, the spec for CSS fonts does indeed say that "A font family name only specifies a name given to a set of font faces; it does not specify an individual face.", so it does seem CF is getting it "right" in this case, where the browser is lax.)

     

    Anyway, back to your code, I notice that your varname holding the font is indeed fntPsName, so you were intentionally using the postscript name. 🙂 Try using the font family name and let us know how things go.

    /Charlie (troubleshooter, carehart. org)
    Adrian Wright
    Participant
    July 19, 2021

    Try using the font family name and let us know how things go.

     

    Thanks for the response Charlie.  Using the font family name produces the same result: a blank PDF 😞

    BKBK
    Community Expert
    Community Expert
    August 3, 2021

    I could reproduce the issue. I do believe it is a bug, and have reported it: https://tracker.adobe.com/#/view/CF-4212214