pdfprintingcoldfusioncfdocument

CFDocument PDF - Header Gets Cut Off When Printing


I have a PDF that I generate via the CFDocument tag. When it generates the PDF and you click on the "printer" icon to pop up the print dialog. For Page Sizing & Handling if it's set to either "Fit" or "Shrink oversized pages", it prints fine. If "Actual size" is selected then the header gets shifted off the page and gets chopped off. I'm using ColdFusion 11 on Windows 7.

To recreate this, I removed all my styles and did a simple test with the following basic code:

<cfdocument format="PDF" saveAsName="test_#dateFormat(now(),'yyyymmdd')#T#timeFormat(now(),'hhmmss')#.pdf">
   <cfdocumentitem type="header">HEADER</cfdocumentitem>
   <cfdocumentsection>
       BODY
   </cfdocumentsection>
   <cfdocumentitem type="footer">
       #cfdocument.currentpagenumber# / #cfdocument.totalpagecount#
   </cfdocumentitem>
</cfdocument>

Which generates the following PDF: PDF Generated

Then I click the "Printer" icon which pops up the printer settings: Shrink Oversized Pages

If you look closely to the preview image in the dialog box, you can see that the header text is within the document. Now if I select "Actual size" instead, it gives the following: Actual Size

If you look at the preview, this time you can see that everything shifted up and the header is partially outside the document which results in half of the header getting chopped off and illegible when printed.

Anyone know why this is happening and how to fix it?


Solution

  • To fix this, I ended up playing around with the pageWidth and pageHeight along with the pageType attributes in CFDocument.

    <cfdocument format="PDF" pageType="custom" pageWidth="8.5" pageHeight="10.75" saveAsName="test_#dateFormat(now(),'yyyymmdd')#T#timeFormat(now(),'hhmmss')#.pdf">
       <cfdocumentitem type="header">HEADER</cfdocumentitem>
       <cfdocumentsection>
           BODY
       </cfdocumentsection>
       <cfdocumentitem type="footer">
           #cfdocument.currentpagenumber# / #cfdocument.totalpagecount#
       </cfdocumentitem>
    </cfdocument>
    

    Standard letter size is 8.5" X 11" (which is default in CFDocument) so I just slightly adjusted the height to 10.75" and the header stayed within the page boundaries even when I clicked "Actual size" in the print dialog. Seems kind of odd that I have to do this to make the header fit on the page without getting chopped off but it works. Adjusting the height any further just scales the header too much and doesn't look good so I went with 10.75".