We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Tray setting via ASPOSE.WORD routines

Hi ,
I have a requirement to be able to set the trays to use so that pages one prints to tray 3 and the remainding pages to tray 2. The print drive I need to talk to is
So my question is does ASPOSE.WORD support the ability to talk to a print driver and if so could you please provde me with some sample code.
Many thanks

Hi Tim,

Thanks for your inquiry. Aspose.Words supports printing as per the paper tray values stored in the document. So, you can mention paper trays in Document.

Please note that paper tray numbers are printer specific. Aspose.Words just reads values from document in Raw format (i.e. as int) and after Print method is called, a function compares the Raw value of PaperTray of current page and values in PrinterSettings.PaperSources and if it doesn’t find coincidence, function returns “Automatic” value. Then it passes the value for PaperTray to underlying Windows function that actually sends document to printer.

Best regards,

Hi I need to be able to set the page/tray setting dynamically after the merge as the document doesn’t have tray settings prior. Is this possible or not and if so do you have some sample code please

Hi Tim,

Thanks for your inquiry. The following code shows how to set up printing using different printer trays for different paper sizes.

Document doc = new Document();
// Choose the default printer to be used for printing this document.
System.Drawing.Printing.PrinterSettings settings = new System.Drawing.Printing.PrinterSettings();
// This is the tray we will use for A4 paper size. This is the first tray in the paper sources collection.
int printerTrayForA4 = settings.PaperSources[0].RawKind;
// The is the tray we will use for Letter paper size. This is the second tray in the paper sources collection.
int printerTrayForLetter = settings.PaperSources[1].RawKind;
// Set the page tray used for each section based off the paper size used in the section.
foreach(Section section in doc.Sections)
    if (section.PageSetup.PaperSize == PaperSize.Letter)
        section.PageSetup.FirstPageTray = printerTrayForLetter;
        section.PageSetup.OtherPagesTray = printerTrayForLetter;
    else if (section.PageSetup.PaperSize == PaperSize.A4)
        section.PageSetup.FirstPageTray = printerTrayForA4;
        section.PageSetup.OtherPagesTray = printerTrayForA4;

I hope, this helps.

Best regards,