PrinterSettings.PaperSource

  • Thread starter Thread starter Todd Acheson
  • Start date Start date
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!
 
STILL NO LUCK.

Evidently, you can change some settings in the QueryPageSettings event and
the PagePrint event, but changing drawers in the printer (PaperSource) is
ignored.

Has anyone else had this problem and/or know of a workaround?
 
before you kill yourself trying to fix this in code, make sure that the
printer driver is capable of it. Use Word to send a three page test
document to the printer, with each of the pages coming from a different
drawer. See what happens. If word can do it, you should be able to, but if
word cannot, you need to update your print driver.

Sorry I'm not much help. I just haven't done much printing in code for
about a decade.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
 
Nick,
Excellent advice.
It so happens the printer I am working with does not switch drawers once a
document is sent to it. Another printer we have which is similar but an
updated version does allow switching of drawers. I tested in Word like you
recommended.

-Todd

--
Todd Acheson

Nick Malik said:
before you kill yourself trying to fix this in code, make sure that the
printer driver is capable of it. Use Word to send a three page test
document to the printer, with each of the pages coming from a different
drawer. See what happens. If word can do it, you should be able to, but if
word cannot, you need to update your print driver.

Sorry I'm not much help. I just haven't done much printing in code for
about a decade.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
 
Back
Top