C# Barcode Generator Library
How to create barcode to HTML web file?


How to use C# to create barcodes to html file in ASP.NET Core, MVC, WinForms, WPF apps?













How to create, export barcode to HTML web file using C#?


You can easily create barcode as SVG file and embed it in a html file using XImage Barcode Generator c# library.

  1. Create a new Linear object with barcode options applied, such as barcode format, data to encode, barcode dimension width and height.
  2. Render the barcode as SVG vector image file format, and store data in byte array
  3. Write the barcode data in byte array to html file
  4. Generate the html file with barcode in SVG inserted
  5. Now you get a single html web file with barcode embeded



        private static void CreateBarcodeInHtmlFile()
        {
            Linear barcode = new Linear();
            barcode.Type = BarcodeType.CODE128;
            barcode.Data = "ABC-12345-abc";

            barcode.AutoResize = true;
            barcode.Resolution = 1200;
            barcode.UOM = UnitOfMeasure.INCH;
            barcode.BarcodeWidth = 2;
            barcode.BarcodeHeight = 1f;

            byte[] barcodeInBytes = barcode.DrawBarcode(OutputFileType.SVG);
            File.WriteAllText(@"C:\Output\RasterEdge.com\demo-create-barcode-html.html",
                getBarcodeInHtml(Encoding.UTF8.GetString(barcodeInBytes)));
        }

        private static String getBarcodeInHtml(string barcodeSvgInString)
        {
            StringBuilder content = new StringBuilder();
            content.Append("<html><body>");
            content.Append(barcodeSvgInString);
            content.Append("</body></html>");

            return content.ToString();
        }