We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Can't Print to Certain Printers

I am generating a PDF by inserting an graphic with some text on top.I am using Aspose PDFViewer to print the PDF with the following routine.

If I print it to a Brother Laser Printer all is fine, however if I print it to a Zebra LP 2844 all I get is a blank label. If I open the file in Adobe, then it prints to the Zebra printer fine.

I have attached a PDF that will not print to the Zebra, but will to a Brother Laser. Any ideas?

Randy

Dim viewer As PdfViewer = New PdfViewer()
Public Sub PrintLabelNew(ByVal sFileURL As String, ByVal bLabelPrinter As Boolean)
Dim iIOErrorCount As Integer = 0

Dim iWidth As Integer = 288
Integer.TryParse(tpMain.objMainForm.txtLabelWidth.Text, iWidth)
Dim iHeight As Integer = 432
Integer.TryParse(tpMain.objMainForm.txtLabelHeight.Text, iHeight)

Dim sFileName As String = sFileURL
Dim sPrinter As String = IIf(bLabelPrinter, tpMain.AppSettings.LabelPrinterName, tpMain.AppSettings.ReportPrinterName)

If sPrinter.Trim.Length = 0 Then
Common.Toast("Printing Problem", "Printer not selected, using default windows printer.")
PrintPreview(sFileURL)
Else
viewer.BindPdf(sFileName)
viewer.AutoResize = False 'print the file with adjusted size
viewer.AutoRotate = False 'print the file with adjusted rotation
viewer.PrintPageDialog = False 'do not produce the page number dialog when printing
Dim ps As System.Drawing.Printing.PrinterSettings = New System.Drawing.Printing.PrinterSettings()
If sPrinter <> tpMain.cDefaultPrinter Then
ps.PrinterName = sPrinter
End If
Dim pgs As Printing.PageSettings = New Printing.PageSettings()
pgs.PaperSize = New System.Drawing.Printing.PaperSize("Shipping Label", PointsToHundredsOfInch(iWidth), _
PointsToHundredsOfInch(iHeight))
pgs.Margins = New Printing.Margins(0, 0, 0, 0)
Try
viewer.PrintDocumentWithSettings(pgs, ps)
Catch ex As Exception
MsgBox("Print Crashed: " & ex.Message)
End Try
viewer.Close()
End If

SyncLock tpMain.objLock_PrintCount
Try

Dim dSec As Decimal = DateDiff(DateInterval.Second, tpMain.AppSettings.StartTime, Now())
tpMain.ShowMessage("Time Per Label: " & Decimal.Round(dSec / tpMain.AppSettings.LabelsProcessed, 2) & " Labels Processed: " & tpMain.AppSettings.LabelsProcessed & " Seconds Lapsed: " & dSec, LogSystem.LogPrint, LogLevel.LogHigh)
'Common.Toast("Time Per Label: " & dSec / Main.AppSettings.LabelsProcessed, "Labels Processed: " & Main.AppSettings.LabelsProcessed & " Seconds Lapsed: " & dSec)
Catch ex As Exception

End Try
End SyncLock

End SubDim viewer As PdfViewer = New PdfViewer()
Public Sub PrintLabelNew(ByVal sFileURL As String, ByVal bLabelPrinter As Boolean)
Dim iIOErrorCount As Integer = 0

Dim iWidth As Integer = 288
Integer.TryParse(tpMain.objMainForm.txtLabelWidth.Text, iWidth)
Dim iHeight As Integer = 432
Integer.TryParse(tpMain.objMainForm.txtLabelHeight.Text, iHeight)

Dim sFileName As String = sFileURL
Dim sPrinter As String = IIf(bLabelPrinter, tpMain.AppSettings.LabelPrinterName, tpMain.AppSettings.ReportPrinterName)

If sPrinter.Trim.Length = 0 Then
Common.Toast("Printing Problem", "Printer not selected, using default windows printer.")
PrintPreview(sFileURL)
Else
viewer.BindPdf(sFileName)
viewer.AutoResize = False 'print the file with adjusted size
viewer.AutoRotate = False 'print the file with adjusted rotation
viewer.PrintPageDialog = False 'do not produce the page number dialog when printing
Dim ps As System.Drawing.Printing.PrinterSettings = New System.Drawing.Printing.PrinterSettings()
If sPrinter <> tpMain.cDefaultPrinter Then
ps.PrinterName = sPrinter
End If
Dim pgs As Printing.PageSettings = New Printing.PageSettings()
pgs.PaperSize = New System.Drawing.Printing.PaperSize("Shipping Label", PointsToHundredsOfInch(iWidth), _
PointsToHundredsOfInch(iHeight))
pgs.Margins = New Printing.Margins(0, 0, 0, 0)
Try
viewer.PrintDocumentWithSettings(pgs, ps)
Catch ex As Exception
MsgBox("Print Crashed: " & ex.Message)
End Try
viewer.Close()
End If

SyncLock tpMain.objLock_PrintCount
Try

Dim dSec As Decimal = DateDiff(DateInterval.Second, tpMain.AppSettings.StartTime, Now())
tpMain.ShowMessage("Time Per Label: " & Decimal.Round(dSec / tpMain.AppSettings.LabelsProcessed, 2) & " Labels Processed: " & tpMain.AppSettings.LabelsProcessed & " Seconds Lapsed: " & dSec, LogSystem.LogPrint, LogLevel.LogHigh)
'Common.Toast("Time Per Label: " & dSec / Main.AppSettings.LabelsProcessed, "Labels Processed: " & Main.AppSettings.LabelsProcessed & " Seconds Lapsed: " & dSec)
Catch ex As Exception

End Try
End SyncLock

End Sub

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

Thank you for sharing the details.

Well, it is a very strange issue that your PDF file is not printing on some specific printer. I have created an issue in our issue tracking system as PDFNEWNET-34473 for our development team to further investigate your issue with the information provided. We will update you with any findings from the development team after their investigation.

Sorry for the inconvenience,