Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

Set PrinterSettings.DefaultPageSettings.PaperSource does not seem to work (VB.Net)

$
0
0

Hi all,
(thanks for any help in advance)

I'm having no luck setting the paper source when sending a page to a printer in a windows form application in Visual Studio Prof. 2012 using VB.net. Here is the scenario:

  • Display a list of printers to the user - user chooses which printer to use
  • I create a new PrintDocument object and set the PrinterSettings.PrinterName property to the selected printer name
  • User then selects the desired paper source from the printer's available paper sources
  • I step through the PrinterSettings.PaperSources until I find the right one and then set PrinterSettings.DefaultPageSettings.PaperSource to that one

Here is the actual code from a little test app:

pDocument = New PrintDocument() pDocument.PrinterSettings.PrinterName = lbPrinters.SelectedItem ' step through the available paper sources and set it to the right one For psrc = 0 To pDocument.PrinterSettings.PaperSources.Count - 1 If pDocument.PrinterSettings.PaperSources(psrc).SourceName = lbPaperSources.SelectedItem.ToString() Then pDocument.PrinterSettings.DefaultPageSettings.PaperSource = pDocument.PrinterSettings.PaperSources.Item(psrc) End If Next pDocument.DocumentName = "Garys Test Document" pDocument.Print()

When I look at the properties in debug mode in Visual Studio as I'm stepping through the code these all seem to be set correctly. I've even put a breakpoint in the PrintDocument PrintPage event and re-examined the properties (like PrinterSettings.DefaultPageSettings.PaperSource) and they seem to be OK (for instance I'll choose the 'Manual Feed' on my old LaserJet 4L here at home and in the PrintPage event sure enough PrinterSettings.DefaultPageSettings.PaperSource SourceName property still says 'Manual Paper Feed'

However, the printer seems to always use the default tray, and no matter what tray I choose the print pages always come from the same source. This is the same whether I run my little test app here or in the office with large, multi-tray printers.

I would be grateful for some help - as far as I can see from the MSDN docs I am doing what is required. I can supply the test app if required.

Many thanks in advance


Viewing all articles
Browse latest Browse all 12583

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>