Tuesday, March 20, 2012

PaperSource

Ciao, I'm using CRAXDDRT automation for printing reports in Crystal Report 10.
I would like to choose the paper source (i.e.: Tray1, Tray2...) for a HP printer.
I use this command:

crystalReport.SelectPrinter "", "", "" TO SET DEFAULT PRINTER
crystalReport.PaperSource = 261 TO SET TRAY1

That printer has 2 trays: if I set for printing on Tray1 but there's no paper into it, tray2 is automatically selected.
I don't want this! I want that a message is prompted in vb code or on the display of hp printer, I want to know that tray1 has no paper and print must be stopped.

How could I do this? Do it depend from the printer type? Is it possible or is it normal that the first tray with paper is used?From what I understand, you can only control the papersource property when the report is not being formatted for printing. So after you open the report, you must set this property before you connect to server and start pumping data into it via the PrintOut method.
Also, the value you should be passing for the upper bin is 1 (crPRBinUpper =1, crPRBinLower = 2), not 261 as your notes show.

dave|||First of all, sorry for my english and thanks for repling me!

With HP Printers upper bin are not good, they need a 'personal code' (261, 262 and so...).
Searching on the internet I've found info about that: after setting the default printer I must pass the tray I need to print.
It works right only if paper is in both of trayes but if a tray is empty it prints automatically using the other one.
Instead of this I would like to know (directly on the printer display or trhrought VB code) if a tray is empty so I can choose to use the other or cancel all.

I hope you understand, but I think there's no solution because I haven't found nothing on the web about this and nobody can help me :(|||Well, if you have a licenced copy of Crystal reports, you had better contact them and ask for a fix.

Dave|||I had a similar problem, passing printer parameters from winspool to an external .net printer appi.

to deal with this in .net, ref. the Crystal 10 CrystalDecisions.CrystalReports.Engine (ver. 10.0.3300.0? assembly)

dont use papersource, this is an enumerated standard.

use CustomPaperSource to set the source from the passed string after the PrinterName is set

code snip:

'Source
Dim m_PrinterSettings As New Printing.PrinterSettings
Dim m_PaperSource As System.Drawing.Printing.PaperSource
Dim m_PrinterSource As Printing.PaperSource
Try
For Each m_PrinterSource In m_PrinterSettings.PaperSources
If m_PrinterSource.SourceName.ToString = <my paper source> Then
m_PaperSource = m_PrinterSource
Exit For
End If
Next

crReportDocument.PrintOptions.CustomPaperSource = m_PaperSource
Catch
'just default to auto if problem
crReportDocument.PrintOptions.PaperSource = CrystalDecisions.[Shared].PaperSource.Auto
End Try

CustomPaperSource is not coded in the 9.x assembly(s)

there is a crystal descision KB article somewhere out there on this.
hope this helps.

No comments:

Post a Comment