jeff411
asked on
IndexOutOfRangeException when using PrintToPrinter in vb.net 2003 and a custom paper size with Crystal Reports v10
In VB.NET I'm trying to print a crystal report directly to a printer. The report it a label with a bar code on it, 8.2cm by .9cm and I'm printing it to a zebra 105SL label printer.
This worked fine with the version of crystal reports that came with VS.NET 2003 ( v9 ) but when we upgraded to Crystal Reports v10 it no longer can print and I get an exception.
System.IndexOutOfRangeExce ption: Index was outside the bounds of the array.
at CrystalDecisions.CrystalRe ports.Engi ne.Migrati on.PrintOp tionsConve rter.EROMP aperSizeTo DNETPaperS ize(CrPape rSizeEnum ePaperSize)
at CrystalDecisions.CrystalRe ports.Engi ne.PrintOp tions.get_ PaperSize( )
at CrystalDecisions.CrystalRe ports.Engi ne.PrintOp tions.Copy To(Printer Settings printer, PageSettings page)
at CrystalDecisions.CrystalRe ports.Engi ne.FormatE ngine.Prin tToPrinter (Int32 nCopies, Boolean collated, Int32 startPageN, Int32 endPageN)
at frmMainScreen.ibutHelp_Cli ck() in C:\@Dev\RMA\Forms\MainScre en.vb:line 1497
What index is it talking about? If I modify the report to be letter size and print it on a regular printer it prints fine. I think the problem probably has something to do with the papersize not being standard and something they may have changed in Crystal Reports v10.
I tried to export the report to a pdf instead of printing using -> fReport.ExportToDisk(Expor tFormatTyp e.Portable DocFormat, "c:\testItemLabel.pdf") and it exports perfectly with the correct papersize.
Here's the code I'm using to print:
Dim cReport As New ItemLabel
cReport.SetDatabaseLogon(" user", "password", "server", "database")
cReport.SetParameterValue( "ItemNumbe r", "1001-01")
cReport.PrintOptions.Print erName = "\\printserver\Zebra"
cReport.FormatEngine.Print ToPrinter( 1, False, 0, 0)
Any help would be greatly appreciated
This worked fine with the version of crystal reports that came with VS.NET 2003 ( v9 ) but when we upgraded to Crystal Reports v10 it no longer can print and I get an exception.
System.IndexOutOfRangeExce
at CrystalDecisions.CrystalRe
at CrystalDecisions.CrystalRe
at CrystalDecisions.CrystalRe
at CrystalDecisions.CrystalRe
at frmMainScreen.ibutHelp_Cli
What index is it talking about? If I modify the report to be letter size and print it on a regular printer it prints fine. I think the problem probably has something to do with the papersize not being standard and something they may have changed in Crystal Reports v10.
I tried to export the report to a pdf instead of printing using -> fReport.ExportToDisk(Expor
Here's the code I'm using to print:
Dim cReport As New ItemLabel
cReport.SetDatabaseLogon("
cReport.SetParameterValue(
cReport.PrintOptions.Print
cReport.FormatEngine.Print
Any help would be greatly appreciated
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.