Re: Printer settings are ignored

We’re also having issues with printerSettings being totally ignored (other than the printer name).

We’re trying to set the PaperSource to a particular tray.

We generate an AsposeWordsPrintDocument object from our document and set the DefaultPageSettings.PaperSource property but it’s totally ignored when we call the Print() method. It does go to the right printer as specified in the PrinterSettings, but PaperSource is ignored.

Hi Richard,

Thanks for your inquiry.

A single Word document can consist of multiple sections that specify pages with different sizes, orientation and paper trays. AsposeWordsPrintDocument overrides OnQueryPageSettings to properly select paper size, orientation and paper source when printing a Word document.

Microsoft Word stores printer specific values for paper trays in a Word document and therefore, only printing on the same printer model as the one that was selected when the user specified the paper trays will result in printing from the correct trays. If you print a document on a different printer, then most likely the default paper tray will be used, not the trays specified in the document.

Following code example changes all sections in a document to use the default paper tray of the selected printer.

Document doc = new Document(MyDir + "in.docx");
// Find the printer that will be used for printing this document. In this case it is the default printer.
// You can define a specific printer using PrinterName.
System.Drawing.Printing.PrinterSettings settings = new System.Drawing.Printing.PrinterSettings();
// The paper tray value stored in documents is completely printer specific. This means
// The code below resets all page tray values to use the current printers default tray.
// You can enumerate PrinterSettings.PaperSources to find the other valid paper tray values of the selected printer.
foreach(Section section in doc.Sections)
{
    section.PageSetup.FirstPageTray = settings.DefaultPageSettings.PaperSource.RawKind;
    section.PageSetup.OtherPagesTray = settings.DefaultPageSettings.PaperSource.RawKind;
}

Could you please share your input document and code here for testing? I will investigate the issue and provide you more information.