T
Todd Acheson
Does anyone know how to switch trays(paper source) when printing a
multi-page document?
Here is some code I have tried, but I can never get the printer to grab from
another tray during the print of a document. If I seperate the two calls
into Page 1 and Pages 2-4, then the printer will grab from the appropriate
tray. To do this, requires I call the objPD.Print two times. This
seperates them in the print buffer, which we are trying to avoid doing.
Friend WithEvents objPD As System.Drawing.Printing.PrintDocument
Private Sub PrintMe()
Dim ps As New System.Drawing.Printing.PrinterSettings
ps.MaximumPage = 4
ps.MinimumPage = 1
ps.PrintRange = Printing.PrintRange.SomePages
ps.FromPage = 1
ps.ToPage = 4
ps.PrinterName = printerName 'Printer name was captured eariler by user
objPD.PrinterSettings = ps
m_currentPrintingPage = 1
m_lastPrintingPage = 4
objPD.DefaultPageSettings.PaperSource =
objPD.PrinterSettings.PaperSources(1) 'goldenrod colored sheet
objPD.Print()
End Sub
'Then in the printpage event:
Private Sub objPD_PrintPage(ByVal sender As System.Object, ByVal e As
System.Drawing.Printing.PrintPageEventArgs) Handles objPD.PrintPage
e.HasMorePages = False
If m_currentPrintingPage <= m_lastPrintingPage Then
If m_currentPrintingPage = 1 Then 'first page gets a goldenrod sheet
objPD.DefaultPageSettings.PaperSource =
objPD.PrinterSettings.PaperSources(1) 'goldenrod sheet
e.PageSettings.PaperSource = objPD.PrinterSettings.PaperSources(1)
'goldenrod sheet
'neither of the two above lines work, either together or seperate
Else 'all other sheets in this document get plain white paper
objPD.DefaultPageSettings.PaperSource =
objPD.PrinterSettings.PaperSources(5) 'White sheet
e.PageSettings.PaperSource = objPD.PrinterSettings.PaperSources(5)
'White sheet
'neither of the two above lines work, either together or seperate
End If
ReportDrawPageNET(e.Graphics) 'create the page that goes to the printer
m_currentPrintingPage += 1
If m_currentPrintingPage <= m_lastPrintingPage Then
e.HasMorePages = True
Else
e.HasMorePages = False
End If
e.Graphics.Dispose()
End If
End Sub
Thanks!
multi-page document?
Here is some code I have tried, but I can never get the printer to grab from
another tray during the print of a document. If I seperate the two calls
into Page 1 and Pages 2-4, then the printer will grab from the appropriate
tray. To do this, requires I call the objPD.Print two times. This
seperates them in the print buffer, which we are trying to avoid doing.
Friend WithEvents objPD As System.Drawing.Printing.PrintDocument
Private Sub PrintMe()
Dim ps As New System.Drawing.Printing.PrinterSettings
ps.MaximumPage = 4
ps.MinimumPage = 1
ps.PrintRange = Printing.PrintRange.SomePages
ps.FromPage = 1
ps.ToPage = 4
ps.PrinterName = printerName 'Printer name was captured eariler by user
objPD.PrinterSettings = ps
m_currentPrintingPage = 1
m_lastPrintingPage = 4
objPD.DefaultPageSettings.PaperSource =
objPD.PrinterSettings.PaperSources(1) 'goldenrod colored sheet
objPD.Print()
End Sub
'Then in the printpage event:
Private Sub objPD_PrintPage(ByVal sender As System.Object, ByVal e As
System.Drawing.Printing.PrintPageEventArgs) Handles objPD.PrintPage
e.HasMorePages = False
If m_currentPrintingPage <= m_lastPrintingPage Then
If m_currentPrintingPage = 1 Then 'first page gets a goldenrod sheet
objPD.DefaultPageSettings.PaperSource =
objPD.PrinterSettings.PaperSources(1) 'goldenrod sheet
e.PageSettings.PaperSource = objPD.PrinterSettings.PaperSources(1)
'goldenrod sheet
'neither of the two above lines work, either together or seperate
Else 'all other sheets in this document get plain white paper
objPD.DefaultPageSettings.PaperSource =
objPD.PrinterSettings.PaperSources(5) 'White sheet
e.PageSettings.PaperSource = objPD.PrinterSettings.PaperSources(5)
'White sheet
'neither of the two above lines work, either together or seperate
End If
ReportDrawPageNET(e.Graphics) 'create the page that goes to the printer
m_currentPrintingPage += 1
If m_currentPrintingPage <= m_lastPrintingPage Then
e.HasMorePages = True
Else
e.HasMorePages = False
End If
e.Graphics.Dispose()
End If
End Sub
Thanks!