Print Document

  • Thread starter Thread starter Charles A. Lackman
  • Start date Start date
C

Charles A. Lackman

Hello,

I am creating a print document and it works well, but how do I make the
print object only print pages 1, 2, 5?
This is how I am currently building the print function.

Private WithEvents docToPrint As New Printing.PrintDocument

Private Sub Button1_Click ....
..PrintDocumentPages(iStartPage, iLastPage, iCopies)
End Sub

Public Sub PrintDocumentPages(ByVal FirstPage As Integer, ByVal LastPage As
Integer, ByVal TheCopies As Integer)
Me.docToPrint = New Printing.PrintDocument
docToPrint.PrintController = New
System.Drawing.Printing.StandardPrintController
For I = 1 To TheCopies
CurrentPage = FirstPage
LastPage = LastPage
docToPrint.Print()
Next I
MessageBox.Show("Print Job Sent To Printer", "Print Completed",
MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub

Private Sub document_PrintPage(ByVal sender As Object, ByVal e As
System.Drawing.Printing.PrintPageEventArgs) Handles docToPrint.PrintPage

Make Graphic Object's....

End Sub

Any Assistance is greatly appreciated,

Chuck
 
Charles,
I'd first set up an array with the pages to be printed in it and a page
counter (CurrentPage). Then in your PrintPageCall check to see if the
current page is in the array and, if not, move to the next page until you
have a page to be printed or are at end of data.

Ron Allen
 
Hello,

Thank you for you assistance. I am not sure I understand what you are
saying. If I add the following to Document_PrintPage it does not work
properly.

Private Sub document_PrintPage(ByVal sender As Object, ByVal e As
System.Drawing.Printing.PrintPageEventArgs) Handles docToPrint.PrintPage


'In this example CurrentPage = 0

if CurrentPage = 0 then exit sub ' This gives me a blank page.
SaveBitMap = New Bitmap(CType(MainForm.DisplayPic(CurrentPage - 1).Image,
Bitmap))


Charles,
I'd first set up an array with the pages to be printed in it and a page
counter (CurrentPage). Then in your PrintPageCall check to see if the
current page is in the array and, if not, move to the next page until you
have a page to be printed or are at end of data.

Ron Allen
 
Hello,

Thank you for your help, It directed me in the right direction. I just took
a while for it to sink in.

Thanks,

Chuck

Hello,

I am creating a print document and it works well, but how do I make the
print object only print pages 1, 2, 5?
This is how I am currently building the print function.

Private WithEvents docToPrint As New Printing.PrintDocument

Private Sub Button1_Click ....
..PrintDocumentPages(iStartPage, iLastPage, iCopies)
End Sub

Public Sub PrintDocumentPages(ByVal FirstPage As Integer, ByVal LastPage As
Integer, ByVal TheCopies As Integer)
Me.docToPrint = New Printing.PrintDocument
docToPrint.PrintController = New
System.Drawing.Printing.StandardPrintController
For I = 1 To TheCopies
CurrentPage = FirstPage
LastPage = LastPage
docToPrint.Print()
Next I
MessageBox.Show("Print Job Sent To Printer", "Print Completed",
MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub

Private Sub document_PrintPage(ByVal sender As Object, ByVal e As
System.Drawing.Printing.PrintPageEventArgs) Handles docToPrint.PrintPage

Make Graphic Object's....

End Sub

Any Assistance is greatly appreciated,

Chuck
 
Back
Top