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.

Thu Apr 14, 2016 6:51 pm

Hello,

I am currently evaluating Spire.PDF for use at my customer site as we need to print PDFs to specific printers, trays and in a specific order and Spire.PDF seems to fit all of that.

In my test code, however I am seeing some strange behavior. I have simple code to pick the 3rd tray to print a PDF document to, however, for some reason it always prints the FIRST page to the main tray, and all of the subsequent pages go to the correct tray.

Any suggestions? Is this a bug? Do I have something coded incorrectly?

To narrow down the issues, when I print from within Acrobat or Word, and select a tray other than the main tray, all of the pages print correctly, so I don't believe it is a printer or driver issue.

The printer I am using is a "Ricoh MP C4603" with the "PCL6 UP" driver.

Thanks!

Code: Select all
        private void button1_Click(object sender, EventArgs e)
        {
            Spire.Pdf.PdfDocument doc = new Spire.Pdf.PdfDocument(@"D:\1\a.pdf");

            PrinterSettings.PaperSourceCollection collections = doc.PrintDocument.PrinterSettings.PaperSources;

            List<Spire.Pdf.PdfPaperSourceTray> loPaperSources = new List<Spire.Pdf.PdfPaperSourceTray>();

            Spire.Pdf.PdfPaperSourceTray tray = new Spire.Pdf.PdfPaperSourceTray();
            tray.StartPage = 1;
            tray.EndPage = doc.Pages.Count;
            tray.PrintPaperSource = collections[3];
            loPaperSources.Add(tray);

            doc.PageSettings.ListPaperSourceTray = loPaperSources;
            doc.PrintDocument.Print();
        }

[email protected]
 
Posts: 2
Joined: Thu Apr 14, 2016 6:05 pm

Fri Apr 15, 2016 3:00 am

Hi,

Thanks for interests in our Spire.PDF.
Please try the following solution.
Code: Select all
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();


Best Regards,
Amy
E-iceblue support team
User avatar

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

Tue Apr 19, 2016 7:54 am

Hi,

Has your issue been resolved?
Thanks for your feedback.

Best Regards,
Amy
E-iceblue support team
User avatar

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

Thu Apr 21, 2016 3:42 pm

No, that did not solve the problem as you just copy / pasted an example from somewhere else on the web and didn't really address my problem.

That example is where I figured out how to write my code from. HOWEVER I don't want to write different pages to different trays! I want them all to go to a single tray...... as you can see from my code.....

[email protected]
 
Posts: 2
Joined: Thu Apr 14, 2016 6:05 pm

Fri Apr 22, 2016 1:51 am

Hi,

Sorry that I misunderstand your issue. Please kindly note that the page indexing is zero-based. It should be tray.StartPage = 0 if you will print all pages.

Best Regards,
Amy
E-iceblue support team
User avatar

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

Return to Spire.PDF

cron