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 Dec 10, 2015 3:29 pm

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!

vtoderica
 
Posts: 3
Joined: Thu Dec 10, 2015 7:22 am

Fri Dec 11, 2015 3:25 am

Hi,

Thanks for your inquiry.
Please try the following code snippet.
Code: Select all
  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();


Best Regards,
Amy
E-iceblue support team
User avatar

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

Fri Dec 11, 2015 6:12 am

Thank you for the fast reply.
The problem is that I have the same printer with many trays. For ex the printer with name: SinglePDFPrinter has yellow sheets on tray1 and blue sheets on tray2 . And I want to print the first 2 pages yellow and the rest blue.

( the same property as in : System.Drawing.Printing.PaperSource )
Could we do that?
( Do you know where/how I can get the x64 bit version for Spire.PDF?)

vtoderica
 
Posts: 3
Joined: Thu Dec 10, 2015 7:22 am

Fri Dec 11, 2015 7:26 am

Hi,

Sorry, please try the following solution. Our Spire.PDF can work for 32bit and 64bit.
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: 3011
Joined: Wed Jun 27, 2012 8:50 am

Sun Dec 13, 2015 10:22 pm

Hi Amy!

Thank you for your fast & professional response. It helped me!
I have one more question. The resulted *.pdf is actually a picture? ( because I cannot for select a text, or search for a text)
Is there an option/solution to have real pdf files? ( We actually need this for some "special" clients that use software printers)

Thanks again! Have an easy week :)

vtoderica
 
Posts: 3
Joined: Thu Dec 10, 2015 7:22 am

Mon Dec 14, 2015 5:48 am

Hi,

Thanks for your further inquiry.
Yes, the content of the printed document is stored in the form of pictures.
Sorry that there is no options on printing function to do this.

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