In this article, we will explain how to convert a barcode to image in SfBarcodeGenarator using RepaintBoundary. Generating barcodes is a common feature in mobile applications, but converting them into images can be useful when you need to save the barcode for offline use or display it outside of the barcode widget. The RepaintBoundary widget in Flutter provides an easy way to capture any widget as an image, and by combining it with SfBarcodeGenarator, we can create, capture, and display a barcode as an image within the app. The following steps will explain how to capture and convert the barcode into an image using Flutter’s RenderRepaintBoundary and display it on a new screen. Step 1: Create a GlobalKey for RepaintBoundary, which is used to uniquely identify the widget that needs to be captured as an image. final GlobalKey _globalKey = GlobalKey(); Step 2: Place the SfBarcodeGenarator inside a RepaintBoundary, allowing it to be rendered as an image. @override Widget build(BuildContext context) { Column( mainAxisAlignment: MainAxisAlignment.center, children: [ SizedBox( child: RepaintBoundary( key: _globalKey, child: SfBarcodeGenerator(value: 'http://www.syncfusion.com'), ), ), ElevatedButton( onPressed: _renderBarcodeImage, child: const Text('Barcode to image'), ), ], ); } Step 3: Create a function to capture the barcode as an image, using RenderRepaintBoundary to convert the widget’s content into the specified format, such as PNG. Future<void> _renderBarcodeImage() async { final RenderRepaintBoundary boundary = _globalKey.currentContext?.findRenderObject() as RenderRepaintBoundary; final ui.Image data = await boundary.toImage(pixelRatio: 3.0); final bytes = await data.toByteData(format: ui.ImageByteFormat.png); await Navigator.of(context).push( MaterialPageRoute( builder: (BuildContext context) { return Scaffold( body: Center( child: Container( color: Colors.white, child: Image.memory(bytes!.buffer.asUint8List()), ), ), ); }, ), ); } Now, convert the barcode to an image in Flutter using the SfBarcodeGenarator have been implemented as shown below. View the sample in GitHub Conclusion I hope you enjoyed learning about how to convert barcode to image in Flutter SfBarcodeGenarator. You can refer to our Flutter BarcodeGenarator feature tour page to know about its other groundbreaking feature representations. You can also explore our Flutter BarcodeGenarator documentation to understand how to create and manipulate data. For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls. If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!
Syncfusion® Essential® DocIO is a .NET Word library used to create, read, edit, and convert Word documents programmatically without Microsoft Word or interop dependencies. Using this library, you can add DocVariable field inside DISPLAYBARCODE field in Word document using C#. Steps to add DocVariable field inside DISPLAYBARCODE field in Word document: Create a new .NET Core console application project. Install the Syncfusion.DocIO.Net.Core NuGet package as a reference to your project from NuGet.org. Starting with v16.2.0.x, if you reference Syncfusion® assemblies from trial setup or from the NuGet feed, include a license key in your projects. Refer to the link to learn about generating and registering a Syncfusion® license key in your application to use the components without trail message. Include the following namespaces in Program.cs file C# using Syncfusion.DocIO; Use the following code example to add DocVariable field inside DISPLAYBARCODE field in Word document. C# // Creates a new instance of WordDocument (empty Word document). using (WordDocument wordDocument = new WordDocument()) { // Adds a section to the document. IWSection section = wordDocument.AddSection(); // Adds a paragraph to the section. IWParagraph paragraph = section.AddParagraph(); // Adds a document variable named "Barcode" with a value of "123456". wordDocument.Variables.Add("Barcode", "123456"); // Appends a field to the paragraph. The field type is set as FieldUnknown initially. WField field = paragraph.AppendField("DISPLAYBARCODE ", Syncfusion.DocIO.FieldType.FieldUnknown) as WField; // Specifies the field code for the barcode. InsertBarcodeField(paragraph, field); // Updates all document fields to reflect changes. wordDocument.UpdateDocumentFields(); // Saves the output Word document to a specified file stream in DOCX format. using (FileStream stream = new FileStream(Path.GetFullPath(@"Output/Result.docx"), FileMode.OpenOrCreate)) { wordDocument.Save(stream, FormatType.Docx); } } Use the following helper method to insert the field code with nested field. C# /// <summary> /// Inserts the field code with a nested field. /// </summary> static void InsertBarcodeField(IWParagraph paragraph, WField? field) { // Get the index of the field in the paragraph to insert the field code. int fieldIndex = paragraph.Items.IndexOf(field) + 1; // Add the field code for the barcode. field.FieldCode = "DISPLAYBARCODE "; // Increment field index for further insertion. fieldIndex++; // Insert document variables into the field code at the specified index. InsertDocVariables("Barcode", ref fieldIndex, paragraph); // Insert the barcode type (e.g., CODE128) into the paragraph. InsertText(" CODE128", ref fieldIndex, paragraph as WParagraph); } Use the following helper method to insert text such as operators or identifiers into the paragraph. C# /// <summary> /// Inserts text such as operators or identifiers into the paragraph. /// </summary> static void InsertText(string text, ref int fieldIndex, WParagraph paragraph) { // Create a new text range with the specified text. WTextRange textRange = new WTextRange(paragraph.Document); textRange.Text = text; // Insert the text range as a field code item at the specified index. paragraph.Items.Insert(fieldIndex, textRange); // Increment the field index for subsequent insertions. fieldIndex++; } Use the following helper method to insert document variables at the given index in the specified paragraph. C# /// <summary> /// Inserts document variables at the given index in the specified paragraph. /// </summary> static void InsertDocVariables(string fieldName, ref int fieldIndex, IWParagraph paragraph) { // Create a new paragraph to hold the document variable field. WParagraph para = new WParagraph(paragraph.Document); para.AppendField(fieldName, FieldType.FieldDocVariable); // Get the count of child entities in the paragraph (should be 1 for the field). int count = para.ChildEntities.Count; // Insert the field into the original paragraph, ensuring the complete field structure is added. paragraph.ChildEntities.Insert(fieldIndex, para.ChildEntities[0]); // Increment the field index based on the count of inserted entities. fieldIndex += count; } You can download a complete working sample to add DocVariable field inside DISPLAYBARCODE field in Word document from the GitHub. By executing the program, you will get the Word document as follows. Take a moment to peruse the documentation where you can find basic Word document processing options along with the features like mail merge, merge, split, and compare Word documents, find and replace text in the Word document, protect the Word documents, and most importantly, the PDF and Image conversions with code examples. Conclusion I hope you enjoyed learning how to add DocVariable field inside DISPLAYBARCODE field in Core Word. You can refer to our ASP.NET Core DocIO feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our ASP.NET Core DocIO example to understand how to create and manipulate data. For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls. If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!
Syncfusion® Essential® DocIO is a .NET Word library used to create, read, and edit Word documents programmatically without Microsoft Word or interop dependencies. Using this library, you can add QR code to Word document in C# and VB.NET. Below steps should be followed. Design your template Word document with the required layout and merge fields using Microsoft Word Using Syncfusion PDF library you can generate a QR code. Insert the generated QR code as an image into the Word document with MergeImageField event using Essential® DocIO. Steps to add QR code to Word document using C# and VB.NET: Create a new C# console application project. Install Syncfusion.DocIO.WinForms NuGet package as a reference to your .NET Framework applications from the NuGet.org. Include the following namespace in the Program.cs file. C# using Syncfusion.DocIO; using Syncfusion.DocIO.DLS; using Syncfusion.Pdf.Barcode; using Syncfusion.Pdf.Graphics; VB Imports Syncfusion.DocIO Imports Syncfusion.DocIO.DLS Imports Syncfusion.Pdf.Barcode Imports Syncfusion.Pdf.Graphics Use the following code to add QR code to Word document. C# //Open an existing document. using (WordDocument document = new WordDocument(Path.GetFullPath(@"../../Template.docx"), FormatType.Automatic)) { //Create mail merge events handler for image fields document.MailMerge.MergeImageField += new MergeImageFieldEventHandler(InsertQRBarcode); //Get data to perform mail merge DataTable table = GetDataTable(); //Perform the mail merge document.MailMerge.ExecuteGroup(table); //Save and close the Word document instance document.Save("Result.docx", FormatType.Docx); } System.Diagnostics.Process.Start("Result.docx"); VB 'Open an existing document. Using document As WordDocument = New WordDocument(Path.GetFullPath("../../Template.docx"), Syncfusion.DocIO.FormatType.Automatic) 'Create mail merge events handler for image fields AddHandler document.MailMerge.MergeImageField, AddressOf InsertQRBarcode Dim table As DataTable = GetDataTable() 'Perform the mail merge document.MailMerge.ExecuteGroup(table) 'Save and close the Word document instance document.Save("Result.docx", Syncfusion.DocIO.FormatType.Docx) End Using System.Diagnostics.Process.Start("Result.docx") Include the following helper method to insert QR code image using MergeImageField event. C# private static void InsertQRBarcode(object sender, MergeImageFieldEventArgs args) { WParagraph paragraph = new WParagraph(args.Document); if (args.FieldName == "QRBarcode") { //Generate barcode image for field value. Image barcodeImage = GenerateQRBarcodeImage(args.FieldValue.ToString()); //Set barcode image for merge field args.Image = barcodeImage; } } VB Private Sub InsertQRBarcode(ByVal sender As Object, ByVal args As MergeImageFieldEventArgs) Dim paragraph As WParagraph = New WParagraph(args.Document) If (args.FieldName = "QRBarcode") Then 'Generate barcode image for field value. Dim barcodeImage As Image = GenerateQRBarcodeImage(args.FieldValue.ToString) 'Set barcode image for merge field args.Image = barcodeImage End If End Sub Include the following helper method to generate QR code image using Syncfusion PDF library. C# private static Image GenerateQRBarcodeImage(string qrBarcodeText) { //Drawing QR Barcode PdfQRBarcode barcode = new PdfQRBarcode(); //Set Error Correction Level barcode.ErrorCorrectionLevel = PdfErrorCorrectionLevel.High; //Set XDimension barcode.XDimension = 3; barcode.Text = qrBarcodeText; //Convert the barcode to image Image barcodeImage = barcode.ToImage(new SizeF(125.5f, 135.5f)); return barcodeImage; } VB Private Function GenerateQRBarcodeImage(ByVal qrBarcodeText As String) As Image 'Drawing QR Barcode Dim barcode As PdfQRBarcode = New PdfQRBarcode 'Set Error Correction Level barcode.ErrorCorrectionLevel = PdfErrorCorrectionLevel.High 'Set XDimension barcode.XDimension = 3 barcode.Text = qrBarcodeText 'Convert the barcode to image Dim barcodeImage As Image = barcode.ToImage(New SizeF(125.5f, 135.5f)) Return barcodeImage End Function Include the following helper method to get data for Mail merge execution process. C# private static DataTable GetDataTable() { // List of products name. string[] products = { "Apple Juice", "Grape Juice", "Hot Soup", "Tender Coconut", "Vennila", "Strawberry", "Cherry", "Cone", "Butter", "Milk", "Cheese", "Salt", "Honey", "Soap", "Chocolate", "Edible Oil", "Spices", "Paneer", "Curd", "Bread", "Olive oil", "Vinegar", "Sports Drinks", "Vegetable Juice", "Sugar", "Flour", "Jam", "Cake", "Brownies", "Donuts", "Egg", "Tooth Brush", "Talcum powder", "Detergent Soap", "Room Spray", "Tooth paste", "Apple Juice", "Grape Juice", "Hot Soup", "Tender Coconut", "Vennila", "Strawberry", "Cherry", "Cone", "Butter", "Milk", "Cheese", "Salt", "Honey", "Soap", "Chocolate", "Edible Oil", "Spices", "Paneer", "Curd", "Bread", "Olive oil", "Vinegar", "Sports Drinks", "Vegetable Juice", "Sugar", "Flour", "Jam", "Cake", "Brownies", "Donuts", "Egg", "Tooth Brush", "Talcum powder", "Detergent Soap", "Room Spray", "Tooth paste"}; DataTable table = new DataTable("Product_PriceList"); // Add fields to the Product_PriceList table. table.Columns.Add("ProductName"); table.Columns.Add("Price"); table.Columns.Add("QRBarcode"); DataRow row; int Id = 10001; // Insert values to the table. foreach (string product in products) { row = table.NewRow(); row["ProductName"] = product; switch (product) { case "Apple Juice": row["Price"] = "$12.00"; break; case "Grape Juice": case "Milk": row["Price"] = "$15.00"; break; case "Hot Soup": row["Price"] = "$20.00"; break; case "Tender coconut": case "Cheese": row["Price"] = "$10.00"; break; case "Vennila Ice Cream": row["Price"] = "$15.00"; break; case "Strawberry": case "Butter": row["Price"] = "$18.00"; break; case "Cherry": case "Salt": row["Price"] = "$25.00"; break; default: row["Price"] = "$20.00"; break; } //Add barcode text row["QRBarcode"] = Id.ToString(); table.Rows.Add(row); Id++; } return table; } VB Private Function GetDataTable() As DataTable ' List of products name. Dim products() As String = New String() {"Apple Juice", "Grape Juice", "Hot Soup", "Tender Coconut", "Vennila", "Strawberry", "Cherry", "Cone", "Butter", "Milk", "Cheese", "Salt", "Honey", "Soap", "Chocolate", "Edible Oil", "Spices", "Paneer", "Curd", "Bread", "Olive oil", "Vinegar", "Sports Drinks", "Vegetable Juice", "Sugar", "Flour", "Jam", "Cake", "Brownies", "Donuts", "Egg", "Tooth Brush", "Talcum powder", "Detergent Soap", "Room Spray", "Tooth paste", "Apple Juice", "Grape Juice", "Hot Soup", "Tender Coconut", "Vennila", "Strawberry", "Cherry", "Cone", "Butter", "Milk", "Cheese", "Salt", "Honey", "Soap", "Chocolate", "Edible Oil", "Spices", "Paneer", "Curd", "Bread", "Olive oil", "Vinegar", "Sports Drinks", "Vegetable Juice", "Sugar", "Flour", "Jam", "Cake", "Brownies", "Donuts", "Egg", "Tooth Brush", "Talcum powder", "Detergent Soap", "Room Spray", "Tooth paste"} Dim table As DataTable = New DataTable("Product_PriceList") ' Add fields to the Product_PriceList table. table.Columns.Add("ProductName") table.Columns.Add("Price") table.Columns.Add("QRBarcode") Dim row As DataRow Dim Id As Integer = 10001 ' Insert values to the table. For Each product As String In products row = table.NewRow row("ProductName") = product Select Case (product) Case "Apple Juice" row("Price") = "$12.00" Case "Grape Juice", "Milk" row("Price") = "$15.00" Case "Hot Soup" row("Price") = "$20.00" Case "Tender coconut", "Cheese" row("Price") = "$10.00" Case "Vennila Ice Cream" row("Price") = "$15.00" Case "Strawberry", "Butter" row("Price") = "$18.00" Case "Cherry", "Salt" row("Price") = "$25.00" Case Else row("Price") = "$20.00" End Select 'Add barcode text row("QRBarcode") = Id.ToString table.Rows.Add(row) Id = (Id + 1) Next Return table End Function A complete working example of how to add QR code to Word document using C# can be downloaded from add QR code to Word.zip Input Word document with merge fields as follows. By executing the program, you will get the output Word document with QR code labels as follows. Take a moment to peruse the documentation, where you can find basic Word document processing options along with features like mail merge, merge and split documents, find and replace text in the Word document, protect the Word documents, and most importantly PDF and Image conversions with code examples. Explore more about the rich set of Syncfusion® Word Framework features. Note:Starting with v16.2.0.x, if you reference Syncfusion® assemblies from trial setup or from the NuGet feed, include a license key in your projects. Refer to link to learn about generating and registering Syncfusion® license key in your application to use the components without trail message. ConclusionI hope you enjoyed learning about how to add a QR code to Word using C#, VB.NET.docx.You can refer to our WinForms word feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our WinForms word example to understand how to create and manipulate data.For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls.If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!
The Syncfusion Essential® PDF is a .NET PDF Library used to create, read, and edit PDF documents. Using this library, you can add quiet zones to barcode in the PDF document using C# and VB.NET. Quiet zone: Quiet zone is the blank margin located at either end of a barcode which is used to tell the barcode reader that where a barcode symbology starts and stops. Steps to add quite zones to barcode in the PDF document programmatically: Create a new C# console application project. Install the Syncfusion.Pdf.WinForms NuGet package as a reference to your .NET Framework application from NuGet.org. Include the following namespaces in Program.cs file. C# using Syncfusion.Pdf; using Syncfusion.Pdf.Barcode; using Syncfusion.Pdf.Graphics; using System.Drawing; VB.NET Imports Syncfusion.Pdf Imports Syncfusion.Pdf.Barcode Imports Syncfusion.Pdf.Graphics Imports System.Drawing Use the following code sample to add quiet zones to the barcode in a PDF document. C# //Create a new PDF document. PdfDocument document = new PdfDocument(); //Creates a new page. PdfPage page = document.Pages.Add(); //Creates a new PdfCode93Barcode. PdfCode93Barcode code93 = new PdfCode93Barcode("CODE93"); //Creates a new PdfBarcodeQuietZones. PdfBarcodeQuietZones quietZones = new PdfBarcodeQuietZones(); quietZones.All = 50f; //Sets the barcode quiet zone. code93.QuietZone = quietZones; //Draws a barcode on the new page. code93.Draw(page, new PointF(10, 10)); //Draw a rectangle based on the barcode size. page.Graphics.DrawRectangle(PdfPens.Red, new RectangleF(10, 10, code93.Size.Width, code93.Size.Height)); //Save the document to disk. document.Save("PdfBarcode.pdf"); //This will open the PDF file and the result will be seen in the default PDF Viewer. Process.Start("PdfBarcode.pdf"); VB.NET 'Create a new PDF document. Dim document As PdfDocument = New PdfDocument() 'Creates a new page. Dim page As PdfPage = document.Pages.Add() 'Creates a new PdfCode93Barcode. Dim code93 As PdfCode93Barcode = New PdfCode93Barcode("CODE93") 'Creates a new PdfBarcodeQuietZones. Dim quietZones As PdfBarcodeQuietZones = New PdfBarcodeQuietZones() quietZones.All = 50.0F 'Sets the barcode quiet zone to all sides. code93.QuietZone = quietZones 'Draws a barcode on the new page. code93.Draw(page, New PointF(10, 10)) 'Draw a rectangle based on the barcode size. page.Graphics.DrawRectangle(PdfPens.Red, New RectangleF(10, 10, code93.Size.Width, code93.Size.Height)) 'Save the document to disk. document.Save("PdfBarcode.pdf") 'This will open the PDF file and the result will be seen in the default PDF Viewer. Process.Start("PdfBarcode.pdf") A complete working sample can be download from BarcodeSample.zip. By executing the program, you will get the output document as follows, If we set the quiet zone to 0, then you will get the output document as follows, Take a moment to peruse the documentation. You can also find other options like adding a one-dimensional or two-dimensional barcode in a PDF document, export a barcode as an image, adding a barcode to PDF without displaying the barcode text. Refer to this link to explore a rich set of Syncfusion Essential® PDF features. Note:Starting with v16.2.0.x, if you reference Syncfusion® assemblies from trial setup or the NuGet feed, include a license key in your product. Refer to the link to learn about generating and registering the Syncfusion® license key in your application to use the components without trail message. Also see: Draw barcode in PDF using C# and VB.NETDraw barcode in PDF table cellSet width to the barcode in PDF documentAlign barcode text in PDF document ConclusionI hope you enjoyed learning about how to add quite zones to barcode in PDF using C# and VB.NET in WinForms.You can refer to our WinForms PDF feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our WinForms PDF example to understand how to create and manipulate data.For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls.If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!
The Syncfusion Essential® PDF is a feature-rich and high-performance .NET PDF library that is used to create, read, and edit PDF documents programmatically without Adobe dependencies. Using this library, you can create a stamp annotation with barcode appearance in a PDF document using C# and VB.NET. Steps to create a stamp annotation with barcode appearance in a PDF document using C# programmatically 1. Create a new C# console application project. 2. Install the Syncfusion.PDF.WinForms NuGet packages as a reference to your .NET Framework application from NuGet.org. 3. Include the following namespaces in the Program.cs file. C# using Syncfusion.Pdf; using Syncfusion.Pdf.Barcode; using Syncfusion.Pdf.Graphics; using Syncfusion.Pdf.Interactive; VB.NET Imports Syncfusion.Pdf Imports Syncfusion.Pdf.Barcode Imports Syncfusion.Pdf.Interactive Imports Syncfusion.Pdf.Graphics 4. The following code example shows how to create stamp annotation with barcode appearance in a PDF document using C#. C# //Creating a new PDF Document. PdfDocument document = new PdfDocument(); //Add the margins. document.PageSettings.Margins.All = 0; //Adding a new page to a PDF document. PdfPage page = document.Pages.Add(); //Initialize a new PdfCode39Barcode instance. PdfCode39Barcode barcode = new PdfCode39Barcode(); //Set the height and text for barcode. barcode.BarHeight = 45; barcode.Text = "CODE39$"; //Convert the barcode to image. Image barcodeImage = barcode.ToImage(new SizeF(180, 100)); //Creates a new pdf rubber stamp annotation. RectangleF rectangle = new RectangleF(40, 60, 180, 100); PdfRubberStampAnnotation rubberStampAnnotation = new PdfRubberStampAnnotation(rectangle, " Barcode Rubber Stamp Annotation"); rubberStampAnnotation.Appearance.Normal.Graphics.DrawImage(new PdfBitmap(barcodeImage), 0, 0, rectangle.Width, rectangle.Height); rubberStampAnnotation.Text = "Barcode Properties Rubber Stamp Annotation"; //Adds annotation to the page. page.Annotations.Add(rubberStampAnnotation); //Save and closes the document. document.Save("../../Barcode.pdf"); document.Close(true); VB.NET 'Creating a new PDF Document. Dim document As PdfDocument = New PdfDocument() 'Add the margins. document.PageSettings.Margins.All = 0 'Adding a new page to a PDF document. Dim page As PdfPage = document.Pages.Add() 'Initialize a new PdfCode39Barcode instance. Dim barcode As PdfCode39Barcode = New PdfCode39Barcode() 'Set the height and text for barcode. barcode.BarHeight = 45 barcode.Text = "CODE39$" 'Convert the barcode to image. Dim barcodeImage As Image = barcode.ToImage(New SizeF(180, 100)) 'Creates a new pdf rubber stamp annotation. Dim rectangle As RectangleF = New RectangleF(40, 60, 180, 100) Dim rubberStampAnnotation As PdfRubberStampAnnotation = New PdfRubberStampAnnotation(rectangle, " Barcode Rubber Stamp Annotation") rubberStampAnnotation.Appearance.Normal.Graphics.DrawImage(new PdfBitmap(barcodeImage), 0, 0, rectangle.Width, rectangle.Height); rubberStampAnnotation.Text = "Barcode Properties Rubber Stamp Annotation"; 'Adds annotation to the page. page.Annotations.Add(rubberStampAnnotation) 'Save and closes the document. document.Save("../../Barcode.pdf") document.Close(true) By executing the program, you will get the PDF document as follows. A complete working sample can be downloaded from AnnotationSample.zip. Take a moment to peruse the documentation. You can also find the options like adding one-dimensional and two-dimensional barcodes to the PDF document, set location and size to the barcode, and customizing the barcode appearance. Refer to this link to explore a rich set of Syncfusion Essential® PDF features. An online sample link to the creation of a barcode in a PDF document. Note:Starting with v16.2.0.x, if you reference Syncfusion® assemblies from the trial setup or NuGet feed, include a license key in your projects. Refer to this link to learn about generating and registering the Syncfusion® license key in your application to use the components without trail message. Also see: https://help.syncfusion.com/file-formats/pdf/working-with-barcode https://www.syncfusion.com/kb/9543/how-to-add-or-draw-barcode-in-a-pdf-using-c-and-vb-net https://www.syncfusion.com/kb/9803/how-to-convert-barcode-to-image-using-c-and-vb-net https://www.syncfusion.com/kb/11502/how-to-convert-the-barcode-to-image-in-the-asp-net-core-platform
Description This article describes how to create an example of Barcode in Syncfusion® Flutter widgets. Solution The Syncfusion® Flutter Barcode Generator is a data visualization widget used to generate and display data in a machine-readable format. It provides a perfect approach to encode text using supported symbology types. Refer to the following instructions to know how to use the barcode generator. Step 1: Create a simple project using the instructions given in the Getting Started with your first Flutter app documentation. Step 2: Add the Syncfusion® Flutter Barcode dependency to your pubspec.yaml file. dependencies: syncfusion_flutter_barcodes: ^xx.x.xx Here xx.x.xx denotes the current version of Syncfusion® Flutter Barcodes package. Step 3: Run the following command to get the required packages. $ flutter pub get Step 4: Import the following package in your Dart code. import 'package:syncfusion_flutter_barcodes/barcodes.dart'; Step 5: Add the Barcode Generator widget as a child of any widget. Here, the widget is added as a child of the container widget and the height to the container is specified (otherwise it will take full container height). The default symbology of SfBarcodeGenerator is Code128. @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( body: Center( child: Container( height: 150, child:SfBarcodeGenerator(value:'http://www.syncfusion.com') ) ) ) ); } Screenshots For more information on the Barcode generator, please check the user guide and API reference. View the sample in GitHub
Steps to apply transparent background to the barcode programmatically: Create a new C# console application project. The Syncfusion Essential® PDF is a .NET PDF library used to create, read, and edit PDF documents. Using this library, you can apply transparent background to the barcode using C# and VB.NET. 2. Install the Syncfusion.Pdf.WinForms NuGet package as a reference to your .NET Framework application from Nuget.org. Including the following namespace in Program.cs file. C# using Syncfusion.Pdf.Barcode; using System.Drawing; using System.IO; VB.NET Imports Syncfusion.Pdf.Barcode Imports System.Drawing Imports System.IO Use the following code to apply transparent background to the barcode using C# and VB.NET. C# //Create a bitmap. Bitmap bmp = new Bitmap(200, 200); //Create graphics from the bitmap. Graphics graphics = Graphics.FromImage(bmp); //Drawing QR Barcode. PdfQRBarcode barcode = new PdfQRBarcode(); //Set the Error correction level. barcode.ErrorCorrectionLevel = PdfErrorCorrectionLevel.High; //Creates a new PdfBarcodeQuietZones. PdfBarcodeQuietZones quietZones = new PdfBarcodeQuietZones(); quietZones.All = 0f; //Set the XDimension. barcode.XDimension = 3; //Add the barcode text. barcode.Text = "http://www.syncfusion.com"; //Apply the quiet zone. barcode.QuietZone = quietZones; //Convert the barcode to an image. System.Drawing.Image barcodeImage = barcode.ToImage(); //Set transparency to the image. Bitmap bitmap = (Bitmap)barcodeImage; bitmap.MakeTransparent(System.Drawing.Color.Transparent); //Save the transparency applied image. MemoryStream imageStream = new MemoryStream(); bitmap.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png); //Load the transparency applied image. System.Drawing.Image transparencyImage = System.Drawing.Image.FromStream(imageStream); //Fill the rectangle with transparency. Brush brush = new SolidBrush(System.Drawing.Color.FromArgb(128, 128, 128, 128)); graphics.FillRectangle(brush, 0, 0, 200, 200); //Draw the transparency image with the bitmap graphics. graphics.DrawImage(transparencyImage, new System.Drawing.RectangleF(0, 0, 200, 200)); //Save the transparency image. bmp.Save("Barcode.png", System.Drawing.Imaging.ImageFormat.Png); //Dispose all the objects. graphics.Dispose(); bmp.Dispose(); bitmap.Dispose(); VB.NET 'Create a bitmap. Dim bmp As Bitmap = New Bitmap(200, 200) 'Create graphics from the bitmap. Dim graphics As Graphics = Graphics.FromImage(bmp) 'Drawing QR Barcode. Dim barcode As PdfQRBarcode = New PdfQRBarcode() 'Set the Error correction level. barcode.ErrorCorrectionLevel = PdfErrorCorrectionLevel.High 'Creates a new PdfBarcodeQuietZones. Dim quietZones As PdfBarcodeQuietZones = New PdfBarcodeQuietZones() quietZones.All = 0F 'Set the XDimension. barcode.XDimension = 3 'Add the barcode text. barcode.Text = "http://www.syncfusion.com" 'Apply the quiet zone. barcode.QuietZone = quietZones 'Convert the barcode to an image Dim barcodeImage As System.Drawing.Image = barcode.ToImage() 'Set transparency to the image Dim bitmap As Bitmap = CType(barcodeImage, Bitmap) bitmap.MakeTransparent(System.Drawing.Color.Transparent) 'Save the transparency applied image. Dim imageStream As MemoryStream = New MemoryStream() bitmap.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png) 'Load the transparency applied image. Dim transparencyImage As System.Drawing.Image = System.Drawing.Image.FromStream(imageStream) 'Fill the rectangle with transparency. Dim brush As Brush = New SolidBrush(System.Drawing.Color.FromArgb(128, 128, 128, 128)) graphics.FillRectangle(brush, 0, 0, 200, 200) 'Draw the transparency image with the bitmap graphics. graphics.DrawImage(transparencyImage, New System.Drawing.RectangleF(0, 0, 200, 200)) 'Save the transparency bitmap. bmp.Save("Barcode.png", System.Drawing.Imaging.ImageFormat.Png) //Dispose all the objects. graphics.Dispose() bmp.Dispose() bitmap.Dispose() A complete working sample can be download from BarcodeImageSample.zip.By executing the program, you will get the image file as follows. Take a moment to peruse the documentation. You can find the options like adding one-dimensional barcode and two-dimensional barcode to PDF document, adding a barcode to the PDF document without displaying the barcode text, export barcode as an image, customizing barcode appearance.Refer to this link to explore a rich set of Syncfusion Essential® PDF features.Note:Starting with v16.2.0.x, if you reference Syncfusion® assemblies from trial setup or the NuGet feed, include a license key in your product. Refer to this link to learn about generating and registering the Syncfusion® license key in your application to use the components without trail message.Also see:Add barcode in the PDF documentSet width to barcode in the PDF documentAlign barcode text in the PDF documentConvert barcode to image ASP.NET Core platform ConclusionI hope you enjoyed learning about how to apply transparency to the generated barcode image in WinForms PDF.You can refer to our WinForms PDF feature tour page to know about its other groundbreaking feature representations documentation and how to quickly get started for configuration specifications. You can also explore our WinForms PDF example to understand how to create and manipulate data.For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls.If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!
Syncfusion Essential® PDF is a .NET PDF library used to create, read, and edit PDF documents. Using this library, you can create a barcode and you can convert the barcode to image in the ASP.NET Core platform. Steps to convert the barcode to image in the ASP.NET Core platform: Create a new ASP.NET Core Web Application project. Select the Web Application pattern (Model-View-Controller) for the project. Install the Syncfusion.Pdf.Imaging.Net.Core NuGet package as a reference to your .NET Core application from nuget.org. Add a new button in the Index.cshtml as shown below. CSHTML @{Html.BeginForm("CreateDocument", "Home", FormMethod.Get); { <div> <input type="submit" value="Create Document" style="width:150px;height:27px" /> </div> } Html.EndForm(); } A default controller with a name HomeController.cs is added to the ASP.NET Core project. Include the following namespaces in that HomeController.cs file. C# using Syncfusion.Pdf.Barcode; using Syncfusion.Pdf.Graphics; using Syncfusion.Drawing; VB.NET Imports Syncfusion.Pdf.Barcode Imports Syncfusion.Pdf.GraphicsImports Syncfusion.Drawing Add a new action method CreateDocument in the HomeController.cs and include the following code snippet to convert the barcode to image and download it. C# //Drawing QR Barcode PdfQRBarcode barcode = new PdfQRBarcode(); //Set an error correction level barcode.ErrorCorrectionLevel = PdfErrorCorrectionLevel.Medium; //Set XDimension barcode.XDimension = 3; //Set text barcode.Text = "http://www.syncfusion.com"; //Convert to image Stream barcodeImage = barcode.ToImage(new SizeF(300,300)); //Download the PDF document in the browser FileStreamResult fileStreamResult = new FileStreamResult(barcodeImage, "application/jpg"); fileStreamResult.FileDownloadName = "Barcode.jpg"; return fileStreamResult; VB.NET 'Drawing QR Barcode Dim barcode As PdfQRBarcode = New PdfQRBarcode() 'Set an error correction level barcode.ErrorCorrectionLevel = PdfErrorCorrectionLevel.Medium 'Set XDimension barcode.XDimension = 3 'Set text barcode.Text = "http://www.syncfusion.com" 'Convert to image Dim barcodeImage As Stream = barcode.ToImage(New SizeF(300, 300)) 'Download the PDF document in the browser Dim fileStreamResult As FileStreamResult = New FileStreamResult(barcodeImage, "application/jpg") fileStreamResult.FileDownloadName = "Barcode.jpg" Return fileStreamResult A complete working sample can be downloaded from BarcodeToImage.zip. By executing the program, you will get the image as follows. Take a moment to peruse the documentation where you can find other options like adding one-dimensional and two-dimensional barcodes, set location, and size to the barcode, export barcode as an image, and customizing the barcode appearance.Refer here to explore the rich set of Syncfusion Essential® PDF features. Note:Starting with v16.2.0.x, if you reference Syncfusion® assemblies from trial setup or the NuGet feed, include a license key in your projects. Refer to the link to learn about generating and registering the Syncfusion® license key in your application to use the components without trail message.See Also:Convert Barcode to image in the Windows Forms platformAdd barcode in PDF document ConclusionI hope you enjoyed learning about how the ASP.NET Core framework handle barcode to image conversion.You can refer to our WinForms PDF feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our WinForms PDF example to understand how to create and manipulate data.For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls.If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!
Syncfusion Essential® PDF is a .NET PDF library used to create, read, and edit PDF documents. Using this library, you can create a barcode and you can convert the barcode to image in the ASP.NET Core platform. Steps to convert the barcode to image in the ASP.NET Core platform: Create a new ASP.NET Core Web Application project. Select the Web Application pattern (Model-View-Controller) for the project. Install the Syncfusion.Pdf.Imaging.Net.Core NuGet package as a reference to your .NET Core application from nuget.org. Add a new button in the Index.cshtml as shown below. CSHTML @{Html.BeginForm("CreateDocument", "Home", FormMethod.Get); { <div> <input type="submit" value="Create Document" style="width:150px;height:27px" /> </div> } Html.EndForm(); } A default controller with a name HomeController.cs is added to the ASP.NET Core project. Include the following namespaces in that HomeController.cs file. C# using Syncfusion.Pdf.Barcode; using Syncfusion.Pdf.Graphics; using Syncfusion.Drawing; VB.NET Imports Syncfusion.Pdf.Barcode Imports Syncfusion.Pdf.GraphicsImports Syncfusion.Drawing Add a new action method CreateDocument in the HomeController.cs and include the following code snippet to convert the barcode to image and download it. C# //Drawing QR Barcode PdfQRBarcode barcode = new PdfQRBarcode(); //Set an error correction level barcode.ErrorCorrectionLevel = PdfErrorCorrectionLevel.Medium; //Set XDimension barcode.XDimension = 3; //Set text barcode.Text = "http://www.syncfusion.com"; //Convert to image Stream barcodeImage = barcode.ToImage(new SizeF(300,300)); //Download the PDF document in the browser FileStreamResult fileStreamResult = new FileStreamResult(barcodeImage, "application/jpg"); fileStreamResult.FileDownloadName = "Barcode.jpg"; return fileStreamResult; VB.NET 'Drawing QR Barcode Dim barcode As PdfQRBarcode = New PdfQRBarcode() 'Set an error correction level barcode.ErrorCorrectionLevel = PdfErrorCorrectionLevel.Medium 'Set XDimension barcode.XDimension = 3 'Set text barcode.Text = "http://www.syncfusion.com" 'Convert to image Dim barcodeImage As Stream = barcode.ToImage(New SizeF(300, 300)) 'Download the PDF document in the browser Dim fileStreamResult As FileStreamResult = New FileStreamResult(barcodeImage, "application/jpg") fileStreamResult.FileDownloadName = "Barcode.jpg" Return fileStreamResult A complete working sample can be downloaded from BarcodeToImage.zip. By executing the program, you will get the image as follows. Take a moment to peruse the documentation where you can find other options like adding one-dimensional and two-dimensional barcodes, set location, and size to the barcode, export barcode as an image, and customizing the barcode appearance. Refer here to explore the rich set of Syncfusion Essential® PDF features. Note:Starting with v16.2.0.x, if you reference Syncfusion® assemblies from trial setup or the NuGet feed, include a license key in your projects. Refer to the link to learn about generating and registering the Syncfusion® license key in your application to use the components without trail message. See Also: Convert Barcode to image in the Windows Forms platform Add barcode in PDF document
Syncfusion Essential® PDF is a .NET PDF library used to create, read, and edit PDF documents. Using this library, you can draw a barcode in a PDF table cell. Steps to draw a barcode in a PDF table cell programmatically: Create a new C# console application project. Install the Syncfusion.Pdf.WinForms NuGet package as a reference to your .NET Framework application from NuGet.org. Include the following namespace in the Program.cs file. C# using System.Drawing; using Syncfusion.Pdf; using Syncfusion.Pdf.Grid; using Syncfusion.Pdf.Barcode; VB.NET Imports System.Drawing Imports Syncfusion.Pdf Imports Syncfusion.Pdf.Grid Imports Syncfusion.Pdf.Barcode Use the following code snippet to draw a barcode in a PDF table cell. C# //Create a new PDF document PdfDocument pdfDocument = new PdfDocument(); //Add a page PdfPage page = pdfDocument.Pages.Add(); //Create a new PdfGrid PdfGrid pdfGrid = new PdfGrid(); //Create a DataTable DataTable dataTable = new DataTable(); //Add columns to the DataTable dataTable.Columns.Add("Barcode Text"); dataTable.Columns.Add("Barcode"); //Add rows to the DataTable dataTable.Rows.Add(new object[] { "CODE39$", "" }); //Assign data source pdfGrid.DataSource = dataTable; //Set height pdfGrid.Rows[0].Height = 70; pdfGrid.BeginCellLayout += PdfGrid_BeginCellLayout; //Draw grid to the page of PDF document pdfGrid.Draw(page, new PointF(10, 10)); //Save the document pdfDocument.Save("Output.pdf"); //Close the document pdfDocument.Close(true); //This will open the PDF file so, the result will be seen in the default PDF viewer Process.Start("Output.pdf"); /// <summary> /// Event handler to draw barcode in grid cell /// </summary> /// <param name="sender"></param> /// <param name="args"></param> private static void PdfGrid_BeginCellLayout(object sender, PdfGridBeginCellLayoutEventArgs args) { if(args.RowIndex==0 && args.CellIndex==1 && !args.IsHeaderRow) { //Drawing Code39 barcode PdfCode39Barcode barcode = new PdfCode39Barcode(); //Setting height of the barcode barcode.BarHeight = 45; barcode.Text = "CODE39$"; //Draw barcode with respect to the grid cell bounds barcode.Draw(page, new PointF(args.Bounds.X+5, args.Bounds.Y+5)); } } VB.NET 'Create a new PDF document Dim pdfDocument As PdfDocument = New PdfDocument() 'Add a page Dim page As PdfPage = pdfDocument.Pages.Add() 'Create a new PdfGrid Dim pdfGrid As PdfGrid = New PdfGrid() 'Create a DataTable Dim dataTable As DataTable = New DataTable() 'Add columns to the DataTable dataTable.Columns.Add("Barcode Text") dataTable.Columns.Add("Barcode") 'Add rows to the DataTable dataTable.Rows.Add(New Object() {"CODE39$", ""}) 'Assign data source pdfGrid.DataSource = dataTable 'Set height pdfGrid.Rows(0).Height = 70 AddHandler pdfGrid.BeginCellLayout, AddressOf PdfGrid_BeginCellLayout 'Draw grid to the page of PDF document pdfGrid.Draw(page, New PointF(10, 10)) 'Save the document pdfDocument.Save("Output.pdf") 'Close the document pdfDocument.Close(True) 'This will open the PDF file so, the result will be seen in the default PDF viewer Process.Start("Output.pdf") ''' <summary> ''' Event handler to draw barcode in grid cell ''' </summary> ''' <param name="sender"></param> ''' <param name="args"></param> Private Sub PdfGrid_BeginCellLayout(ByVal sender As Object, ByVal args As PdfGridBeginCellLayoutEventArgs) If args.RowIndex = 0 AndAlso args.CellIndex = 1 AndAlso Not args.IsHeaderRow Then 'Drawing Code39 barcode Dim barcode As PdfCode39Barcode = New PdfCode39Barcode() 'Setting height of the barcode barcode.BarHeight = 45 barcode.Text = "CODE39$" 'Draw barcode with respect to the grid cell bounds barcode.Draw(page, New PointF(args.Bounds.X + 5, args.Bounds.Y + 5)) End If End Sub A complete working sample can be download from DrawBarcodeInTable.zip. By executing the program, you will get the PDF document as follows, Take a moment to peruse the documentation where you can find the options like creating the table using the PdfLightTable and PdfGrid, cell, and row customization in the PdfLightTable and PdfGrid, built-in table styles to PdfGrid, pagination in PdfGrid, and PdfLightTable, and add the one-dimensional barcode, Add two-dimensional barcode, export barcode as an image, and customize barcode appearance. Refer here to explore the rich set of Syncfusion Essential® PDF features. Note:Starting with v16.2.0.x, if you reference Syncfusion® assemblies from trial setup or the NuGet feed, include a license key in your product. Refer to the link to learn about generating and registering the Syncfusion® license key in your application to use the components without trail message. See Also: Add barcode in the PDF document Create a table in a PDF file
Syncfusion® Essential® DocIO is a .NET Word library used to create, read, and edit Word documents programmatically without Microsoft Word or interop dependencies. Using this library, you can add barcode to Word document in C# and VB.NET. Below steps should be followed. Design your template Word document with the required layout and merge fields using Microsoft Word Using Syncfusion PDF library you can generate a barcode. Insert the generated barcode as an image into the Word document with MergeImageField event using Essential® DocIO. Steps to add barcode to Word document using C#: Create a new C# console application project. Install Syncfusion.DocIO.WinForms NuGet package as a reference to your .NET Framework applications from the NuGet.org. Include the following namespace in the Program.cs file. C# using Syncfusion.DocIO; using Syncfusion.DocIO.DLS; using Syncfusion.Pdf.Barcode; VB Imports Syncfusion.DocIO Imports Syncfusion.DocIO.DLS Imports Syncfusion.Pdf.Barcode Use the following code to add barcode to Word document. C# //Opens the template document WordDocument document = new WordDocument(Path.GetFullPath(@"../../Template.docx")); //Creates mail merge events handler for image fields document.MailMerge.MergeImageField += new MergeImageFieldEventHandler(InsertBarcode); //Gets data to perform mail merge DataTable table = GetDataTable(); //Performs the mail merge document.MailMerge.ExecuteGroup(table); //Saves and closes the Word document instance document.Save(Path.GetFullPath(@"../../Sample.docx")); document.Close(); VB 'Opens the template document Dim document As WordDocument = New WordDocument(Path.GetFullPath("../../Template.docx")) 'Creates mail merge events handler for image fields AddHandler document.MailMerge.MergeImageField, AddressOf InsertBarcode 'Gets Data to perform mail merge Dim table As DataTable = GetDataTable() 'Performs the mail merge document.MailMerge.ExecuteGroup(table) 'Saves And closes the Word document instance document.Save(Path.GetFullPath("../../Sample.docx")) document.Close() Include the following helper method to insert barcode image using MergeImageField event. C# private static void InsertBarcode(object sender, MergeImageFieldEventArgs args) { if (args.FieldName == "Barcode") { //Generates barcode image for field value. Image barcodeImage = GenerateBarcodeImage(args.FieldValue.ToString()); //Sets barcode image for merge field args.Image = barcodeImage; } } VB Private Shared Sub InsertBarcode(ByVal sender As Object, ByVal args As MergeImageFieldEventArgs) If args.FieldName = "Barcode" Then 'Generates barcode image for field value. Dim barcodeImage As Image = GenerateBarcodeImage(args.FieldValue.ToString()) 'Sets barcode image for merge field args.Image = barcodeImage End If End Sub Include the following helper method to generate barcode image using Syncfusion PDF library. C# private static Image GenerateBarcodeImage(string barcodeText) { //Initialize a new PdfCode39Barcode instance PdfCode39Barcode barcode = new PdfCode39Barcode(); //Set the height and text for barcode barcode.BarHeight = 45; barcode.Text = barcodeText; //Convert the barcode to image Image barcodeImage = barcode.ToImage(new SizeF(145, 45)); return barcodeImage; } VB Private Shared Function GenerateBarcodeImage(ByVal barcodeText As String) As Image 'Initialize a New PdfCode39Barcode instance Dim barcode As PdfCode39Barcode = New PdfCode39Barcode() 'Set the height And text for barcode barcode.BarHeight = 45 barcode.Text = barcodeText 'Convert the barcode to image Dim barcodeImage As Image = barcode.ToImage(New SizeF(145, 45)) Return barcodeImage End Function Include the following helper method to get data for Mail merge execution process. C# private static DataTable GetDataTable() { // List of products name. string[] products = { "Apple Juice", "Grape Juice", "Hot Soup", "Tender Coconut", "Vennila", "Strawberry", "Cherry", "Cone", "Butter", "Milk", "Cheese", "Salt", "Honey", "Paneer", "Curd", "Bread", "Olive oil", "Vinegar", "Sports Drinks", "Vegetable Juice", "Sugar", "Flour", "Jam", "Cake", "Brownies", "Donuts", "Egg", "Tooth Brush", "Talcum powder", "Detergent Soap", "Room Spray", "Tooth paste"}; DataTable table = new DataTable("Product_PriceList"); // Add fields to the Product_PriceList table. table.Columns.Add("ProductName"); table.Columns.Add("Price"); table.Columns.Add("Barcode"); DataRow row; int Id =10001; // Inserting values to the tables. foreach (string product in products) { row = table.NewRow(); row["ProductName"] = product; switch (product) { case "Apple Juice": row["Price"] = "$12.00"; break; case "Grape Juice": case "Milk": row["Price"] = "$15.00"; break; case "Hot Soup": row["Price"] = "$20.00"; break; case "Tender coconut": case "Cheese": row["Price"] = "$10.00"; break; case "Vennila Ice Cream": row["Price"] = "$15.00"; break; case "Strawberry": case "Butter": row["Price"] = "$18.00"; break; case "Cherry": case "Salt": row["Price"] = "$25.00"; break; default: row["Price"] = "$20.00"; break; } //Add barcode text row["Barcode"] = Id.ToString(); table.Rows.Add(row); Id++; } return table; } VB Private Shared Function GetDataTable() As DataTable 'List of products name. Dim products As String() = {"Apple Juice", "Grape Juice", "Hot Soup", "Tender Coconut", "Vennila", "Strawberry", "Cherry", "Cone", "Butter", "Milk", "Cheese", "Salt", "Honey", "Paneer", "Curd", "Bread", "Olive oil", "Vinegar", "Sports Drinks", "Vegetable Juice", "Sugar", "Flour", "Jam", "Cake", "Brownies", "Donuts", "Egg", "Tooth Brush", "Talcum powder", "Detergent Soap", "Room Spray", "Tooth paste"} Dim table As DataTable = New DataTable("Product_PriceList") 'Add fields to the Product_PriceList table. table.Columns.Add("ProductName") table.Columns.Add("Price") table.Columns.Add("Barcode") Dim row As DataRow Dim Id As Integer = 10001 'Inserting values to the tables For Each product As String In products row = table.NewRow() row("ProductName") = product Select Case product Case "Apple Juice" row("Price") = "$12.00" Case "Grape Juice", "Milk" row("Price") = "$15.00" Case "Hot Soup" row("Price") = "$20.00" Case "Tender coconut", "Cheese" row("Price") = "$10.00" Case "Vennila Ice Cream" row("Price") = "$15.00" Case "Strawberry", "Butter" row("Price") = "$18.00" Case "Cherry", "Salt" row("Price") = "$25.00" Case Else row("Price") = "$20.00" End Select 'Add barcode text row("Barcode") = Id.ToString() table.Rows.Add(row) Id += 1 Next Return table End Function A complete working example of how to add barcode to Word document using C# can be downloaded from add barcode to Word.zip Input Word document with merge fields as follows. By executing the program, you will get the output Word document with barcode labels as follows. Take a moment to peruse the documentation, where you can find basic Word document processing options along with features like mail merge, merge and split documents, find and replace text in the Word document, protect the Word documents, and most importantly PDF and Image conversions with code examples. Explore more about the rich set of Syncfusion® Word Framework features. Note:Starting with v16.2.0.x, if you reference Syncfusion® assemblies from trial setup or from the NuGet feed, include a license key in your projects. Refer to link to learn about generating and registering Syncfusion® license key in your application to use the components without trail message.
We need to add the barcode data extension to show the barcode item in our standalone Report Designer application. Find the below step for how to add the barcode data extension in our standalone angular JS application. 1.Add the below attached barcode standalone sample in our application. Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/BarcodeExtension_-1927834608.zip 2.Add the extension in your application web.config file as shown in below code example. <configuration> <configSections> <section name="ReportingExtensions" type="Syncfusion.Reporting.Extensions, syncfusion.EJ.ReportViewer" allowLocation="true" allowDefinition="Everywhere" /> </configSections> <ReportingExtensions> <ReportItems> <ReportItem Name="Barcode" Assembly="Syncfusion.Extensions.BarcodeCRI" Type="Syncfusion.Extensions.BarcodeCRI.BarcodeCustomReportItem" /> </ReportItems> </ReportingExtensions> </configuration> 3.Add the reportItemExtension property in default.html page as shown in below code example. <link href="Scripts/extension/barcode.reportitem.css" rel="stylesheet" /> <script src="Scripts/extension/barcode.reportitem.js"></script> </head> <body > <div ng-controller="ReportController"> <div ng-if="report"> <div id="container" ej-reportdesigner="ej-reportdesigner" e-toolbarsettings="toolbarsettings" e-ajaxbeforeload="ajaxbeforeload" e-reportitemextensions="reportItemExtensions" e-serviceurl="samplevalue" style="position: absolute;height:500px;width:100%"></div> </div> </div> <script type="text/javascript"> angular.module('syncApp', ['ejangular']).controller('ReportController', function ($scope) { $scope.report = true; $scope.samplevalue = '../../api/ReportingAPI'; $scope.ajaxbeforeload = "ajaxBeforeLoad"; $scope.reportItemExtensions = [{ name: 'barcode', className: 'EJBarcode', imageClass: 'customitem-barcode', displayName: 'Barcode', category: 'Data Patterns' }]; Output snap: Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/ReportDesignerSample-1081120422.zip
The Syncfusion Essential Barcode control is used to create various types of barcodes. Using this control, you can print barcode on a printer using C# and VB.NET. Steps to print barcode on a printer programmatically: Create a new C# Windows Forms application project. Install the Syncfusion.SfBarcode.Windows NuGet package as reference to your .NET Framework application from NuGet.org. The SfBarcode control can be added to the application by dragging it from toolbox and dropping in designer. The required assembly references will be added automatically. Use the following code snippet to load and print barcode on a printer. C# public Form1() { InitializeComponent(); //Set text to the encode this.sfBarcode1.Text = "Syncfusion Essential Studio Enterprise edition $995"; } private void button1_Click(object sender, EventArgs e) { //Create a PrintDocument object PrintDocument pd = new PrintDocument(); //Add PrintPage event handler pd.PrintPage += new PrintPageEventHandler(this.PrintTextFileHandler); //Call Print Method pd.Print(); } private void PrintTextFileHandler(object sender, PrintPageEventArgs eventArgs) { int size = eventArgs.MarginBounds.Width; //Create a graphics with the size of the printer page's width Bitmap imageToPr = new Bitmap(size, size); Graphics graphics = Graphics.FromImage(imageToPr); graphics.DrawImage(sfBarcode1.ToImage(sfBarcode1.Size), new Rectangle(0, 0, size, size)); //Draw barcode image into the printer graphics eventArgs.Graphics.DrawImage(imageToPr, new Rectangle((int)eventArgs.MarginBounds.Left, (int)eventArgs.MarginBounds.Top, imageToPr.Width, imageToPr.Height), 0, 0, size, size, GraphicsUnit.Pixel); } VB.NET Sub New() InitializeComponent() sfBarcode1.Text = "http://www.google.com" End Sub Sub button1_Click(sender As Object, eventArgs As EventArgs) 'Create a PrintDocument object Dim pd As New PrintDocument() 'Add PrintPage event handler AddHandler pd.PrintPage, New PrintPageEventHandler(AddressOf PrintTextFileHandler) 'Call Print Method pd.Print() End Sub Private Sub PrintTextFileHandler(sender As Object, eventArgs As PrintPageEventArgs) Dim size As Integer = eventArgs.MarginBounds.Width 'Create a graphics with the size of the printer page's width Dim imageToPr As New Bitmap(size, size) Dim graphics__1 As Graphics = Graphics.FromImage(imageToPr) graphics__1.DrawImage(sfBarcode1.ToImage(sfBarcode1.Size), New Rectangle(0, 0, size, size)) Dim rect As RectangleF = New Rectangle(CInt(eventArgs.MarginBounds.Left), CInt(eventArgs.MarginBounds.Top), imageToPr.Width, imageToPr.Height) 'Draw barcode image into the printer graphics eventArgs.Graphics.DrawImage(imageToPr, rect, 0, 0, size, size, GraphicsUnit.Pixel) End Sub A complete working sample can be downloaded from PrintBarcodeOnPrinter.zip. Take a moment to peruse the documentation for Barcode, where you will find other options like creating one and two dimensional barcodes. Refer here to explore the Syncfusion Essential Barcode control for Windows Forms. An online sample link to create one and two dimensional barcode. Note:Starting with v16.2.0.x, if you reference Syncfusion assemblies from trial setup or from the NuGet feed, include a license key in your projects. Refer to link to learn about generating and registering Syncfusion license key in your application to use the components without trail message.
ZXing (zebra crossing) is an open-source tool to decode barcodes within images that fall under the Apache 2.0 license. It allows users to scan most of the 1D and 2D barcodes. Barcode OPX is used to optimize the working of ZXing. This enhanced library read the intelligent Mail Barcode (IBM) and returns the barcode value and type. Steps to read Intelligent Mail Barcode (IMB) programmatically: Create a new C# Windows Forms application project. To use the Barcode Reader feature in applications, add the references to the following set of assemblies: Syncfusion.BarcodeReader.OPX zxing Include the following namespaces in Form1.cs file.// [C# Code] using Syncfusion.BarcodeReader.OPX; ' [VB Code] Imports Syncfusion.BarcodeReader.OPX Use the following code snippet to read Intelligent Mail Barcode programmatically.// [C# Code] string filePath = "IMBBarcode.png"; //Read barcode BarcodeResult result = BarcodeReader.ScanBarcode(filePath); if(result!=null) txtResult.Text += "Barcode Type: " + result.BarcodeType + " " + "Text: " + result.Text + "\r\n"; else MessageBox.Show("Barcode could not be detected", "Barcode Reader", MessageBoxButtons.OK); ' [VB Code] Dim filePath As String = "IMBBarcode.png" Dim result As BarcodeResult = BarcodeReader.ScanBarcode(filePath) If result IsNot Nothing Then txtResult.Text += "Barcode Type: " & result.BarcodeType & " " & "Text: " + result.Text & vbCrLf Else MessageBox.Show("Barcode could not be detected", "Barcode Reader", MessageBoxButtons.OK) End If A complete working sample can be downloaded from BarcodeReaderSample.zip. By executing the program, you will get the barcode type and values as follows. Refer here to learn more about Barcode Reader OPX.
Syncfusion Essential® PDF is a .NET PDF library used to create, read, and edit PDF documents. Using this library, you can set width to the barcode in the PDF document using C# and VB.NET. Steps to set width to the barcode in PDF programmatically: Create a new C# Windows Forms application project. Install the Syncfusion.Pdf.WinForms NuGet package as reference to your .NET Framework application from NuGet.org. Include the following namespaces in the Form1.Designer.cs file. C# using Syncfusion.Pdf; using Syncfusion.Pdf.Barcode; using Syncfusion.Pdf.Graphics; using System.Drawing; VB.NET Imports Syncfusion.Pdf Imports Syncfusion.Pdf.Barcode Imports Syncfusion.Pdf.Graphics Imports System.Drawing Use the following code snippet to set width to the barcode in PDF document. C# //Creating new PDF Document PdfDocument document = new PdfDocument(); document.PageSettings.SetMargins(10f); //Adding new page to PDF document PdfPage page = document.Pages.Add(); //Drawing Code39 barcode PdfCode93ExtendedBarcode barcode = new PdfCode93ExtendedBarcode(); //Setting size of the barcode barcode.Size = new SizeF(250, 100); barcode.Text = "(401)93508890BRAN122790"; //Printing barcode on to the Pdf barcode.Draw(page, new PointF(30, 10)); //Drawing Code39 barcode barcode = new PdfCode93ExtendedBarcode(); barcode.Text = "(00)093508890001"; //Setting size of the barcode barcode.Size = new SizeF(250, 100); //Printing barcode on to the Pdf barcode.Draw(page, new PointF(30, 140)); //Save and close the document document.Save("Barcode.pdf"); document.Close(true); VB.NET 'Creating new PDF Document Dim document As PdfDocument = New PdfDocument() document.PageSettings.SetMargins(10) 'Adding new page to PDF document Dim page As PdfPage = document.Pages.Add() 'Drawing Code39 barcode Dim barcode As PdfCode93ExtendedBarcode = New PdfCode93ExtendedBarcode() 'Setting size of the barcode barcode.Size = New SizeF(250, 100) barcode.Text = "(401)93508890BRAN122790" 'Printing barcode on to the Pdf barcode.Draw(page, New PointF(30, 10)) 'Drawing Code39 barcode barcode = New PdfCode93ExtendedBarcode() barcode.Text = "(00)093508890001" 'Setting size of the barcode barcode.Size = New SizeF(250, 100) 'Printing barcode on to the Pdf barcode.Draw(page, New PointF(30, 140)) 'Save and close the document document.Save("Barcode.pdf") document.Close(True) A complete working sample can be downloaded from SetWidthToBarcode.zip. By executing the program, you will get the PDF document as follows. Take a moment to peruse the documentation for working with barcode, where you will find other options like drawing one and two dimensional barcodes in PDF document, set location and size to the barcode and customizing the barcode appearance.Refer here to explore the rich set of Syncfusion Essential® PDF features.An online sample link to drawing one and two dimensional barcode in PDF document.Note:Starting with v16.2.0.x, if you reference Syncfusion® assemblies from trial setup or from the NuGet feed, include a license key in your projects. Refer to link to learn about generating and registering Syncfusion® license key in your application to use the components without trail message. ConclusionI hope you enjoyed learning about how to set width to the barcode in PDF using C# and VB.NET.You can refer to our WinForms PDF feature tour page to know about its other groundbreaking feature representations. You can also explore our WinForms PDF documentation to understand how to create and manipulate data.For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls.If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!
Syncfusion WinForms Barcode control helps rendering barcodes in desktop application. The control can be merged with any desktop application and easy to encode text using the supported symbol types. The basic structure of a barcode consists of a leading and trailing quiet zone, a start pattern, one or more data characters, optionally one or two check characters, and a stop pattern. Using this control, you can print the barcode in Windows Forms. Steps to print the barcode programmatically: Create a new C# Windows Forms application project. Install the Syncfusion.SfBarcode.Windows NuGet package as reference to your .NET Framework application from NuGet.org. Include the following namespaces in the Form1.Designer.cs file.// [C# Code] using System.Drawing; using System.Drawing.Printing; using Syncfusion.Windows.Forms.Barcode; using System.Windows.Forms; ' [VB Code] Imports System.Drawing Imports System.Drawing.Printing Imports Syncfusion.Windows.Forms.Barcode Imports System.Windows.Forms Use the following code snippet to print the barcode.// [C# Code] //Initialize the Barcode control SfBarcode barcode = new SfBarcode(); //Set the barcode symbology type barcode.Symbology = BarcodeSymbolType.Code128A; //Set the input text barcode.Text = textBox1.Text; //Set the barcode size barcode.Size = pictureBox1.Size; //Export the Barcode control as image pictureBox1.Image = barcode.ToImage(); bitmap = new Bitmap(barcode.ToImage()); //Initialize the print document PrintDocument printDocument = new PrintDocument(); PrintDialog pdialog = new PrintDialog(); if (pdialog.ShowDialog() == DialogResult.OK) { printDocument.PrinterSettings.PrinterName = pdialog.PrinterSettings.PrinterName; //Triggers to print current page printDocument.PrintPage += printDocument_PrintPage; printDocument.Print(); } // Event handler to save the PrintDocument page as image void printDocument_PrintPage(object sender, PrintPageEventArgs e) { //Draw barcode into PDF page e.Graphics.DrawImage(bitmap, 0, 0); e.HasMorePages = false; } ' [VB Code] 'Initialize the Barcode control Dim barcode As New SfBarcode() 'Set the barcode symbology type barcode.Symbology = BarcodeSymbolType.Code128A 'Set the input text barcode.Text = TextBox1.Text 'Set the barcode size barcode.Size = PictureBox1.Size 'Export the Barcode control as image PictureBox1.Image = barcode.ToImage() Bitmap = New Bitmap(barcode.ToImage()) 'Initialize the print document Dim printDocument As New PrintDocument() Dim pdialog As New PrintDialog() If pdialog.ShowDialog() = DialogResult.OK Then printDocument.PrinterSettings.PrinterName = pdialog.PrinterSettings.PrinterName 'Triggers to print current page AddHandler printDocument.PrintPage, AddressOf printDocument_PrintPage printDocument.Print() End If 'Event handler to save the PrintDocument page as image Private Sub printDocument_PrintPage(sender As Object, e As PrintPageEventArgs) 'Draw barcode into PDF page e.Graphics.DrawImage(Bitmap, 0, 0) e.HasMorePages = False End Sub Download the complete work sample from BarcodeSample.zip. Take a moment to peruse the documentation, where you can find barcode customization, symbology settings for 1D and 2D barcodes with code examples. Refer here to explore the barcode control for Windows Forms. Note:Starting with v16.2.0.x, if you reference Syncfusion assemblies from trial setup or from the NuGet feed, include a license key in your projects. Refer to link to learn about generating and registering Syncfusion license key in your application to use the components without trail message.
The Syncfusion Essential JS Barcode control is used to render one-dimension and two-dimension barcodes in webpage. Barcode provides a simple and inexpensive method of encoding text information that can be easily read by electronic readers. Using this control, you can get an image from barcode. Steps to get an image from barcode programmatically: Add div container for barcode rendering. <div id="barcode"></div> Use the following code to get an image from barcode. This can be achieved by setting ID to the barcode canvas manually then convert it to image. <script type="text/javascript"> var barcodeCtrl; $(function () { $("#barcode").ejBarcode({ text: "HTTP://WWW.SYNCFUSION.COM", symbologyType: "qrbarcode", xDimension: 12, }); barcodeCtrl = $("#barcode").data("ejBarcode"); }); function Download(link, canvasId, filename){ link.href = document.querySelector(canvasId).toDataURL(); link.download = filename; } document.getElementById('download').addEventListener('click', function () { Download(this, '#barcode canvas', 'Barcode.png'); }, false); </script> By executing the program, you will get the PNG image as follows. JS Playground link: https://jsplayground.syncfusion.com/osybd0sb Take a moment to peruse the documentation, where you can find options like customizing the appearance of barcode, rendering one dimensional and two dimensional barcodes with code examples. See Also: Convert barcode to image in Windows Forms
Syncfusion Essential® PDF is a .NET PDF library used to create, read, and edit PDF documents. Using this library, you can align barcode text in the PDF document using C# and VB.NET. Steps to align barcode text in PDF programmatically: Create a new C# Windows Forms application project. Install the Syncfusion.Pdf.WinForms NuGet package as reference to your .NET Framework application from NuGet.org. Include the following namespaces in the Form1.cs file. C# using Syncfusion.Pdf; using Syncfusion.Pdf.Barcode; using Syncfusion.Pdf.Graphics; using System.Drawing; VB.NET Imports Syncfusion.Pdf Imports Syncfusion.Pdf.Barcode Imports Syncfusion.Pdf.Graphics Imports System.Drawing Use the following code snippet in the click event of the button to align barcode text in the PDF document. C# //Creating a new PDF document PdfDocument document = new PdfDocument(); document.PageSettings.SetMargins(10f); //Adding new page to the PDF document PdfPage page = document.Pages.Add(); //Barcode size SizeF size = new SizeF(250, 100); //Create a new instance for Code39 barcode PdfCode39Barcode code39 = new PdfCode39Barcode(); code39.Text = "CODE39$"; //Set center alignment to the barcode text code39.TextAlignment = PdfBarcodeTextAlignment.Center; //Setting size of the barcode code39.Size = size; //Draw barcode into the PDF page code39.Draw(page, new PointF(30, 30)); //Set left alignment to the barcode text code39.TextAlignment = PdfBarcodeTextAlignment.Left; //Draw barcode into the PDF page code39.Draw(page, new PointF(30, 150)); //Set right alignment to the barcode text code39.TextAlignment = PdfBarcodeTextAlignment.Right; //Draw barcode into the PDF page code39.Draw(page, new PointF(30, 270)); //Save and close the document document.Save("BarcodeTextAlignment.pdf"); document.Close(true); VB.NET 'Creating a new PDF document Dim document As New PdfDocument() document.PageSettings.SetMargins(10.0F) 'Adding new page to the PDF document Dim page As PdfPage = document.Pages.Add() 'Barcode size Dim size As New SizeF(250, 100) 'Create a new instance for Code39 barcode Dim code39 As New PdfCode39Barcode() code39.Text = "CODE39$" 'Set center alignment to the barcode text code39.TextAlignment = PdfBarcodeTextAlignment.Center 'Setting size of the barcode code39.Size = size 'Draw barcode into the PDF page code39.Draw(page, New PointF(30, 30)) 'Set left alignment to the barcode text code39.TextAlignment = PdfBarcodeTextAlignment.Left 'Draw barcode into the PDF page code39.Draw(page, New PointF(30, 150)) 'Set right alignment to the barcode text code39.TextAlignment = PdfBarcodeTextAlignment.Right 'Draw barcode into the PDF page code39.Draw(page, New PointF(30, 270)) 'Save and close the document document.Save("BarcodeTextAlignment.pdf") document.Close(True) A complete working sample can be downloaded from AlignBarcodeTestInPDF.zip. By executing the program, you will get the PDF document as follows. Take a moment to peruse the documentation for working with barcode, where you will find other options like drawing one and two dimensional barcodes in the PDF document, setting location and size to the barcode, and customizing the barcode appearance. Refer here to explore the rich set of Syncfusion Essential® PDF features. An online sample link to drawing one and two dimensional barcode in PDF document. Note:Starting with v16.2.0.x, if you reference Syncfusion® assemblies from trial setup or from the NuGet feed, include a license key in your projects. Refer to link to learn about generating and registering Syncfusion® license key in your application to use the components without trail message.
Syncfusion Essential® PDF is a .NET PDF library used to create, read, and edit PDF documents. Using this library, you can add or draw rotated barcode in a PDF document using C# and VB.NET. Steps to add or draw rotated barcode in a PDF programmatically: Create a new C# console application project. Install the Syncfusion.Pdf.WinForms NuGet package as reference to your .NET Framework application from NuGet.org. Include the following namespace in the Program.cs file. C# using Syncfusion.Pdf; using Syncfusion.Pdf.Barcode; using Syncfusion.Pdf.Graphics; using System.Drawing; VB.NET Imports System.Drawing Imports Syncfusion.Pdf Imports Syncfusion.Pdf.Barcode Imports Syncfusion.Pdf.Graphics Use the following code snippet to add or draw rotated barcode in PDF document. C# //Create a new PDF document PdfDocument document = new PdfDocument(); //Adding new page to PDF document PdfPage page = document.Pages.Add(); //Drawing Code39 barcode PdfCode39Barcode barcode = new PdfCode39Barcode(); //Set height of the barcode barcode.BarHeight = 45; //Setting text of the barcode barcode.Text = "CODE39"; //Save the current graphics state PdfGraphicsState gs = page.Graphics.Save(); //Draw string page.Graphics.DrawString("Code39 Barcode drawn vertically", new PdfStandardFont(PdfFontFamily.Helvetica, 10, PdfFontStyle.Bold), PdfBrushes.Black, new PointF(20, 30)); //Set translate transform in the position where the barcode should be drawn page.Graphics.TranslateTransform(100, 170); //Rotate the graphics to 90 degrees page.Graphics.RotateTransform(-90); //Printing barcode on to the PDF barcode.Draw(page, new PointF(0, 0)); //Restore the previous graphics state page.Graphics.Restore(gs); //Save the document document.Save("Barcode.pdf"); //Close the document document.Close(true); //This will open the PDF file so, the result will be seen in default PDF viewer Process.Start("Barcode.pdf"); VB.NET Dim document As PdfDocument = New PdfDocument 'Adding new page to PDF document Dim page As PdfPage = document.Pages.Add 'Drawing Code39 barcode Dim barcode As PdfCode39Barcode = New PdfCode39Barcode 'Set height of the barcode barcode.BarHeight = 45 'Setting text of the barcode barcode.Text = "CODE39" Dim gs As PdfGraphicsState = page.Graphics.Save 'Draw string page.Graphics.DrawString("Code39 Barcode drawn vertically", New PdfStandardFont(PdfFontFamily.Helvetica, 10, PdfFontStyle.Bold), PdfBrushes.Black, New PointF(20, 30)) 'Set translate transform in the position where the barcode should be drawn page.Graphics.TranslateTransform(100, 170) 'Rotate the graphics to 90 degrees page.Graphics.RotateTransform(-90) 'Printing barcode on to the PDF barcode.Draw(page, New PointF(0, 0)) 'Restore the previous graphics state page.Graphics.Restore(gs) 'Save the document document.Save("Barcode.pdf") 'Close the document document.Close(True) 'This will open the PDF file so, the result will be seen in default PDF viewer Process.Start("Barcode.pdf") A complete working sample can be downloaded from RotatePDFBarcode.zip By executing the program, you will get the PDF document as follows. Take a moment to peruse the documentation, where you can find the options like adding one dimensional and two dimensional barcodes to the PDF document, set location and size to the barcode, and customizing the barcode appearance. Refer here to explore the rich set of Syncfusion Essential® PDF features. Note:Starting with v16.2.0.x, if you reference Syncfusion® assemblies from trial setup or from the NuGet feed, include a license key in your projects. Refer to link to learn about generating and registering Syncfusion® license key in your application to use the components without trail message. ConclusionI hope you enjoyed learning about how to rotate barcode vertically in PDF using C# and VB.NET.You can refer to our WinForms PDF feature tour page to know about its other groundbreaking feature representations. You can also explore our documentation to understand how to create and manipulate data.For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls.If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!
Syncfusion Essential Barcode control is used to create various types of barcodes. Using this control, you can export barcode as image without GUI interfaces using C# and VB.NET. Steps to export barcode as image programmatically: Create a new C# Windows Forms application project. Install the Syncfusion.SfBarcode.Windows NuGet package as reference to your .NET Framework application from NuGet.org. Include the following namespaces in the Form1.Designer.cs file. C# using Syncfusion.Windows.Forms.Barcode; using System.Drawing; VB.NET Imports Syncfusion.Windows.Forms.Barcode Imports System.Drawing Use the following code snippet to export barcode to image without using any GUI interfaces. C# //Create a new Barcode control SfBarcode barcode = new SfBarcode(); //Set the barcode text barcode.Text = "Syncfusion Essential Studio Enterprise edition $995"; //Set the barcode type barcode.Symbology = BarcodeSymbolType.QRBarcode; //Set dimension for each block QRBarcodeSetting setting = new QRBarcodeSetting(); setting.XDimension = 6; barcode.SymbologySettings = setting; //Export to image Image img = barcode.ToImage(); //Save the image img.Save("QRBarcode.png", System.Drawing.Imaging.ImageFormat.Png); //Dispose the control barcode.Dispose(); VB.NET 'Create a new Barcode control Dim barcode As SfBarcode = New SfBarcode() 'Set the barcode text barcode.Text = "Syncfusion Essential Studio Enterprise edition $995" 'Set the barcode type barcode.Symbology = BarcodeSymbolType.QRBarcode Dim setting As QRBarcodeSetting = New QRBarcodeSetting() setting.XDimension = 6 barcode.SymbologySettings = setting Dim img As Image = barcode.ToImage() 'Save the image img.Save("QRBarcode.png", System.Drawing.Imaging.ImageFormat.Png) 'Dispose the control barcode.Dispose() Process.Start("QRBarcode.png") A complete working sample can be downloaded from ConvertBarcodeToImage.zip. By executing the program, you will get the PNG image as follows. Take a moment to peruse the documentation for Barcode, where you will find other options like creating one and two dimensional barcodes. Refer here to explore the Syncfusion Essential Barcode control for Windows Forms. An online sample link to create one and two dimensional barcode. Note:Starting with v16.2.0.x, if you reference Syncfusion assemblies from trial setup or from the NuGet feed, include a license key in your projects. Refer to link to learn about generating and registering Syncfusion license key in your application to use the components without trail message.
Syncfusion Essential PDF is a .NET PDF library used to create, read, and edit PDF documents. Using this library, you can add or draw barcode in PDF document using C# and VB.NET. Steps to add or draw barcode in PDF programmatically: Create a new C# console application project. Install the Syncfusion.Pdf.WinForms NuGet package as reference to your .NET Framework application from NuGet.org. Include the following namespace in the Program.cs file. C# using Syncfusion.Pdf; using Syncfusion.Pdf.Barcode; using Syncfusion.Pdf.Graphics; using System.Drawing; VB.NET Imports System.Drawing Imports Syncfusion.Pdf Imports Syncfusion.Pdf.Barcode Imports Syncfusion.Pdf.Graphics Use the following code snippet to add or draw barcode in PDF document. C# //Create a new PDF document PdfDocument document = new PdfDocument(); //Adding new page to PDF document PdfPage page = document.Pages.Add(); #region Code39 //Drawing Code39 barcode PdfCode39Barcode barcode = new PdfCode39Barcode(); //Set height of the barcode barcode.BarHeight = 45; //Setting text of the barcode barcode.Text = "CODE39$"; //Draw string page.Graphics.DrawString("Code39", new PdfStandardFont(PdfFontFamily.Helvetica, 10,PdfFontStyle.Bold), PdfBrushes.Black, new PointF(20,30)); //Printing barcode on to the PDF barcode.Draw(page, new PointF(50, 70)); #endregion #region QRBarcode //Drawing QR barcode PdfQRBarcode qrBarcode = new PdfQRBarcode(); //Set Error Correction Level qrBarcode.ErrorCorrectionLevel = PdfErrorCorrectionLevel.High; //Set XDimension qrBarcode.XDimension = 3; qrBarcode.Text = "http://www.syncfusion.com"; //Draw string page.Graphics.DrawString("QR Barcode", new PdfStandardFont(PdfFontFamily.Helvetica, 10, PdfFontStyle.Bold), PdfBrushes.Black, new PointF(20, 180)); //Printing barcode on to the PDF qrBarcode.Draw(page, new PointF(50, 200)); #endregion //Save the document document.Save("Barcode.pdf"); //Close the document document.Close(true); //This will open the PDF file so, the result will be seen in default PDF viewer Process.Start("Barcode.pdf"); VB.NET 'Create a new PDF document Dim document As New PdfDocument() 'Adding new page to PDF document Dim page As PdfPage = document.Pages.Add() #Region "Code39" 'Drawing Code39 barcode Dim barcode As New PdfCode39Barcode() 'Set height of the barcode barcode.BarHeight = 45 'Setting text of the barcode barcode.Text = "CODE39$" 'Draw string page.Graphics.DrawString("Code39", New PdfStandardFont(PdfFontFamily.Helvetica, 10, PdfFontStyle.Bold), PdfBrushes.Black, New PointF(20, 30)) 'Printing barcode on to the PDF barcode.Draw(page, New PointF(50, 70)) #End Region #Region "QR Barcode" 'Drawing QR barcode Dim qrBarcode As New PdfQRBarcode() 'Set Error Correction Level qrBarcode.ErrorCorrectionLevel = PdfErrorCorrectionLevel.High 'Set XDimension qrBarcode.XDimension = 3 qrBarcode.Text = "http://www.syncfusion.com" 'Draw string page.Graphics.DrawString("QR Barcode", New PdfStandardFont(PdfFontFamily.Helvetica, 10, PdfFontStyle.Bold), PdfBrushes.Black, New PointF(20, 180)) 'Printing barcode on to the PDF qrBarcode.Draw(page, New PointF(50, 200)) #End Region 'Save the document document.Save("Barcode.pdf") 'Close the document document.Close(True) 'This will open the PDF file so, the result will be seen in default PDF viewer Process.Start("Barcode.pdf") A complete working sample can be downloaded from BarcodeSample.zip. By executing the program, you will get the PDF document as follows. Take a moment to peruse the documentation, where you can find the options like adding one dimensional and two dimensional barcodes to the PDF document, set location and size to the barcode, and customizing the barcode appearance. Refer here to explore the rich set of Syncfusion Essential PDF features. An online sample link to creation of barcode in PDF document. Note:Starting with v16.2.0.x, if you reference Syncfusion assemblies from trial setup or from the NuGet feed, include a license key in your projects. Refer to link to learn about generating and registering Syncfusion license key in your application to use the components without trail message. ConclusionI hope you enjoyed learning about how to add or draw QR Code(barcode) in a PDF using C# and VB.NET. You can refer to our .NET PDF Framework’s feature tour page to know about its other groundbreaking feature representations and documentation to know about how to quickly getting started for configuration specifications. You can also explore our PDF example to understand how to create and manipulate data in .NET PDF. For current customers, you can check out our Document processing libraries from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our JavaScript Context Menu and other JavaScript controls. If you have any queries or require clarifications, please let us know in comments below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!
This knowledge base explains how to print the grid when Syncfusion canvas control such as barcode as one of the grid column using Print feature of JavaScript Grid. Solution: Using beforePrint event, we can print the grid with column contains syncfusion canvas control (ejBarcode) as one of the column by converting the canvas element into image. Initially we can display the ejBarcode in Grid by using column template feature of grid. Render the Grid control. HTML <div id="Grid"></div> JS <script type="text/x-jsrender" id="columnTemplate"> <div id="{{:EmployeeID}}barcode" class="barcode"></div> </script> <script type="text/javascript"> $(function () { $("#Grid").ejGrid({ // the datasource "window.employeeView" is referred from jsondata.min.js dataSource: window.employeeView, allowPaging: true, pageSettings: {pageSize: 4}, toolbarSettings: {showToolbar: true, toolbarItems: [ej.Grid.ToolBarItems.PrintGrid]}, columns: [ {headerText: "Barcode", templateID: "#columnTemplate", textAlign: "center", width: 170}, {field: "EmployeeID", headerText: "Employee ID", textAlign: ej.TextAlign.Right, width: 90}, {field: "FirstName", headerText: "First Name", width: 90}, {field: "LastName", headerText: "Last Name", width: 90}, {field: "BirthDate", headerText: "Birth Date", width: 90, format: "{0:MM/dd/yyyy}"}, {field: "Country", headerText: "Country", width: 80} ], dataBound: "databound", templateRefresh: "refresh", beforePrint: "beforeprint" }); }); </script> MVC @(Html.EJ().Grid<object>("Grid") .Datasource((IEnumerable<object>)ViewBag.DataSource) .AllowPaging() .PageSettings(p => { p.PageSize(4); }) .ToolbarSettings(toolbar =>{ toolbar.ShowToolbar().ToolbarItems(items => { items.AddTool(ToolBarItems.PrintGrid); }); }) .Columns(col =>{ col.HeaderText("Barcode").Template("#columnTemplate") .TextAlign(TextAlign.Center).Width(170).Add(); col.Field("EmployeeID").HeaderText("Employee ID").TextAlign(TextAlign.Right).Width(90).Add(); col.Field("FirstName").HeaderText("First Name").Width(90).Add(); col.Field("LastName").HeaderText("Last Name").Width(90).Add(); col.Field("BirthDate").HeaderText("Birth Date”).Width(90).Format("{0:MM/dd/yyyy}").Add(); col.Field("Country").HeaderText("Country”).Width(80).Add(); }) .ClientSideEvents(eve => { eve.DataBound("databound"); eve.TemplateRefresh("refresh"); eve.BeforePrint("beforeprint"); }) ) [Serverside code] namespace EJGrid.Controllers { public class HomeController: Controller { public ActionResult Index() { var DataSource = new NorthwindDataContext().EmployeeViews.ToList(); ViewBag.DataSource = DataSource; return View(); } } } ASP.NET [aspx] <ej:Grid ID="Grid" runat="server" AllowPaging="True"> <ToolbarSettings ShowToolbar="True" ToolbarItems="printGrid"> </ToolbarSettings> <PageSettings PageSize="4" /> <ClientSideEvents DataBound="databound" TemplateRefresh="refresh" BeforePrint="beforeprint"> </ClientSideEvents > <Columns> <ej:Column HeaderText="Barcode" Template="#columnTemplate" TextAlign="Center" Width="170" /> <ej:Column Field="EmployeeID" HeaderText="Employee ID" TextAlign="Right" Width="90"/> <ej:Column Field="FirstName" HeaderText="First Name" Width="90"/> <ej:Column Field="LastName" HeaderText="Last Name" Width="90"/> <ej:Column Field="BirthDate" HeaderText="Birth Date" Format="{0:MM/dd/yyyy}" Width="90"/> <ej:Column Field="Country" HeaderText="Country" Width="80"/> </Columns> </ej:Grid> [Serverside code] public partial class _Default: Page { protected void Page_Load(object sender, EventArgs e) { this.Grid.DataSource = new NorthwindDataContext().EmployeeViews.ToList(); this.Grid.DataBind(); } } ASP.NET CORE <ej-grid id="Grid" allow-paging="true" datasource="ViewBag.DataSource" databound="databound" template-refresh="refresh" before-print="beforeprint"> <e-toolbar-settings show-toolbar="true" toolbar-items='@new List<string> {"printGrid"}' /> <e-page-settings page-size="4"></e-page-settings> <e-columns> <e-column header-text="Barcode" template="#columnTemplate" width="170"></e-column> <e-column field="EmployeeID" header-text="Employee ID" text-align="Right" width="80"></e-column> <e-column field="FirstName" header-text="First Name" width="90"></e-column> <e-column field="LastName" header-text="Last Name" width="90"></e-column> <e-column field="BirthDate" header-text="Birth Date" format="{0:MM/dd/yyyy}" width="90"></e-column> <e-column field="County" header-text="Country" width="80"></e-column> </e-columns> </ej-grid> [Serverside code] public partial class GridController: Controller { public ActionResult GridFeatures() { var DataSource = new NorthwindDataContext().EmployeeViews.ToList(); ViewBag.DataSource = DataSource; return View(); } } Angular Define the template in the Index page. <script type="text/x-jsrender" id="columnTemplate"> <div id="{{:EmployeeID}}barcode" class="barcode"></div> </script> HTML File <ej-grid id="Grid" #grid [allowPaging]=true [dataSource]="gridData" (beforePrint)="onPrint($event)" (dataBound)="dataBound($event)" (templateRefresh)="refresh($event)" [pageSettings]="pageSettings" [toolbarSettings.showToolbar]="true" [toolbarSettings.toolbarItems]="tools" > <e-columns> <e-column headerText="Barcode" template="#columnTemplate" textAlign="center" width="170"></e-column> <e-column field="EmployeeID" headerText="Employee ID" width="90"></e-column> <e-column field="FirstName" headerText="First Name" width="90"></e-column> <e-column field="LastName" headerText="Last Name" width="90"></e-column> <e-column field="BirthDate" headerText="Birth Date" format="{0:MM/dd/yyyy}" width="90"></e-column> <e-column field="Country" headerText="Country" width="80"></e-column> </e-columns> </ej-grid> Ts File export class AppComponent { public gridData; public tools; public pageSettings; @ViewChild('grid') Grid: EJComponents<any, any>; constructor() { //The datasource "window.employeeView" is referred from 'http://js.syncfusion.com/demos/web/scripts/jsondata.min.js' this.gridData = window.employeeView; this.pageSettings = { pageSize: 4 }; this.tools = ["printGrid"]; } // convert the element to corresponding controls by using templateRefresh and databound event of grid. refresh(e:any){ var grid = $("#Grid").ejGrid("instance"); if(!grid.initialRender){ var text = e.data.EmployeeID; var val = text.toString(); $(e.cell).find(".barcode").ejBarcode({ text: val, symbologyType: "qrbarcode" }); } } dataBound(e){ var data = e.model.currentViewData; for (var j = 0; j < data.length; j++) { var text = data[j].EmployeeID; $(".barcode").eq(j).ejBarcode({ text: text.toString(), symbologyType: "qrbarcode" }); } } // convert this canvas element to image and then print the ejBarcode control. onPrint(e) { if (e.requestType == "print") { var img = new Image(); var len = e.element.find(".barcode").length; e.model.allowPaging = false; var grid = $("#" + this.Grid.widget._id).ejGrid("instance"); grid.refreshContent(); grid.getPager().css('display', 'none'); for (var i = 0; i < len; i++) { img = new Image(); img.src = $(".barcode").children("canvas")[i].toDataURL(); e.element.find(".barcode").eq(i).parent("td").append(img); } grid.model.allowPaging = true; grid.refreshContent(); grid.getPager().css('display', 'block'); } } } Using template property of grid columns, we can add ejBarcode control as one of the grid column. Create an element using jsRender and convert the element to corresponding control by using templateRefresh and dataBound event of the grid. <script type="text/javascript"> function refresh(args) { if (!this.initialRender) { var text = args.data.EmployeeID; $(args.cell).find(".barcode").ejBarcode({ text: text.toString(), symbologyType: "qrbarcode" }); } } function databound(args) { var data = this.model.currentViewData; for (var j = 0; j < data.length; j++) { var text = data[j].EmployeeID; this.element.find(".barcode").eq(j).ejBarcode({ text: text.toString(), symbologyType: "qrbarcode" }); } } </script> In beforePrint event, convert the canvas element to image and then print the ejBarcode control. <script type="text/javascript"> function beforeprint (args) { if (args.requestType == "print") { var img = new Image(); var len = args.element.find(".barcode").length; this.model.allowPaging = false; var grid = $("#" + this._id).ejGrid("instance"); grid.refreshContent(); grid.getPager().css('display', 'none'); for (var i = 0; i < len; i++) { img = new Image(); img.src = $(".barcode").children("canvas")[i].toDataURL(); args.element.find(".barcode").eq(i).parent("td").append(img); } grid.model.allowPaging = true; grid.refreshContent(); grid.getPager().css('display', 'block'); } } </script> Figure SEQ Figure \* ARABIC 1 Grid with barcode control Figure SEQ Figure \* ARABIC 2 To print barcode control Conclusion I hope you enjoyed learning about how to print the grid when barcode as one of the column in JS Grid.You can refer to our JavaScript Grid feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our JavaScript Grid example to understand how to create and manipulate data.For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!
How to choose right color combination to the Barcode? While customizing the barcode main thing to consider color combinations, which is important to choose right color combination to the barcode for recognizing with scanner. This article explains you about how to choose right color combination to the Barcode in Xamarin Android. Barcode color can be customized by the DarkBarBrush and LightBarBrush properties. It’s important to use light colors for the background and dark colors for the barcode. Right color combination Below are color combinations are scan-able. The best contrast is obtained when the background reflects all the light and the bars reflect none which can that can work for barcode labels. Dark and light color combination will always work with all type of Barcodes. Black on White Blue on White Green on White Black on Yellow Blue on Yellow Green on Yellow Black on Red Blue on Red Green on Red Wrong Color Combination If the background and bar colors, both are too light or too dark, the scanner won’t be able to read the barcode label. Below are color combinations are Non scan-able. Red on White Yellow on White Light Brown on White Black on Yellow Black on Green Black on Blue Red on Blue Green on Blue Brown on Blue
How to choose the right barcode for your application? Barcode supports different variants of symbologies in both One dimensional as well as in Two dimensional, which can be used in various applications. This article explains you about choosing the right barcode for your application. 1D Barcode: One dimensional Barcode is a linear Barcode, The bars and spaces signified for each symbol in one dimensional Barcodes are grouped in such a way to represent a specific ASCII character. Which has commonly used on consumer goods, use a series of variable-width lines and spaces to encode data. Linear barcodes hold just a few dozen characters, and generally get physically longer as more data is added. 2D Barcode: Two dimensional Barcode is a way to represent information by using two-dimensional approach. It is similar to one dimensional Barcode, but can represent more data per unit area. Two dimensional Barcode, like Data Matrix and QR Code, use patterns of squares, hexagons, dots, and other shapes to encode data. They can be much smaller while holding more data (hundreds of characters) than 1D codes. Data is encoded based on both the vertical and horizontal arrangement of the pattern, thus it is read in two dimensions. Below tabulation helps to narrow down the decision before choose the right barcode for your application 1D Barcode Type Allowed Characters Applications Codabar "0 1 2 3 4 5 6 7 8 9 - $ : / dot(.) +" Logistics and Healthcare professionals, including U.S. blood banks, FedEx, photo labs, and libraries Code11 "0 1 2 3 4 5 6 7 8 9 dash(-)" Telecommunications equipment’s Code32 "1 2 3 4 5 6 7 8 9 0\\n Text length should be 8!!!" Coding pharmaceuticals, cosmetics and dietetics Code39 "0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z dash(-) dot(.) $ / + % SPACE" Automotive Industry Defense Code39Extended "All 128 ASCII Characters" Code93 "0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z dash(-) dot(.) $ / + % SPACE" # Retail # Manufacturing and Logistics Code93Extended "All 128 ASCII Characters" Code128A "ASCII values from 0 to 95\\nNUL SOH STX ETX EOT ENQ ACK BEL BS HT LF VT FF CR SO SI DLE DC1 DC2 DC3 DC4 NAK SYN ETB CAN EM SUB ESC FS GS RS US SPACE ! \\ # $ % ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; = >? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \\\\ ]^ _" # Retail # Manufacturing and Logistics # Transportation industries for Ordering and distribution Code128B "ASCII values from 32 to 127\\nSPACE ! \\ # $ % ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; = >? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \\\\ ]^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~ DEL" Code128C "0 1 2 3 4 5 6 7 8 9" 2D Barcode Allowed Characters Applications QRCode All 128 ASCII Characters # Mobile Applications # Medical fields # Business cards # Print advertisement # Business stationary and invoices Data Matrix All 128 ASCII Characters # Manufacturing part tracking # Lotteries # ID Cards # Registrations # Postal Tracking
The QR barcode can be scaled by setting the XDimension property of the PdfQRBarcode class. The following code example is for scaling QR Code. C# //Loads the pdf PdfLoadedDocument pdfDoc = new PdfLoadedDocument("sample.pdf"); //create the barcode PdfQRBarcode qrCode = new PdfQRBarcode(); qrCode.Text = "Ac-42"; //Set dimension to scale the barcode qrCode.XDimension = 10; //Draw the Barcode qrCode.Draw(pdfDoc.Pages[0], new PointF(10, 10)); //Save the File pdfDoc.Save("Output.pdf"); pdfDoc.Close(); Sample Link: https://www.syncfusion.com/downloads/support/directtrac/general/QRCode911548536.zip