HOW to print more page using PrintPreviewDialig??

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
 
N

Nice Chap

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.
 
R

Ron Allen

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top