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.

Tue Jun 13, 2017 12:28 pm

Good morning.
I'm evaluating the purchase of this library for an application I'm developing for production management.

I just need to start printing from code without needing to load the file into a viewer and / or the print panel.

I need a simple command:

Print (file name)

I searched for the demos I downloaded but I did not miss anything. Can you tell me if it is possible with your libraries to do what I ask?

THANK YOU.

PippoIppo
 
Posts: 4
Joined: Mon Jun 12, 2017 2:22 pm

Wed Jun 14, 2017 2:42 am

Dear PippoIppo,

Thanks for your inquiry.
Here is sample code for your reference.
Code: Select all
            PdfDocument doc = new PdfDocument();
            doc.LoadFromFile(@"Sample.pdf");
            doc.PrintDocument.Print();

If there is any question, please let me know.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Mon Jun 19, 2017 8:44 am

Great.

Thanks a lot, it works.

Can you also set print options, such as sheet size, rotating page, and number of copies?

Thanks.

PippoIppo
 
Posts: 4
Joined: Mon Jun 12, 2017 2:22 pm

Tue Jun 20, 2017 6:46 am

Dear PippoIppo,

Thanks for your feedback.
Spire.PDF could set that print options as below, yet I found the Landscape and Copies properties don't work, and posted the issue to our Dev team. Once there is any progress, we will let you know immediately. Sorry for inconvenience caused.
Code: Select all
            PdfDocument doc = new PdfDocument();
            doc.LoadFromFile(@"F:\testing\pdf form testing\original document\10308.pdf");
            doc.PrintDocument.PrinterSettings.Copies = 2;
            PaperSize paperSize = new PaperSize();
            paperSize.Width = 800;
            paperSize.Height = 1200;
            paperSize.RawKind = (int)PaperKind.Custom;
            doc.PrintDocument.DefaultPageSettings.PaperSize = paperSize;
            doc.PrintDocument.DefaultPageSettings.Landscape = true;     
            doc.PrintDocument.Print();


Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Return to Spire.PDF