Hi there,
We’re using your product (v 6.6.0.0) and have hit a bit of a snag. I’ve got this document printing to a Hewlett Packard 5500 LaserJet printer. In the document, I’ve setup the first page to print to tray 1 and all other pages to print to tray 3 (see image1). I print this from Word and the print works as expected.
An interesting note is when I close the document, reopen in Word and then change the printer (before hit the OK to print) is that the settings become stuffed up (see image2). The trays are now both on tray 1 (with one being the manual).
When I have stepped through the code, the page setup for the first section is:
OtherPagesTray = 261
FirstPageTray = 259
I created a script in Word to get the names and numbers of the trays - and this matches up - those values are what Word thinks are the trays (and also what the PaperSources are in the PrinterSettings class) for this printer.
So everything looks correct as far as I can see with the tray values, so I’m just wondering if anyone else has come across this before?
The code I’m using to print is this:
Public Function PrintDocument(ByVal Path As String, ByVal Printer As String, ByVal Copies As Integer, ByVal DeleteFile As Boolean) As Boolean
Dim aspDoc As Aspose.Words.Document = Nothing
Dim awPrintDoc As Aspose.Words.Rendering.AsposeWordsPrintDocument = Nothing
Dim myPrintSettings As System.Drawing.Printing.PrinterSettings
'
Try
' create instances.
myPrintSettings = New System.Drawing.Printing.PrinterSettings
aspDoc = New Aspose.Words.Document(Path)
' setup the print settings and print the document.
awPrintDoc = New AsposeWordsPrintDocument(aspDoc)
myPrintSettings.FromPage = 1
myPrintSettings.ToPage = aspDoc.PageCount
myPrintSettings.Copies = CShort(Copies)
myPrintSettings.PrinterName = Printer
awPrintDoc.PrinterSettings = myPrintSettings
awPrintDoc.Print()
' do we delete?
If (DeleteFile) Then
Try
IO.File.Delete(Path)
Catch ex As Exception
' ignore exceptions on this.
End Try
End If
Return True
Catch ex As Exception
Return False
Finally
If (awPrintDoc IsNot Nothing) Then
awPrintDoc.Dispose()
End If
End Try
End Function
I haven’t gone as far as to override the entire print process yet, but I’m not entirely sure this will fix this problem. We have got a workaround at the moment (setup the printer to only print from a certain tray) - works, but not the ideal solution.
And I may have overlooked something simple as, so any help would be much appreciated.
Cheers,
Tyron