Hi!
I have an Pdf file and I need that first 2 pages to be printed on printer tray 1 and the rest on printer tray 2.
How can I do that when I use Spire.PDF?
Thank you in advance!
PdfDocument doc = new PdfDocument();
doc.LoadFromFile(input);
doc.PrinterName =printer1;
doc.PrintFromPage = 1;
doc.PrintToPage = 2;
doc.PrintDocument.Print();
doc.PrinterName = printer2;
doc.PrintFromPage = 3;
doc.PrintDocument.Print(); PdfDocument doc = new PdfDocument();
doc.LoadFromFile(input);
PrinterSettings.PaperSourceCollection collections = doc.PrintDocument.PrinterSettings.PaperSources;
List<PdfPaperSourceTray> loPaperSources = new List<PdfPaperSourceTray>();
if (loPaperSources.Count >= 4)
{
PdfPaperSourceTray tray = new PdfPaperSourceTray();
tray.StartPage = 0;
tray.EndPage = 1;
tray.PrintPaperSource = collections[2];
loPaperSources.Add(tray);
PdfPaperSourceTray tray1 = new PdfPaperSourceTray();
tray1.StartPage = 2;
tray1.EndPage = 3;
tray1.PrintPaperSource = collections[3];
loPaperSources.Add(tray);
}
else
{
for (int i = 0; i < collections.Count; i++)
{
PdfPaperSourceTray tray = new PdfPaperSourceTray();
tray.StartPage = i * 2;
tray.EndPage = (i + 1) * 2;
tray.PrintPaperSource = collections[i];
loPaperSources.Add(tray);
}
}
doc.PageSettings.ListPaperSourceTray = loPaperSources;
doc.PrintDocument.Print();