Skip to content

Barcode in Crystal Report in VB.Net

rachayita jaiswal

Asked Oct 2, 2013, 11:57 PM EDT1 answer
Share
LinkedInX
HI,

 I have created crystal report and i am generating Bar code image, Barcode string i am getting from data base so may code is - 

SQL
barcode = DashboardDS.Tables(0).Rows(i).Item("Barcode").ToString  // barcode string i am getting from data base


            Dim imgBarcpde As New System.Web.UI.WebControls.Image
            Using bitmap As New Bitmap(barcode.Length * 40, 80)
                Using G = Graphics.FromImage(bitmap)
                    Dim ofont As New Font("IDAutomationHC39M", 16)
                    Dim fpoint As New PointF(2.0F, 2.0F)
                    Dim blackBrush As New SolidBrush(Color.Black)
                    Dim whiteBrush As New SolidBrush(Color.White)
                    G.FillRectangle(whiteBrush, 0, 0, bitmap.Width, bitmap.Height)
                    G.DrawString(barcode, ofont, blackBrush, fpoint)
                End Using
                Using ms As New MemoryStream()
                    bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Png)
                    Dim byteimage As Byte() = ms.ToArray()
                    Convert.ToBase64String(byteimage)
                    imgBarcpde.ImageUrl = "data:image/png;base64," + Convert.ToBase64String(byteimage)
                End Using
                barcodeimage.Controls.Add(imgBarcpde) // binding barcode image
            End Using

dsSummary.Tables("ObjectSummary").Rows.Add( ------ ) // here i want to bind this panel.

I am not getting this please help.

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.