Spire.PDFViewer is a powerful PDF Viewer component for .NET. It allows developers to load PDF document from stream, file and byte array.

Tue Jul 21, 2015 1:11 pm

Do you have a code example available for printing silently with a predefined set of Printersettings? I am needing to be able to print PDF files when the user clicks a button and not have it display a dialog but print to a printer other than the default printer.

Thanks for your assistance.

Regards,
Nate

nemler
 
Posts: 8
Joined: Wed Jun 24, 2015 2:41 pm

Wed Jul 22, 2015 7:36 am

Hello,

Thanks for your inquiry.
Here is the code for your reference.
Code: Select all
PdfDocument[] docs = {
           new PdfDocument("D:\\testfile\\Pdf\\pdf_1.pdf"),
           new PdfDocument("D:\\testfile\\Pdf\\pdf_2.pdf"),
           new PdfDocument("D:\\testfile\\Pdf\\Image.pdf")
            };//Load pdf files
            foreach (PdfDocument doc in docs)
            {   
                doc.PageSettings.Size = PdfPageSize.A4;
                doc.PrintDocument.DefaultPageSettings.Landscape = true;
                doc.PageScaling = PdfPrintPageScaling.FitSize;
                doc.PrinterName = "Microsoft XPS Document Writer";//Set the name of your printer.               
                doc.PrintDocument.Print();
            }


Best Regards,
Sweety

E-iceblue support team
User avatar

sweety1
 
Posts: 539
Joined: Wed Mar 11, 2015 1:14 am

Fri Jul 24, 2015 6:31 am

Hello,

Have you tried the code?
Has your issue been resolved?
Thanks for your feedback.

Best Regards,
Sweety

E-iceblue support team
User avatar

sweety1
 
Posts: 539
Joined: Wed Mar 11, 2015 1:14 am

Mon Jul 27, 2015 10:56 am

Yes this solved my issue quite well. Thank you for the quick response and the code example.

Kind Regards,
Nate

nemler
 
Posts: 8
Joined: Wed Jun 24, 2015 2:41 pm

Tue Jul 28, 2015 1:35 am

Hello,

Please feel free to contact us, if you have any questions or needs. We are here for help.

Best Regards,
Sweety

E-iceblue support team
User avatar

sweety1
 
Posts: 539
Joined: Wed Mar 11, 2015 1:14 am

Mon Feb 01, 2016 3:39 pm

Hello ICEBLUE-Team,

I have a similar query, I am currently showing the printing dialog and the user chooses a printer. Then I am looping through a list of PDFs which all get printed with the same Settings that were originally chosen by the user. (I do not want to merge them).

What I like to avoid is the window that pops up, saying "printing page 1, printing page 2, printing page 3" for each of the documents. It is a lot of windows popping up if there are a couple of PDFs with some pages each to print. #

Is there any way to "mute" those Windows?

Many thanks in advance!
:-)

LJU
 
Posts: 3
Joined: Mon Feb 01, 2016 11:29 am

Tue Feb 02, 2016 2:45 am

Hi,

Thanks for your posting and using our component.
Please try the following code snippet.
Code: Select all
Spire.Pdf.PdfDocument doc = new Spire.Pdf.PdfDocument();
           doc.LoadFromFile(DocumentFilePath);
           System.Drawing.Printing.PrintDocument printDoc = doc.PrintDocument;
           printDoc.PrintController = new StandardPrintController();
           printDoc.Print();


Best Regards,
Amy
E-iceblue support team
User avatar

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

Tue Feb 02, 2016 9:38 am

Dear Amy, thank you so much for your quick response, that worked like a dream!!! :-)

LJU
 
Posts: 3
Joined: Mon Feb 01, 2016 11:29 am

Wed Feb 03, 2016 1:36 am

Hi,

Thanks for your feedback.
I am glad that your issue has been resolved.
Welcome to write to us again for further problems.

Best Regards,
Amy
E-iceblue support team
User avatar

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

Wed Feb 03, 2016 9:37 am

Hello Amy,

sorry, me again! I've got one more question. I have noticed, that my print dialog sometimes appears in the background. After doing some research, I have found that whilst the print preview does have some property to bring it to the front, the actual print dialog does not have this option. Is there a way around this problem with Spire?

Thank you in advance!
Laura

LJU
 
Posts: 3
Joined: Mon Feb 01, 2016 11:29 am

Thu Feb 04, 2016 2:23 am

Hi Laura,

Thanks for your further inquiry.
Please try the following solution.
Code: Select all
 Spire.Pdf.PdfDocument doc = new Spire.Pdf.PdfDocument();
           doc.LoadFromFile(DocumentFilePath);
           PrintDialog dialogPrint = new PrintDialog();
           dialogPrint.AllowPrintToFile = true;
           dialogPrint.AllowSomePages = true;
           dialogPrint.PrinterSettings.MinimumPage = 1;
           dialogPrint.PrinterSettings.MaximumPage = doc.Pages.Count;
           dialogPrint.PrinterSettings.FromPage = 1;
           dialogPrint.PrinterSettings.ToPage = doc.Pages.Count;
           if (dialogPrint.ShowDialog() == DialogResult.OK)
           {
               doc.PrintFromPage = dialogPrint.PrinterSettings.FromPage;
               doc.PrintToPage = dialogPrint.PrinterSettings.ToPage;
               doc.PrinterName = dialogPrint.PrinterSettings.PrinterName;
               PrintDocument printDoc = doc.PrintDocument;
               printDoc.PrintController = new StandardPrintController();
               dialogPrint.Document = printDoc;
               printDoc.Print();
           }


Best Regards,
Amy
E-iceblue support team
User avatar

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

Mon Feb 15, 2016 7:35 am

Hi,

Has your issue been resolved?
Thank you for your feedback.

Best Regards,
Amy
E-iceblue support team
User avatar

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

Tue Jan 16, 2018 4:13 pm

Dear Team,

I have the similar need to print multiple files in a folder silently. I am able to do so but I could see the fonts are not same and when ever any text is bold the very next text is miss-aligned.

here my code snip:
Spire.Pdf.PdfDocument doc = new PdfDocument();
doc.LoadFromFile(file); //full file path
doc.PrinterName = "my printer name";
doc.PrintDocument.DocumentName = "filename";
doc.PrintDocument.Print();

can you help?

VIJAYMISHRA26@GMAIL.COM
 
Posts: 1
Joined: Mon Jan 15, 2018 11:11 pm

Wed Jan 17, 2018 3:03 am

Hi VIJAY MISHRA,

Thanks for your inquiry.
Please try the latest version(Spire.PDF Pack(Hot Fix) Version:3.9.584).
If the problem still troubles you, please send the documents which have the issue to us(support@e-iceblue.com).

Sincerely,
Jane
E-iceblue support team
User avatar

Jane.Bai
 
Posts: 1156
Joined: Tue Nov 29, 2016 1:47 am

Thu May 31, 2018 12:06 pm

Hi,

How to restrict a pdf file to download and print in asp.net mvc ? Do you have a sample code?

Thanks

margerie
 
Posts: 1
Joined: Thu May 31, 2018 12:01 pm

Return to Spire.PDFViewer

cron