COLDFUSION: cfdocument and forcing

I am creating a dynamic PDF file in ColdFusion and have a "pagebreak" problem. The page in question can have 1 entry or up to 60+ entries. Each entry is displayed in 2 rows of the table. Some of the returned records are shared between pages (the first line is at the end of the first page, the second line is the top line of the next).

An example of a record in displayable HTML:

<tr> <td>Title</td><td>Price</td> <td colspan="2">Description</td> </tr> 

In a client request I am trying to display = <9 entries per page .

Here is an example I tried:

 <cfdocument format="PDF"> <cfoutput query = "sqllookup"> <cfset loopcount = loopcount + 1> <cfif loopcount EQ '9'> <cfdocumentitem type="pagebreak" /> <cfelse> <tr> <td>#Title#</td><td>#Price#</td> <td colspan="2">#Description#</td> </tr> </cfif> </cfoutput> </cfdocument> 

This does not work (it only hides the 9th record). I tried several different ideas, and now I'm at a standstill. Am I watching something?

Thanks in advance.

ColdFusion MX 7. (I also ran the fix for the text clipping issue. Http://kb2.adobe.com/cps/402/kb402093.html )

+6
coldfusion pdf page-break cfdocument
source share
4 answers

You hide the ninth record because you choose between displaying it and showing it:

 if 9th record break page else show record end if 

What do you like more:

 <cfoutput query = "sqllookup"> <!--- this is the 9th row, because 9 mod 9 is 0 ---> <cfif not sqllookup.currentrow mod 9> <cfdocumentitem type="pagebreak" /> </cfif> <tr> <td>#Title#</td><td>#Price#</td> <td colspan="2">#Description#</td> </tr> </cfoutput> 
+7
source share

After dealing with this issue for several months, I found that wrapping the contents of td with a div (i.e. <tr><td><div>Cell Contents</div></td></tr> ) would prevent tearing pages inside the line. With this setting, a page break, which usually separates a line between pages, will fall in front of the line, creating a few extra spaces at the end of the first page and placing the line at the beginning of the next page.

Note on multi-cell rows: One td-nested div is sufficient to trigger the behavior described above for the entire row.

 <tr> <td>Blah blah blah blah blah</td> <td>Gnar gnar gnar gnar gnar</td> <td><div>Soda POP soda POP soda POP</div></td> <!--- the fix ---> <td>Stellar!</td> </tr> 
+1
source share

Try adding style="page-break-inside: avoid;" to any element that you do not want to share between 2 pages.

For example,

 <tr style="page-break-inside: avoid;"> <td>#Title#</td><td>#Price#</td> <td colspan="2">#Description#</td> </tr> 
0
source share

For me, having tried all the tricks and tips of the forum, etc. - the only thing that worked in cf8 for large blocks of code (including images, tables, div block, etc.):

  • wrap the non-page part with

    <div>...</div>

  • but super simple <br> after it in a new line (in code) for example.

    <div> ... your stuff ... </div> <br>

what worked, damn knows why ...

0
source share

All Articles