Paper Tray setting is not used when sending to printer through Crystal Reports .NET SDK.
- Crystal Reports for Visual Studio 2012
- Crystal Reports for Visual Studio 2010
- Crystal Reports for Visual Studio 2008
- Crystal Reports for Visual Studio 2005
For example, when I select “A4”, the cboCurrentPaperSizes .SelectedIndex is “5”. But in CrPaperSizeEnum, “5” means “crPaperSizePaperLegal”, A4 is 9. So the sdk set the wrong papaersize(Legal) here. I modify the code as follows.
rasPROpts.PaperSize = (CrPaperSizeEnum)cboCurrentPaperSizes.SelectedIndex;
int sizes = PaperSizeGetter.Get_PaperSizes(cboCurrentPrinters.Text);
int paperSizeid = sizes[this.cboCurrentPaperSizes.SelectedIndex];
if (paperSizeid > 0)
rasPROpts.PaperSize = (CrystalDecisions.ReportAppServer.ReportDefModel.CrPaperSizeEnum)paperSizeid;
Let's return, the root cause of Paper Tray not work is as follow. Because selectedtext will return empty string “”, if DropDownStyle is set to DropDownList(You can find it in msdn). In this way the original SDK always returns empty string, so BinName is always empty. The situation you mention will appear, “For the HP 4050 it always selects Tray 1 first, when it runs out of paper then Tray 2 is used.”
rasPROpts.BinName = cboDefaultPaperTrays.SelectedText;
rasPROpts.BinName = cboCurrentPaperTrays.SelectedItem.ToString();
The modification above is just for PrintOutputController.PrintReport. PrintToPrinter should modify as follows. We should assign a PaperSource to pSettings.PaperSource, not only the papersource name.
pSettings.PaperSource.SourceName = cboCurrentPaperTrays.SelectedText;
System.Drawing.Printing.PaperSource myPaperSource = new System.Drawing.Printing.PaperSource();
pDoc.PrinterSettings.PrinterName = cboCurrentPrinters.SelectedItem.ToString();
foreach (System.Drawing.Printing.PaperSource tmpPaperSource in pDoc.PrinterSettings.PaperSources)
if (tmpPaperSource.SourceName == cboCurrentPaperTrays.SelectedItem.ToString())
myPaperSource = tmpPaperSource;
pSettings.PaperSource = myPaperSource;
See attached C# file for more info on how to query the printers for the above info.
KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , Problem