HOW to print more page using PrintPreviewDialig??

  • Thread starter Thread starter KWOK
  • Start date Start date
K

KWOK

Hi all,

I want to use a printDocument and PrintPreviewDailog to
print more pages.

I can view more pages in printPreviewDialog, but I click a
print button, it only print a last page.

my code here...
Dim PrintInv as new PrintDocument()
AddHandler PrintInv.PrintPage, AddressOf printInvoice
PrintInv.PrinterSettings.PrintRange = PrintRange.AllPages

PreInvDialog.Document = PrintInv

PreInvDialog.ShowDialog()

If PreInvDialog.ShowDialog() = DialogResult.OK Then
Me.PrintInv.Print()
End If

Thanks,
KWOK
 
To me it looks like there is some problem in your printInvoice function. Are
you managing HasMorePages variable properly ? Please post code for further
assistence and also are you initialising the varaible you are using to keep
track of printed page number when you have printed the last page ?

Note that Preview also causes PrintPage event to be called.
 
KWOK,
This sounds like you are not properly positioning the data stream (or
whatever other item contains you data) in OnBeginPrint so that the starting
pointer is left at the last position produced by PrintPreview. Your
printing logic should reset the position and allocate disposable objects in
OnBeginPrint and (of course) deallocate resouces in OnEndPrint.

Ron Allen
 
Back
Top