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.

Fri Jun 30, 2017 3:50 pm

We have a purchased edition of Spire.Pdf and it works great on my development box but on our deployment box we are not getting prints using the same code base and its not producing an error in our log or Windows Event Viewer . We have two theories 1. permissions problem or 2. wrong ddl version.

Local on my development machine and on our server we have the following in the bin.
Spire.pdf.dll v.3.9.0.2040
Spire.License.dll v.1.3.6.40
Spire.License.xml

seanw432
 
Posts: 6
Joined: Thu Jun 15, 2017 3:13 pm

Mon Jul 03, 2017 2:49 am

Hello,

Thanks for your inquiry.
To help us with a better investigation, could you share the following information?
• Your desired behavior and the related code
• The deployed environment
• Your project mode, such as ASP.NET
• Sample files
Besides, any other details about the situation would be greatly appreciated.

Sincerely,
Jane
E-iceblue support team
User avatar

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

Mon Jul 03, 2017 1:18 pm

• Your desired behavior and the related code
The section of code below currently works on development, important to note about a week ago all this code was working on our Test Server ASP.Net (what I called 'deployment'), now is not and not producing an error. The sample below is code designed to be a test on a blank ASP.Net page so that we would not inject other factors while trying to solve the recent problem. The reportURL, ReportPath,Paramaters,parameternames in the first section are verified to have worked on both development and our Test Server (however no longer working on test) (same is true for the second section). The values in the sample have been removed for business security. Sample below is using both LoadFromBytes and LoadFromFile.
Our Desired behavior is very simply to have the code produce a printed document as it was doing last week on Test with the same line of code and how it currently still working on Dev.

Me.ReportViewer1.ServerReport.ReportServerUrl = New System.Uri(CType(System.Configuration.ConfigurationManager.AppSettings("SSRS"), String))
Me.ReportViewer1.ServerReport.ReportPath = "the_report_name"
Dim p As New Microsoft.Reporting.WebForms.ReportParameter("param", "value")
Me.ReportViewer1.ServerReport.SetParameters(p)
Me.ReportViewer1.ServerReport.Refresh()

Dim PDFDoc1 As New Spire.Pdf.PdfDocument
PDFDoc1.LoadFromBytes(Me.GlobalUtilityMethods.ReturnReportToStream(Me.ReportViewer1))
PDFDoc1.PrintDocument.PrinterSettings.PrinterName = "printer_name"
PDFDoc1.PrintDocument.PrinterSettings.Copies = 1
PDFDoc1.PrintDocument.Print()


Dim PDFDoc As New Spire.Pdf.PdfDocument
PDFDoc.LoadFromFile("file_name")
PDFDoc.PrintDocument.PrinterSettings.PrinterName = "printer_name"
PDFDoc.PrintDocument.PrinterSettings.Copies = 1
PDFDoc.PrintDocument.Print()

• The deployed environment
ASP.Net running on Windows Server (I think either the latest version or previous I can get that information tomorrow)

• Your project mode, such as ASP.NET
ASP.Net Web Application

• Sample files
I dont think this is needed in this case, but let me know if feeling on that is different.

Summary:
The main take away is that this code on our Test server was working and now stopped and its not producing an error


Added:
Spire.pdf.dll v.3.9.0.2040
Spire.License.dll v.1.3.6.40
Spire.License.xml

My first assumption is that our Test enviroment still has the evaluation edition and has stopped working because its past 14 days but my co-worker who manages the test server does not feel that is the case.

Thanks for your help!

seanw432
 
Posts: 6
Joined: Thu Jun 15, 2017 3:13 pm

Tue Jul 04, 2017 2:19 am

Hello,

Thanks for your information.
Kindly note that the classes within the System.Drawing.Printing namespace are not well supported for a Windows service or ASP.NET application. Using the classes in these application types may result in unexpected problems, such as diminished service performance and run-time exceptions. In this case, it might be the root of your issue. Don't worry, Microsoft has provided a proper way to use the unmanaged XpsPrint API for server solutions. Please reference the attached XpsPrintHelper class and use the below code.
Code: Select all
Dim ms As New MemoryStream()
                  Dim doc As New Document()
                  doc.LoadFromFile(input)
                  doc.SaveToStream(ms, FileFormat.XPS)
                  ms.Position = 0
                  XpsPrint.XpsPrintHelper.Print(ms,printerName,"My printing job", True)
User avatar

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

Wed Jul 05, 2017 1:11 pm

However, load from file is also not working on the server but is working locally and is not producing an error.
Additionally, I know about 7 days ago I was printing using .LoadfromStream from the server successfully without issue

PDFDoc.LoadFromFile("file_name")

seanw432
 
Posts: 6
Joined: Thu Jun 15, 2017 3:13 pm

Thu Jul 06, 2017 8:27 am

Hello Sean,

I have received your mail and replied you.
Following are the suggestions on our side.
1. Here on my side, I load the file using the code below:
Code: Select all
PDFDoc.LoadFromFile(Server.MapPath("~/Data/samplefile.pdf"))

you can have a try and tell us if it works on your end.
2. Please simplify your asp.net project, remove the other unrelated code, only load file and then print.
3. I want to know if you have changed the printer in the server. Since some printer doesn’t support printing via System.Drawing.Printing, the proper way to print documents according to Microsoft is to use the unmanaged XpsPrint API.
I also would like to know whether you have tried the XpsPrint API I provided in the forum and what the result is.
4. If the above suggestions make no sense, just create a standalone/runnable simple application that shows the issue and send it to us for a further investigation.
I’m looking forward to your reply.

Sincerely,
Jane
E-iceblue support team
User avatar

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

Return to Spire.PDF