1
votes

I know there are similar questions about this topic,but somehow I'm not able to crack this.

I googled this issue and got lot of references but none of them worked for me :-(

I'm creating a crystal report which i will be using for badge printing.

Everything is fine except i want a barcode in the report which is not showing up.

I'm creating this barcode in runtime and saving it in the datatable which i bind to the report.

I know there are two ways to do that.

and I'm able to get the image using OLE Object,by specifying the Graphic property of the object to the database field which contains the path of the image.

but the Problem with this approach is that, i have to save the image and the number of badges can go up to 1 lakh and i don't want to save 1 lakh image files on sever.

Rather i want to go for the other approach,To bind the Byte[] field to report but somehow that is not working for me.

Here is the code.

           System.IO.MemoryStream strmem = new System.IO.MemoryStream();

            bc.Save(strmem, System.Drawing.Imaging.ImageFormat.Tiff);

            Byte[] mybit = new Byte[strmem.Length];

            strmem.Read(mybit, 0, Convert.ToInt32(strmem.Length));

                dt.Rows[0]["Barcode_Image"] = mybit;

where dt is the table that i bind to the report and "Barcode_Image" is the System.Byte[] field which contains the byte[] form of barcode image

I already have the Crystal Report Image handler in my web config.

Webconfig: Assemblies

 <assemblies>
            <add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
            <add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            <add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            <add assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
            <add assembly="CrystalDecisions.Shared, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
            <add assembly="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
            <add assembly="CrystalDecisions.ReportSource, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
            <add assembly="CrystalDecisions.ReportAppServer.Controllers, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
            <add assembly="CrystalDecisions.ReportAppServer.DataDefModel, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
            <add assembly="CrystalDecisions.CrystalReports.Engine, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
</assemblies>

HTTPHandler in System.web

    <httpHandlers>
        <add path="Telerik.Web.UI.WebResource.axd" verb="*" type="Telerik.Web.UI.WebResource, Telerik.Web.UI" validate="false"/>
  <add verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
    </httpHandlers>

HTTPHandler in System.webServer

<system.webServer>
<handlers>
  <add name="CrystalImageHandler.aspx_GET" verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" preCondition="integratedMode"/>
</handlers>
    <modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>

Note: I'm using visualstudio 2010

kindly guide me,whee am i going wrong

1
Can you not pass the barcode as a string of numeric characters to Crystal and then display using a barcode font? This is how I've always handled barcodes in Crystal. - digital.aaron
If you copy the image link from the report and past it into a new window does it come up with an error message? - Alxwest
@digital.aaron,I guess that's what I'm doing I'm creating the barcode using font and its a valid barcode when i save the file,take printout and scan,it gets scanned,So there's not problem with barcode.After creating,i save the barcode in my dataset in a System.Byte[] column,which is i guess a string of numeric data as you said and I'm binding that dataset to my crystal report.and I'm displaying that byte[] column in report but still no sign of image there. - Neelam
@ Alxwest it says resource cannot be found. - Neelam
Sorry for the late response guys,and thanx for responding. - Neelam

1 Answers

0
votes

The easiest way to print barcodes in Crystal Reports is to pass a string or integer to the report, and display the field using a barcode font. That way you don't have to worry about storing actual image files in the database or passing said image data to Crystal.