public void PaperTrayForDifferentPaperType()
{
//ExStart
//ExFor:PageSetup.FirstPageTray
//ExFor:PageSetup.OtherPagesTray
//ExSummary: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.
PrinterSettings settings = new 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 == Aspose.Words.PaperSize.Letter)
{
section.PageSetup.FirstPageTray = printerTrayForLetter;
section.PageSetup.OtherPagesTray = printerTrayForLetter;
}
else if (section.PageSetup.PaperSize == Aspose.Words.PaperSize.A4)
{
section.PageSetup.FirstPageTray = printerTrayForA4;
section.PageSetup.OtherPagesTray = printerTrayForA4;
}
}
//ExEnd
}