Printing from a data grid with variable height rows
Posted: Thu Sep 27, 2012 3:14 pm
I have a datagrid form that contains variable height fields. Once the dg is populated with data, it extends beyond the visible window, thus adding a vertical scroll bar. I have a separate print routine that I am writing to Print to PDF. Using the examples in the book, I can get the header to print and the first page of the dg, but I am at a loss of how to scroll the dg and print it for as many iterations as required to print everything. I also need to know when the last of the dg is printed so that I can add my footer to the report. I've tried multiple iterations of the samples in the manual, but can't get anything to work -- any help would be appreciated. Here's what I've got so far ...
The code is creating a PDF file successfully. If I uncomment the "Get the BodyText" section, the current view of the datagrid is also printed correctly, I just can't figure out how to code it so that if the datagrid is more than one page, how do I scroll the datagrid, print again, and also know when the datagrid is done. Ideally, I'd like to be able to print the footer right below the last row of the datagrid
Code: Select all
---| Get the PDF Template |---
hide stack "PDFLayout"
go stack "PDFLayout"
put the rect of graphic "header" into tHeaderRect
put the rect of graphic "body" into tBodyRect
put the rect of graphic "footer" into tFooterRect
put the rect of graphic "Total" into tTotalRect
close stack "PDFLayout"
---| Initialize PDF file creation |---
put specialfolderpath("documents") & "/" into tPDF
put "TestRPT.pdf" after tPDF
delete file tPDF --> delete any existing file first
set the printpaperorientation to "landscape"
set the printscale to 1
open printing to pdf tPDF
---| Get the PDF Header |---
go stack "PDFHeader"
set the defaultstack to "PDFHeader"
print this card from the topleft of field "txtHeader" to \
the bottomright of field "txtHeader" into tHeaderRect
close stack "PDFHeader"
---| Get the BodyText |---
#### NOTE: This works, but only prints the current view (one page) ####
## go stack "PDFBody"
## set the defaultstack to "PDFBody"
## print this card from the topleft of group "dgDetailReport" to \
the bottomright of group "dgDetailReport" into tBodyRect
## close stack "PDFBody"
##########
### This is where I need help to have the BodyText print everything in the group "dgDetailReport" ...
---| Reset the default stack and exit |---
close printing