Solved

IndexOutOfRangeException when using PrintToPrinter in vb.net 2003 and a custom paper size with Crystal Reports v10

Posted on 2004-10-15
3
1,019 Views
Last Modified: 2011-09-20
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.IndexOutOfRangeException: Index was outside the bounds of the array.
   at CrystalDecisions.CrystalReports.Engine.Migration.PrintOptionsConverter.EROMPaperSizeToDNETPaperSize(CrPaperSizeEnum ePaperSize)
   at CrystalDecisions.CrystalReports.Engine.PrintOptions.get_PaperSize()
   at CrystalDecisions.CrystalReports.Engine.PrintOptions.CopyTo(PrinterSettings printer, PageSettings page)
   at CrystalDecisions.CrystalReports.Engine.FormatEngine.PrintToPrinter(Int32 nCopies, Boolean collated, Int32 startPageN, Int32 endPageN)
   at frmMainScreen.ibutHelp_Click() in C:\@Dev\RMA\Forms\MainScreen.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(ExportFormatType.PortableDocFormat, "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("ItemNumber", "1001-01")
            cReport.PrintOptions.PrinterName = "\\printserver\Zebra"

            cReport.FormatEngine.PrintToPrinter(1, False, 0, 0)

Any help would be greatly appreciated
0
Comment
Question by:jeff411
3 Comments
 
LVL 9

Accepted Solution

by:
Lacutah earned 500 total points
ID: 12324945
Sorry to say this, more than likely it's an implementation issue with the Zebra / Seagull printer drivers and the information it provides Crystal Reports via com interop.  I had a heck of a time getting things to print correctly to a Zebra printer while previewing always looked fine...  Fortunately, I was doing my own PrintDocument implementation, so using different ( properly supported by the driver) methods resolved the problem...
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
System32Int Error 8 56
Getfiles in vb.net 28 42
Trying to use colormap to replace color in png, with a gradient to transparent 7 31
Exit the loop 4 34
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now