PDF generated using CFDocument with CFPDF Action="Header" does not print on Paper or preview

216 Views Asked by At

I have generated pdf using cfdocument. Added header using cfpdf="addHeader". This header doesn't print when printed on paper or show up in print preview. Here is the code

<cfsavecontent  variable="pdfHeaderText">
    Daily Consumer Report
</cfsavecontent>

<cfdocument name="PDFVariable" format="PDF" orientation="portrait" marginbottom="1" marginleft="0.5" marginright="0.5" margintop="1" overwrite="true" >
    <cfdocumentsection name="Title">
        <cfinclude template="MyReportData.cfm">
    </cfdocumentsection>
</cfdocument>

<cfpdf action="addHeader" name="pdfwithHeader" source="PDFVariable" align="left"
    text="#pdfHeaderText#" overwrite = "yes">
</cfpdf>

<cfheader name="Content-Disposition" value="attachment; filename=DailyReport.pdf" />
<cfcontent type="application/pdf" file="#Variables.DESTINATION_DIR#/#PDFfilename#" deletefile="yes" />

Any help would be much appreciated. Thank you.

2

There are 2 best solutions below

1
Merle_the_Pearl On
   <cfdocument name="PDFVariable" format="PDF" orientation="portrait" marginbottom="1" marginleft="0.5" marginright="0.5" margintop="1" overwrite="true" >

     <cfdocumentitem type="header">
           <cfinclude template="HEADERDATA.cfm">
     </cfdocumentitem>

     <cfdocumentitem type="footer">
           <cfinclude template="FOOTERDATA.cfm">
     </cfdocumentitem> 

           --------
           YOU COULD ALSO JUST PULL IN A .CFM TEMPLATE WITH COLDFUSION/HTML/CSS
           <cfinclude template="HEADERDATA.cfm">
           --------

     <cfdocumentsection name="Title">
           <cfinclude template="MyReportData.cfm">
     </cfdocumentsection>

   </cfdocument>
0
Craig Verrastro On

Add the attribute showOnPrint="yes":

<cfpdf action="addHeader" showOnPrint="yes" name="pdfwithHeader" source="PDFVariable" align="left" text="#pdfHeaderText#" overwrite="yes"></cfpdf>