CFDocument PDF font size

is there a simple solution to make generated PDFs look more like they did in Coldfusion? it would especially help to generally reduce the font size

Which version of Lucee? The PDF engine changed in 5.3. To change the font size you only need to change the CSS

5.3.2.77 so it should work - seems like my css file is not found. When I omit cfdocument, I get a HTML page that finds the css and is formatted correctly. When I wrap everything in cfdocument, the formatting is gone. Does this code look ok? could it be some caching problem?

<cfdocument format="PDF">
<html>
<head>
	<cfoutput>
		<LINK href="https://#cgi.http_host#/css/mycssfile.css" type=text/css rel=stylesheet>
	</cfoutput>	
</head>
<body>
some content here
</body>
</html>
</cfdocument>

Keep it simple and avoid the http request, i.e read the CSS file in and output it inline

Ok I now put all css directly into a style tag in the head of the created page. No difference :frowning:

So changing the CSS font size doesn’t affect the PDF output?

It works now after trying this and that. Not entirely sure what the culprit was, but probably some invalid css on my part. Thank you for your patience!!

Using a CSS file still doesn’t work - I have to specify everything inline. Is that a known bug?

did you see any requests hitting your webserver when you run CFDOCUMENT?

I just saved this as pdf.cfm under my C:\lucee\tomcat\webapps\ROOT

<cfdocument format="PDF">
    <cfoutput>
    <html>
    <head>
        <LINK href="http://#cgi.http_host#/assets/css/lib/bootstrap.min.css" type=text/css rel=stylesheet>        
    </head>
    <body>
    outputting the url as text so i can confirm it's correct

    http://#cgi.http_host#/assets/css/lib/bootstrap.min.css
    </body>
    </html>
    </cfoutput>	
</cfdocument>

and accessed http://localhost:8888/pdf.cfm and I can see the css being applied, and the css file request shows up in my C:\lucee\tomcat\logs\localhost_access_log.2019-07-01.txt log file

127.0.0.1 - - [01/Jul/2019:12:05:02 +0200] "GET /assets/css/lib/bootstrap.min.css HTTP/1.1" 200 43855
0:0:0:0:0:0:0:1 - - [01/Jul/2019:12:05:02 +0200] "GET /pdf.cfm HTTP/1.1" 200 1033

I’m running the 5.3.3.60-RC

hmm when I don’t use variables but write the http_host in there literally, it works. Oh well … I’ll do that then

it would be nice to have a CFDOCUMENT throwonerror=true option to throw an error when an external (i.e requested over http) resource returns a 404

flying saucer does allow overriding the built objects which do this
https://flyingsaucerproject.github.io/flyingsaucer/r8/guide/users-guide-R8.html#xil_17

the custom uri’s also looks interesting, that could be used to pass in server side content via a lucee:// scheme without having to fall back on http requests

Hi all

I would like to jump in here:

In my case i can not make it work, regardless if i used a variable or the hostname itself.

I also tried following like described here.

<cfdocument type="modern">
  or
<cfdocument type="classic">

No chance, my css is just ignored. Embedded images etc, work smooth.

Here is the source of my page:

<cfdocument format="PDF" bookmark="yes" pageType="A4" margintop="1.0"  type="classic">
    <cfdocumentsection>
        <cfdocumentitem type="header" evalAtPrint="true">
        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
        <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
        <title>Some invoice</title>
        <link href="https://cc.thuinformatik.ch/css/4/style-print.css" rel="stylesheet" type="text/css">
        <meta http-equiv="content-type" content="text/html; charset=utf-8">
        </head>
        <body bgcolor="#FFFFFF">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td colspan="8" height="5">&nbsp;</td>
          </tr>
          <tr>
            <td colspan="4" width="30%"><img src="https://cc.thuinformatik.ch/prod/images/thulogo.png" /></td>
            <td colspan="4" width="70%" align="right" valign="bottom">
            company name &#8226; Street &#8226; ZIP / City <br /> +123456789 &#8226; some@mail.org
            </td>
          </tr>
          <tr>
            <td colspan="8" height="5">&nbsp;</td>
          </tr>
          <tr> 
            <td colspan="8" height="1" bgcolor="#999999"></td>
        </td>
          </tr>
        </table>
        </body>
        </html>
        </cfdocumentitem>
		Some text

    </cfdocumentsection>

</cfdocument>

Rendered it looks like this

That is how it was rendered on CF9

I’m going crazy :face_with_peeking_eye: Any hints are very welcome.

:beer: Tom

I’m running:

Win2k16
JAVA_VERSION=“11.0.3”
Tomcat 9.0.14
Lucee 5.3.8.206
PDF Extension: 1.1.0.7

I’ve replicated the issue with PDF extension latest version 1.1.0.16-SNAPSHOT. cfdocumentitem tag ignores CSS and without cfdocumentitem, pfd document works fine with CSS.

Already have a related ticket for this issue [LDEV-1004] - Lucee

@cfmitrah oh, thanks for the link. It‘s a ‚show-stopper‘ here :disappointed: something i can do to help out?

Put the contents of the CSS as inline style attributes before rendering the pdf.

Its not only more efficient in terms of processing, it makes it easier to debug

Hi @Terry_Whitney

The css issue can be solved by using inline-css, right.
But i also have the other issue from the ticket mentioned above:

  • no style rendering in <cfdocumentitem type=“header” or “footer”> even with css inside it.

<cfdocumentitem type=“header” or “footer”> inside internal CSS style not working. But using inline CSS style inside <cfdocumentitem> works fine.

<cfdocument format="PDF" bookmark="yes" pageType="A4" margintop="1.0">

	<cfdocumentsection>
		<cfdocumentitem type="header">
			<html>
				<head>
					<title>Some invoice</title>
					<!--- internal css not working --->
					<style>
						body{
							background-color:yellow;
						}
					</style>
				</head>
				<body>
					<table width="100%" border="0" cellspacing="0" cellpadding="0">
					<tr>
						<!--- inline CSS works fine --->
						<td style="color:red;" colspan="4" width="70%" align="center">
							Header
						</td>
					</tr>
					</table>
					<hr>
				</body>
			</html>
		</cfdocumentitem>
		<center>body content</center>
		<cfdocumentitem type="footer">
			<!--- Inline CSS works fine  --->
			<hr><h1 style="text-align:center;color:red;"> footer is here </h1>
		</cfdocumentitem>
	</cfdocumentsection>

</cfdocument>