PageSetupOtherPagesTray Property |
Namespace: Aspose.Words
Document doc = new Document(); // 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 PrinterSettings settings = new 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.OfType<Section>()) { section.PageSetup.FirstPageTray = settings.DefaultPageSettings.PaperSource.RawKind; section.PageSetup.OtherPagesTray = settings.DefaultPageSettings.PaperSource.RawKind; }
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.OfType<Section>()) { 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; } }