• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Intermittent application of external CSS styling to CFDocument/CFDocumentSection

New Here ,
Feb 08, 2019 Feb 08, 2019

Copy link to clipboard

Copied

Howdy all,

   I've recently encountered an issue with a 300+ page PDF generated by a scheduled process. The scheduler generates our institutional organization chart and has been working great. However, we have found instances where a few pages (~4 or so depending upon run) are flat and have no CSS styling applied to them. All other pages are flawless. Even more puzzling is that in some instances, the styling will be applied to parts of the content, but not others. So in one case, the header and footer are properly styled, but the page body has no styling applied. In another case, on one page only the footer is missing styling.

   Given this is all rendered via iteration, the only thing I can think of is maybe an intermittent connectivity issue to the CSS sheet. We have recently moved our data center, so we have had some squirrely routing issues every now and then. I've learned from experience that it is best to include the CSS in both the CFDocument AND in every CFDocumentSection. I have not tried @Import on the styling link yet, but have not seen any difference when using it in the past with other PDF styling issues. It would seem like CFDocument SHOULD be caching the style sheets to reduce remote references (and impact of connectivity issues), but IF it is a connectivity issue, then it would appear there is no caching.

   I have included the code below. Any thoughts or suggestions would be greatly appreciated. Thank you.

JJ

<!--- BUILD THE PDF --->

<CFDOCUMENT format="pdf" filename="#orgPDF.osPDFDirectory##orgPDF.PDFFileName#" overwrite="yes">

<!--- BRING IN THE STYLE SHEET --->

<link href="../../styles/orgChartPrintStyles.css" rel="stylesheet" type="text/css" media="print"/>

<!--- BUILD EACH LEVEL --->

<CFLOOP list="#orgChart.Walk#" item="CurrentNode">

<!--- SAVE CONTENT IN CASE THERE IS NO CONTENT FOR DOCUMENT SECTION --->

<CFSAVECONTENT variable="orgPDF.PDFContent">

<!--- PRINT CURRENT LEVEL AND RETURN CHILD LIST --->

<CFSET childList = renderOrgLevel(currentNode)>

</CFSAVECONTENT>

<!--- NOT LEAF, THEN USE CONTENT --->

<CFIF childList NEQ "">

<CFDOCUMENTSECTION>

<link href="../../styles/orgChartPrintStyles.css" rel="stylesheet" type="text/css" media="print"/>

#orgPDF.PDFContent#

</CFDOCUMENTSECTION>

</CFIF>

<!--- CLEAR PREVIOUS CONTENT --->

<CFSET orgPDF.PDFContent = "">

</CFLOOP>

</CFDOCUMENT>

Views

311

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 09, 2019 Feb 09, 2019

Copy link to clipboard

Copied

LATEST

My experience has been that this works a lot better if you literally embed the styles in your CFDOCUMENT tag, instead of linking to external CSS files. You can do this by using CFOUTPUT to output the contents of the CSS file within a STYLE block, if I recall correctly.

Dave Watts, Eidolon LLC

Dave Watts, Eidolon LLC

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation