我已经使用cfdocument生成了pdf。添加标题使用cfpdf="addHeader"当打印在纸上或在打印预览中显示时,此标题不会打印。下面是代码
<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" />
任何帮助都将非常感激。谢谢你。
<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>
添加属性showOnPrint="yes"
:
<cfpdf action="addHeader" showOnPrint="yes" name="pdfwithHeader" source="PDFVariable" align="left" text="#pdfHeaderText#" overwrite="yes"></cfpdf>