Changing from Aspose.Pdf.Kit to Aspose.PDF's PrintViewer

I am switching over from PrintViewer class from Apose.Pdf.Kit to the equivalent in Aspose.PDF.

Unfortunately, our pdf files aren't actually printing. On my workstation, the files are sent to the local queue, but do not print. When testing on a server, one file is submitted to the queue, but the program seems to hang after that.

Maybre I am missing something.

I downloaded the lastest version of Apose.PDF, embedded the new license which just received today, and changed the code to reference the new license and new DLL:

'Dim license As Aspose.Pdf.Kit.License = New Aspose.Pdf.Kit.License

Dim license As Aspose.Pdf.License = New Aspose.Pdf.License

'license.SetLicense("Aspose.Pdf.Kit.lic")

license.SetLicense("Aspose.Pdf.lic")

Private Function PrintPDF(ByVal sPDFFileNameAndPath As String) As Boolean

Dim viewer As New Aspose.Pdf.Facades.PdfViewer

'Dim viewer As New Aspose.Pdf.Kit.PdfViewer

Try

viewer.AutoRotate = True ' new

viewer.Resolution = iPrintResolution

viewer.OpenPdfFile(sPDFFileNameAndPath)

viewer.PrintPageDialog = False

Catch ex As Exception

WriteToLog("PrintPDF: Exception setting Viewer attributes. " & ex.Message)

End Try

Dim ps As New PrinterSettings

Dim pgs As New PageSettings

Dim prtdoc As New PrintDocument

Try

ps.Copies = 1

ps.PrinterName = sPrintQueue

ps.PrintToFile = True ' new

ps.PrintFileName = sPDFFileNameAndPath

If sDuplexFlag = "Y" Then

If sDuplexValue = "Default" Then

ps.Duplex = Duplex.Default

End If

If sDuplexValue = "Simplex" Then

ps.Duplex = Duplex.Simplex

End If

If sDuplexValue = "Horizontal" Then

ps.Duplex = Duplex.Horizontal

End If

If sDuplexValue = "Vertical" Then

ps.Duplex = Duplex.Vertical

End If

If sDuplexValue = "" Or sDuplexValue = " " Then

ps.Duplex = Duplex.Default

End If

End If

pgs.Margins = New System.Drawing.Printing.Margins(0, 0, 0, 0)

Catch ex As Exception

WriteToLog("PrintPDF: Exception setting Printer Settings. " & ex.Message)

End Try

Try

viewer.PrintDocumentWithSettings(pgs, ps)

PrintPDF = True

Catch ex As Exception

WriteToLog("PrintPDF Exception while printing. " & ex.Message)

PrintPDF = False

End Try

End Function

Thanks,

Michael

Hi Michael,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for the details,

Please try the following code to set the license for the new Aspose.Pdf for .NET (merged version).

' create license object

Dim pdflic As New Aspose.Pdf.License()

' specify the embedded file information. MergedAPI is default namespace of project

pdflic.SetLicense("MergedAPI.Aspose.Pdf.lic")

' embed the license file within solution

pdflic.Embedded = True

Please do let us know if you still face any issue.

Sorry for the inconvenience,

Thanks.

Our program didn't like the "MergedAPI.Aspose.Pdf.lic", saying it was not found. So I substituded that with "Aspose.Pdf.lic" and that made it happy.

Also, I needed to change the paper settings parameter "PrintToFile" to "False" because the prints weren't being spooled to the queue. With Aspose.Pdf.Kit, we needed to change it to "True" for some reason.

ps.PrintToFile = False ' new

By the way, the speed in which the PDF's are queued seems to be about the same as with Aspose.Pdf.Kit. Has there been any plans to improve the speed?

I ask because the one complaint we are getting from our users is how slow the documents are printing - the old programs we replaced used FormsPartner and printed the docs quickly. Printing using Aspose is about one per 16 to 20 seconds.

CrystalMage:
Our program didn’t like the “MergedAPI.Aspose.Pdf.lic”, saying it was not found. So I substituded that with “Aspose.Pdf.lic” and that made it happy.
Hi Michael,

MergedAPI is a sample name and you can replace it with the default namespace of your project. Right click over project in solution explorer and select properties. You will be able to see the default namespace of your project.

CrystalMage:
By the way, the speed in which the PDF's are queued seems to be about the same as with Aspose.Pdf.Kit. Has there been any plans to improve the speed?

I ask because the one complaint we are getting from our users is how slow the documents are printing - the old programs we replaced used FormsPartner and printed the docs quickly. Printing using Aspose is about one per 16 to 20 seconds.

Usually the printing of a document should not take this much time. However it depends upon the PDF file structure, the contents of document and network configurations (if printer is attached over network). Can you please share some sample PDF documents so that we can test the scenario at our end. We are really sorry for your inconvenience.


Hi,

Thanks for the quick response.

I attached a sample PDF file. This is a two page file where one page prints as landscape while the 2nd page prints as portrait. This particular report prints on printing stock that is folded, sealed and then mailed to our customers.

We only use the Aspose to perform silent PDF printing. The documents are submitted/printed to a remote printer.

Thanks for your help.

Michael

Hello
Michael,

Thanks for sharing the resource file.

I have tested the scenario while using Aspose.Pdf for .NET 6.8.0 where I have tried printing the source PDF file into XPS format and as per my observations, the process is taking around 4.3 seconds to generate the output in intel Core i5, 2.8 GHz with 8GB of RAM. More along, please note that in order to accommodate the contents of first page on resultant output, I have used the following code lines

// auto resize the output page size to fit the contents

pdfViewer.AutoResize = true;

Can you please take a look over the output which I have generated over my end and also please try using the latest release version. We are sorry for your inconvenience.

PS, I have used the code snippet specified over Printing PDF to an XPS File and Hiding Print Dialog (Facades)