Why get 6 print jobs for each 6 pages

zekeman

Well-known member
Joined
May 23, 2006
Messages
224
Programming Experience
10+
I'm printing 6 pages and for each page that I print I get 6 print jobs.

There is nothing terrible about that except that I'm printing to a

psuedo printer that turns output into a PDF file.

(www.pdf995.com)

So now my problem is that instead of getting 1 PDF file that I got

with VB6, I am getting 6 PDF files (1 PDF file for each of the 6 pages).


Question: Is there a way to get 6 pages printed in one print job?

VB.NET:
'code example
[SIZE=2]for i = 1 to number_products_ordered[/SIZE]
[SIZE=2]  loadProduct(i)[/SIZE]
[SIZE=2][SIZE=2]  PrintDocument1.Print()[/SIZE][/SIZE]
[SIZE=2][SIZE=2]next i[/SIZE][/SIZE]
 
Each time you call PrintDocument.Print results in a single print job where all the printing work is done in PrintPage event handler. PrintPage must handle all pages to be printed for a single print job. You do this by keeping track of your data with a counter variable, and set e.HasMorePages True until finished. PrintPage prints a single page and you have to implement it with the counter dynamics to print more pages. When you set e.HasMorePages True the same PrintPage event handler is called again.

Here is an example that will print 10 pages in a single print job:
VB.NET:
Dim i As Integer = 0
 
Private Sub PrintDocument1_BeginPrint(ByVal sender As Object, _
                                      ByVal e As System.Drawing.Printing.PrintEventArgs) _
Handles PrintDocument1.BeginPrint
  i = 0
End Sub
 
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, _
                                     ByVal e As System.Drawing.Printing.PrintPageEventArgs) _
Handles PrintDocument1.PrintPage
  i += 1
  e.Graphics.DrawString(i.ToString, Me.Font, Brushes.Black, 10, 10)
  If i < 10 Then e.HasMorePages = True
End Sub
Moved thread to Printing forum.
 
Back
Top