Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Wed Jan 20, 2016 9:14 am

I want to print multiple pdf document in different tray in single click.

e.g. i have a button in UI and when user click that button i want to print two pdf document on different tray.

[email protected]
 
Posts: 1
Joined: Wed Jan 20, 2016 9:10 am

Thu Jan 21, 2016 3:51 am

Hi,

Thanks for your posting and using Spire.PDF.
Please refer to the following code.
Code: Select all
  string[] files = null;
            files = Directory.GetFiles("D:\\files", "*.pdf");
            foreach (string lcFile in files)
            {
                PdfDocument doc = new PdfDocument();
                doc.LoadFromFile(lcFile);
                PrinterSettings.PaperSourceCollection collections = doc.PrintDocument.PrinterSettings.PaperSources;
                List<PdfPaperSourceTray> loPaperSources = new List<PdfPaperSourceTray>();

                //Assume collections[2] is big A3,and collections[3] is A4.

                PdfPageBase loPage = doc.Pages[0];
                if (loPage.Size == PdfPageSize.A4)
                {
                    PdfPaperSourceTray tray = new PdfPaperSourceTray();
                    tray.StartPage = 0;
                    tray.EndPage = doc.Pages.Count - 1;
                    tray.PrintPaperSource = collections[3];
                    loPaperSources.Add(tray);
                }
                else   //A3
                {
                    PdfPaperSourceTray tray = new PdfPaperSourceTray();
                    tray.StartPage = 0;
                    tray.EndPage = doc.Pages.Count - 1;
                    tray.PrintPaperSource = collections[2];
                    loPaperSources.Add(tray);
                }
                doc.PageSettings.ListPaperSourceTray = loPaperSources;
                doc.PrintDocument.Print();
            }


Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 3011
Joined: Wed Jun 27, 2012 8:50 am

Fri Jan 22, 2016 7:37 am

Hi,

Has your issue been resolved?
Thanks for your feedback.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 3011
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.PDF