Copy link to clipboard
Copied
I'm trying to generate PDF from a database.
I display my data in tables that can be 2 or 3 rows or sometimes 100 rows and multiple sheets. Problem is, the tables often break mid row. Which would be fine, but then on the next page, the table is 'open' with no top border.
I have tried two methods so far:
1. CFDocument creating PDF. I am having a difficult time with the lack of normal CSS control. I can't seem to get it to look right.
2. Create a normal page, then print to PDF. I like this method, because I have a lot more control on the look of the tables.
Both of these methods result in the pagination issue.
So, my question is:
1. Is there a solution to either of these on the pagination?
2. Is there another method that I am unaware of?
I thank you in advance for your consideration.
Copy link to clipboard
Copied
Here is what it looks like:
This is actually another option I tried - flashpaper then print to PDF.
Copy link to clipboard
Copied
Hi Dan,
If I understand what you are trying to accomplish, try the example code below:
The example assumes there are 30 total records and you want to display only 10 per page. You will need to add additional <cfif>(s) to accommodate what you to believe to be the maximum number of records to be.
Hope this helps you out.
Leonard B
===== Example Code =====
<!--- Insert header content here --->
>> Will display first 10 records on page 1
<cfoutput query="rsRecords" startrow="1" maxrows="10">
#NumberFormat(currentrow,00)# - #BillName#<br />
</cfoutput>
>> Will display second set of 10 records on page 2
<cfif rsRecords.RecordCount gt 10>
<cfdocumentitem type="pagebreak" />
<!--- Insert header content here --->
<cfoutput query="rsRecords" startrow="11" maxrows="10">
#NumberFormat(currentrow,00)# - #BillName#<br />
</cfoutput>
</cfif>
>> Will display third set of 10 records on page 3
<cfif rsRecords.RecordCount gt 20>
<cfdocumentitem type="pagebreak" />
<!--- Insert header content here --->
<cfoutput query="rsRecords" startrow="21" maxrows="10">
#NumberFormat(currentrow,00)# - #BillName#<br />
</cfoutput>
</cfif>
Below will display current page number and total page number along with date and time printed
<!--- Footer section for each generated page --->
<cfdocumentitem type="footer">
Page <cfoutput>#cfdocument.currentpagenumber#</cfoutput> of <cfoutput>#cfdocument.totalpagecount#</cfoutput> — Printed <cfoutput>#DateFormat(CreateODBCDate(now()),"mm/dd/yy")# at #TimeFormat(CreateODBCTime(now()),"h:mm:ss tt")#</cfoutput>
</cfdocumentitem>
</cfdocument>
Copy link to clipboard
Copied
Thanks Leonard.
I do this programming on the side, if boss understood how important this will be, he'd give me more time. Anyhow, I am getting back now to tackle this issue.
The problem with this solution is that I don't know how big each of the items are going to be. They may be 4 lines as I have shown, but in cases they will be 20 lines.
I think my solution will be to have a temp variable to hold the item number after the page break. THat is the user will create the doc, and then decide he wants a page break after item #7. He will then click #7 and rerun. Then click #23, and so on until he is done. Bit awkward but it will do the trick.
Wish there was some way I could measure where on the PDF sheet I was at all times. Then when I'm near the bottom I can <cfif> something to put in a page break. hmmmm.