Coldfusion print HTML tables

I have a cfm that which generates an HTML with many tables. The content of the HTML is captured using CFSAVECONTENT. The number rows in each table varies.

<!--- Table n>
<table>
...rows x
</table>

<!--- Table n+1 --->
<table>
...rows y
</table>

<!--- Table n + 2 --->
<table>
...rows z
</table>


I want to use <cfdocument format="PDF"> to print the HTML. The requirement is that I must print as many tables as possible on one page.
If a subsequent table will not fit on the current page, there should be a form feed to the next page.
A table is not allowed to print partially on a page and then overflows to the next page.
Any code to help me solve this problem is appreciated.

Example:
Form Length = 80 rows

Table 1 has 20 rows
Table 2 has 30 rows
Table 3 has 50 rows.

Table 3 should print on a new page
Errol FarroAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gurpreet Singh RandhawaCEOCommented:
You should give custom length to the pdf document

<cfdocument
            name="certificate"
            format="PDF"
            pagetype="custom"
            pageheight="25"
            pagewidth="6.5"
            margintop="0"
            marginbottom="0"
            marginright="0"
            marginleft="0"
            unit="in"
            fontembed="true"
            backgroundvisible="true"
            localurl="true">
Errol FarroAuthor Commented:
If a table does not fit on a page, will the above force the whole table to print on a new page ?
Gurpreet Singh RandhawaCEOCommented:
if you provide

pageheight="25"
            pagewidth="6.5", you can create the long length pdf document without any page break

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
_agx_Commented:
The requirement is that I must print as many tables as possible on one page.  If a subsequent table will not fit on the current page, there should be a form feed to the next page.

How are you defining a "page"? A custom height simply avoids the issue but doesn't really solve it.  It reduces the likelihood, but tables can still cross pages.  Especially if printed with the default settings, like 8 1/2 x 11.

You might try custom CSS settings on the tables, like "page-break-after". However, frankly cfdocument has always been flaky with table breaks.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ColdFusion Language

From novice to tech pro — start learning today.