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.

Sat Apr 16, 2016 5:52 pm

Hello,

I use the following code:

var doc = new PdfDocument();
doc.LoadFromFile(pdfFilename);
doc.PrintDocument.Print();
doc.Close();

This nicely prints the pdf file, but it also shows a popup dialog that it is printing. Is it possible to not show this dialog such that the printing is completely silently?

Thank you,

Peter

peno64
 
Posts: 2
Joined: Sat Apr 16, 2016 5:49 pm

Mon Apr 18, 2016 3:37 am

Hi Peter,

Thanks for your feedback.
Please try the following solution.
Code: Select all
            var doc = new PdfDocument();
            doc.LoadFromFile("E:\\Sample1.pdf");
            PrintDocument printDoc = doc.PrintDocument;
            printDoc.PrintController = new StandardPrintController();//don't show the dialog box;
            printDoc.Print();
            doc.Close();


Sincerely,
Caroline
E-iceblue support team
User avatar

caroline.zhang
 
Posts: 291
Joined: Mon Mar 07, 2016 9:22 am

Tue Apr 19, 2016 6:42 am

Hello Peter,

Has your issue been resolved?
Thanks for your feedback.

Sincerely,
Caroline
E-iceblue support team
User avatar

caroline.zhang
 
Posts: 291
Joined: Mon Mar 07, 2016 9:22 am

Thu Apr 21, 2016 5:36 pm

Works great, thank you

peno64
 
Posts: 2
Joined: Sat Apr 16, 2016 5:49 pm

Fri Apr 22, 2016 1:07 am

Hi Peter,

Glad to hear that your issue has been resolved.
If there is any problem, welcome to get it back to us again.

Sincerely,
Caroline
E-iceblue support team
User avatar

caroline.zhang
 
Posts: 291
Joined: Mon Mar 07, 2016 9:22 am

Thu Jun 20, 2024 9:07 am

Dear Caroline,

The piece of code you provided (in 2018) to perform a silent print (without Dialog box), doesn't seems to be suitable with the latest version of Spire.PDF. Would you be kind providing an updated code to perform a silent print ?

Thanks advance,

fpernisek
 
Posts: 12
Joined: Wed Jun 15, 2016 7:02 am

Fri Jun 21, 2024 2:54 am

Hello,

Thanks for your inquiry.
Yes, we have adjusted the printing code in the new version. For silent printing, please refer to the following code. For more details about printing, please refer to this tutorial: Print PDF Documents.
Code: Select all
PdfDocument doc = new PdfDocument();
doc.LoadFromFile(@"sample.pdf");
doc.Print();

Sincerely,
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 454
Joined: Mon Dec 27, 2021 2:23 am

Return to Spire.PDF