So I followed the example from the docs to print a datagrid. For some
reason I always get validNextPage to be true even when there is not
enough data to fill a page.
The example works fine but I cannot get it to work with my application.
Here is the code:
private function printExecution():void {
var printJob:FlexPrintJob = new FlexPrintJob;
if ( printJob.start() ) {
var thePrintView:FormPrintView = new FormPrintView();
thePrintView.visible = false;
thePrintView.includeInLayout = false;
Application.application.addChild(thePrintView);
thePrintView.width = printJob.pageWidth;
thePrintView.height = printJob.pageHeight;
thePrintView.acct = acctArray[accts.selectedIndex];
thePrintView.fromDate =
df.format(fromDate.selectedDate);
thePrintView.toDate = df.format(toDate.selectedDate);
thePrintView.totalTrades = numFmt.format(totalTrades);
thePrintView.totalQty = numFmt.format(totalQty);
thePrintView.totalComm = total.format(totalComm);
thePrintView.dg_printDG.dataProvider =
dg_report.dataProvider;
thePrintView.showPage("single");
thePrintView.footer.includeInLayout = true;
thePrintView.footer.visible = true;
trace("VALIDNEXTPAGE1 = " +
thePrintView.dg_printDG.validNextPage)
if (!thePrintView.dg_printDG.validNextPage) {
printJob.addObject(thePrintView);
} else {
thePrintView.showPage("first");
printJob.addObject(thePrintView);
thePrintView.pageNumber++;
while(true) {
thePrintView.dg_printDG.nextPage();
thePrintView.showPage("last");
trace("VALIDNEXTPAGE2 = " +
thePrintView.dg_printDG.validNextPage)
if
(!thePrintView.dg_printDG.validNextPage) {
printJob.addObject(thePrintView);
break;
} else {
thePrintView.showPage("middle");
printJob.addObject(thePrintView);
thePrintView.pageNumber++;
trace("PAGE = " +
thePrintView.pageNumber);
}
}
}
Application.application.removeChild(thePrintView);
}
printJob.send();
}
Any help would be appreciated...I've been banging my head for a few
days now.
thanks!