Nov 24 2006

CFDocument and Default Page Breaks

Published by Mike Munhall at 8:05 am under ColdFusion,Web Development

Recently I got to use ColdFusion’s <cfdocument> tag extensively on a project to convert HTML reports to PDF. A coworker and I ran across the same issue when using the tag, where the page breaks in the PDF would occur right through the middle of some text. No pixels are lost when the page break occurs; the document just continues on the next page right where it left off on the previous one. You would expect, however, that the page would break would occur at the end of a table row or some other logical section, just as it does when printing on paper.

Coworker Alex found that you can get those results only if you include the margin attributes (marginbottom, marginleft, marginright, margintop) and set all of the values to zero. This adds page breaks where you would expect them to be, although it brings the document out to the edges of the page. Since <cfdocument> supports CSS1 and CSS2, the workaround for this second problem is to add margins to your document when outputting a PDF.

I personally don’t care for the workaround. It defeats much of the purpose of <cfdocument>, which is to easily be able to convert HTML documents to PDF without much, if any, effort. I’m not saying that the tag is worthless. In fact, even with this minor flaw, I think it’s the best thing since sliced sourdough (with tons of butter). My preference is to not programatically adjust the styles or create new styles and just allow the page breaks to fall where they fall.

I’m hoping this is a bug with <cfdocument> that will be fixed in Scorpio, but I don’t feel like doing the research to find out.

4 responses so far

4 Responses to “CFDocument and Default Page Breaks”

  1. duncanon 10 Dec 2007 at 6:26 am

    Looks like WordPress is stripping HTML out of your blogpost:
    - Since supports CSS1
    and
    - It defeats much of the purpose of ,

    I’m guessing should say:
    - Since <cfdocument> supports CSS1
    and
    - It defeats much of the purpose of <cfdocument>,

  2. Mike Munhallon 10 Dec 2007 at 7:40 am

    Thanks for the tip. Many of the posts on this blog, including this one, broke when ported from another blog. I’ve updated this one with the appropriate entities.

  3. Joshon 27 Mar 2008 at 2:14 pm

    there is a hot fix for CF 7.02 that fixes this issue.

    http://kb.adobe.com/selfservice/viewContent.do?externalId=kb402465&sliceId=1

  4. Joshon 27 Mar 2008 at 2:18 pm

    Looks this needs to be applied as well

    http://kb.adobe.com/selfservice/viewContent.do?externalId=kb402093&sliceId=1

Trackback URI | Comments RSS

Leave a Reply