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