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.

Mon May 02, 2022 8:43 am

Hello,

I have a problem with Spire.Office for WPF. I need to print a lot of PDF files and program asks me every time about printing options and printer selection. I tried silent printing from your help page but there's no doc.Print.Settings in WPF version. Is there any way to avoid pop-up windows while printing using Spire.Office for WPF?

Thank you in advance,
Jacek

j.strychalski
 
Posts: 9
Joined: Tue Apr 19, 2022 8:05 am

Mon May 02, 2022 10:28 am

Hi Jacek,

Thanks for your inquiry.

I'm very sorry that currently Spire.Pdf does not support setting print options in wpf projects. We will add this feature to the develop plans. For this, I have created a new ticket SPIREPDF-5166. I will keep you informed as soon as there is any progress or update on this issue.
Sincerely,
Andy
E-iceblue support team
User avatar

Andy.Zhou
 
Posts: 483
Joined: Mon Mar 29, 2021 3:03 am

Wed May 04, 2022 10:32 am

Hello Andy,

Thank you for your answer.

Do I need to wait for an update with these changes or is there any other way to avoid pop-up window while printing?

Sincerely,
Jacek

j.strychalski
 
Posts: 9
Joined: Tue Apr 19, 2022 8:05 am

Thu May 05, 2022 2:31 am

Hi Jacek,

There is a feasible solution for you. You can use PdfDocumentViewer instead of PdfDocument to print files. Please decide whether this solution is suitable according to your own situation. Below is the sample code.
Besides, regarding the issue SPIREPDF-5166, we will investigate it and try to improve. I will keep you informed when this feature becomes available.

Code: Select all
            PdfDocumentViewer viewer = new PdfDocumentViewer();
            viewer.LoadFromFile("xxxx.pdf");
            //false: not show the dialog while printing
            viewer.Print(false);
            viewer.CloseDocument();
Sincerely,
Andy
E-iceblue support team
User avatar

Andy.Zhou
 
Posts: 483
Joined: Mon Mar 29, 2021 3:03 am

Mon May 09, 2022 6:20 am

Hello Andy,

Thank you for your help and sorry for my late reply. I'll try your solution and wait for an update on SPIREPDF-5166 issue.

Best regards,
Jacek

j.strychalski
 
Posts: 9
Joined: Tue Apr 19, 2022 8:05 am

Mon May 09, 2022 9:01 am

Hi Jacek,

You are welcome. I will notify you in time when the update is available.
Sincerely,
Andy
E-iceblue support team
User avatar

Andy.Zhou
 
Posts: 483
Joined: Mon Mar 29, 2021 3:03 am

Mon May 09, 2022 11:49 am

Hello Andy,

Sorry for troubling you again. I tried this method you recommended and I got some error.

Code:

Code: Select all
By = FileIO.FileSystem.ReadAllBytes("d:\4317066.pdf")
Dim M As New IO.MemoryStream(Text.ASCIIEncoding.ASCII.GetBytes(My.Resources.license_elic))
Spire.License.LicenseProvider.SetLicenseFileFullPath("D:\Documents\license.elic.xml")
Dim doc As New Spire.DocViewer.Forms.DocViewer
doc.LoadFromStream(New IO.MemoryStream(By), Spire.Doc.FileFormat.Auto)
doc.Print()


Error:
Code: Select all
System.ArgumentException
HResult=0x80070057
Message=Wartość FromPage jest poza zakresem.
Source=System.Windows.Forms
Ślad stosu:
w System.Windows.Forms.PrintDialog.ShowPrintDialog(IntPtr hwndOwner, WndProc hookProcPtr, PRINTDLG data)
w System.Windows.Forms.PrintDialog.RunDialog(IntPtr hwndOwner)
w System.Windows.Forms.CommonDialog.ShowDialog(IWin32Window owner)
w System.Windows.Forms.CommonDialog.ShowDialog()
w Spire.DocViewer.Forms.DocViewer.Print()
w _4Pack.AppClass.clsPrintPDF.PrintPDF(String PrinterName, String Name, Int32 IdPaczki, Byte[] By) w D:\Moje Programy\Git\4Pack\4Pack\AppClass\clsPrintPDF.vb:wiersz 59
w _4Pack.MainWindow..ctor() w D:\Moje Programy\Git\4Pack\4Pack\MainWindow.xaml.vb:wiersz 21


It happened when I tried to print some specific PDF files. Is there any way to solve this error?

Sincerely,
Jacek

j.strychalski
 
Posts: 9
Joined: Tue Apr 19, 2022 8:05 am

Tue May 10, 2022 2:43 am

Hi Jacek,

I noticed that you used DocViewer to load a PDF document and try to print it. Please kindly note that DocViewer is used to load and display Word documents and not PDFs. Please test the code below.

Code: Select all
Imports Spire.PdfViewer.Wpf

Class MainWindow
    Public Sub test()
        Dim viewer As New PdfDocumentViewer
        viewer.LoadFromFile("test.pdf")
        viewer.Print(False)
        viewer.CloseDocument()
    End Sub

End Class
Sincerely,
Andy
E-iceblue support team
User avatar

Andy.Zhou
 
Posts: 483
Joined: Mon Mar 29, 2021 3:03 am

Tue May 24, 2022 9:46 am

Hello Andy,

I'm sorry for my late reply.

I tested your code and it works fine. Thank you for your help.

Best regards,
Jacek

j.strychalski
 
Posts: 9
Joined: Tue Apr 19, 2022 8:05 am

Tue May 24, 2022 10:07 am

Hi Jacek,

You are welcome!
Sincerely,
Andy
E-iceblue support team
User avatar

Andy.Zhou
 
Posts: 483
Joined: Mon Mar 29, 2021 3:03 am

Fri Jul 08, 2022 8:34 am

Hi Jacek,

Thanks for your patience!

Glad to inform you that we just released Spire.Office Version:7.7.2 which added "PrintSettings" into "PdfDocument" in Wpf version.

Please download the new version from the following links to test.
Website link:
https://www.e-iceblue.com/Download/down ... t-now.html
Nuget link:
https://www.nuget.org/packages/Spire.Office/7.7.2
https://www.nuget.org/packages/Spire.Of ... dard/7.7.2
Sincerely,
Andy
E-iceblue support team
User avatar

Andy.Zhou
 
Posts: 483
Joined: Mon Mar 29, 2021 3:03 am

Return to Spire.PDF