Spire.Barcode is a professional barcode library specially designed for .NET developers (C#, VB.NET, ASP.NET, .NET Core) and Java developers (J2SE and J2EE) to generate, read and scan 1D & 2D barcodes.

Wed Nov 26, 2014 4:18 pm

hi

I did this to create the barcode in winform in page_load event

Code: Select all
   this.packInfoTableAdapter.Fill(this.dsLabel.PackInfo);
            Spire.Barcode.BarcodeSettings barsetting = new Spire.Barcode.BarcodeSettings();

            //set the x dimension
            barsetting.X = 0.8f;
            barsetting.BarHeight = 25;
            barsetting.Unit = GraphicsUnit.Millimeter;
            barsetting.TextFont = new Font("Arial", 20.0f);
            barsetting.Type = Spire.Barcode.BarCodeType.EAN13;


            foreach (dsLabel.PackInfoRow row in this.dsLabel.PackInfo.Rows)
            {
                //Set the value to encode
                barsetting.Data = row.CustomValue.ToString();
                barsetting.Data2D = row.CustomValue.ToString();

                Spire.Barcode.BarCodeGenerator bargenerator = new Spire.Barcode.BarCodeGenerator(barsetting);
                Image barcodeimage = bargenerator.GenerateImage();
       
                //Generate the barcode image and store it into the Barcode Column
                row.BarCode = imageToByteArray(bargenerator.GenerateImage());
            }


            this.reportViewer1.RefreshReport();
       



how can I do the same thing in the webform?

in web there is a ObjectDataSource that acts as an intermediary with the dataset and do not know how to value the field of the dataset "barcode"

can you help?

cicciuzzo
 
Posts: 5
Joined: Wed Nov 26, 2014 4:00 pm

Thu Nov 27, 2014 3:54 am

Hello,

Thanks for your inquiry.
There is no any difference between winform and webform. Kindly note that the barcode only generate images with Spire.Barcode.BarCodeGenerator.GenerateImage() method.
Sincerely,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Thu Nov 27, 2014 7:56 am

Gary.zhang wrote:Hello,

Thanks for your inquiry.
There is no any difference between winform and webform. Kindly note that the barcode only generate images with Spire.Barcode.BarCodeGenerator.GenerateImage() method.
Sincerely,
Gary
E-iceblue support team


tanks for you reply.

you can give me an example with the web form, because the code that I used with winform not work.

br

cicciuzzo
 
Posts: 5
Joined: Wed Nov 26, 2014 4:00 pm

Thu Nov 27, 2014 4:29 pm

any suggestions? :roll: :roll:

cicciuzzo
 
Posts: 5
Joined: Wed Nov 26, 2014 4:00 pm

Fri Nov 28, 2014 6:04 am

Hello,

Please add a button in webform and refer to the following code.
Code: Select all
 protected void GenerateBarcode_Click(object sender, EventArgs e)
        {
            Spire.Barcode.BarcodeSettings barsetting = new Spire.Barcode.BarcodeSettings();
            barsetting.X = 0.8f;
            barsetting.BarHeight = 25;
            barsetting.Unit = GraphicsUnit.Millimeter;
            barsetting.TextFont = new Font("Arial", 20.0f);
            barsetting.Type = Spire.Barcode.BarCodeType.EAN13;
            barsetting.Data = "123456";
            Spire.Barcode.BarCodeGenerator bargenerator = new Spire.Barcode.BarCodeGenerator(barsetting);
            byte[] myImage = imageToByteArray(bargenerator.GenerateImage());

  }
        private byte[] imageToByteArray(System.Drawing.Image image)
        {
            using (MemoryStream ms = new MemoryStream())
            {
                image.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                return ms.ToArray();
            }
        }

Sincerely,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Fri Nov 28, 2014 6:40 am

maybe I explained bad!


the problem is not generating the barcode, but add in a report rdlc when it appears ...

in winform I created in the 'load event of the form ... but the same code in the load of the webpage does not work.

thanks for your time

br


Gary.zhang wrote:Hello,

Please add a button in webform and refer to the following code.
Code: Select all
 protected void GenerateBarcode_Click(object sender, EventArgs e)
        {
            Spire.Barcode.BarcodeSettings barsetting = new Spire.Barcode.BarcodeSettings();
            barsetting.X = 0.8f;
            barsetting.BarHeight = 25;
            barsetting.Unit = GraphicsUnit.Millimeter;
            barsetting.TextFont = new Font("Arial", 20.0f);
            barsetting.Type = Spire.Barcode.BarCodeType.EAN13;
            barsetting.Data = "123456";
            Spire.Barcode.BarCodeGenerator bargenerator = new Spire.Barcode.BarCodeGenerator(barsetting);
            byte[] myImage = imageToByteArray(bargenerator.GenerateImage());

  }
        private byte[] imageToByteArray(System.Drawing.Image image)
        {
            using (MemoryStream ms = new MemoryStream())
            {
                image.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                return ms.ToArray();
            }
        }

Sincerely,
Gary
E-iceblue support team

cicciuzzo
 
Posts: 5
Joined: Wed Nov 26, 2014 4:00 pm

Fri Nov 28, 2014 9:49 am

Hello,

It seems that the issue is not caused by our product. Sorry that it might be not able to provide you the solution to the issue out of our product.

Thanks,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Return to Spire.BarCode