C# Barcode Generator Library
How to generate linear, 2d barcodes in PDF, Tiff, Word, image files in C# ASP.NET, MVC, Windows applications


To Have a Quick Evaluation of XImage.Barcode Generator in Visual C# Console Application









As a leading professional third-party SDK supplier in the field of image and document management, RasterEdge has always been devoted to providing various effective and fully-functional barcode imaging solutions for developers who are working on different .NET developing applications.



This C#.NET barcode generation toolkit, RasterEdge XImage.Barcode Generator SDK for .NET is one of the most strongly-featured and mature document imaging library toolkits on the market, which is designed to help developers implement barcode-related tasks in their C#.NET applications.

Using this C#.NET barcode generation control, you can easily and quickly complete both 1d and 2d barcode creating on raster and vector images, tiff files, PDF documents, Word documents, Excel files and PPT files in any type of a 32-bit or 64-bit .NET application, including ASP.NET Core MVC web app, ASP.NET web service and Windows Forms for any .NET Framework version from 2.0 to 4.5.

As you know, there're various reliable barcode generation features that can be implemented in C#.NET programming. And you may want to have a quick testing on RasterEdge XImage.Barcode Generator after downloading its free trial package online. To meet your requirement, on this quick to start page, we will tell how to create a C# console application, and create QR Code on PDF in C#.NET.







How to create QR Code barcode in PDF file with web link added using C#.NET


The following content and C# sample source code to show how to create QR Code barcode in an existing PDF file, and create, insert a web link on the QR Code in the PDF document using C#.NET

  1. Create a new QRCode object
  2. Set QR Code encoding data "https://www.rasteredge.com".
  3. Set QR Code barcode size options
  4. Create a new PDFDocument from an existing PDF file
  5. Get a new PDFPage object from the first page of the PDF document
  6. Generate and print QR Code on the PDFPage object
  7. Create a new PDFLinkAction object to add a web link to PDF page
  8. Set the web link position and area which is the same position and area as QR Code
  9. Add, insert the web link object to the PDF page
  10. Save the PDF file


Note: web link covered area width and height calculation is based on PDF document default resolution (96 dpi). Two inch is 192 dpi.



            RasterEdge.XImage.BarcodeCreator.QRCode qrcode = new RasterEdge.XImage.BarcodeCreator.QRCode();

            qrcode.Data = "https://www.rasteredge.com";
            qrcode.DataMode = RasterEdge.XImage.BarcodeCreator.QRCodeDataMode.Auto;

            //  Set barcode size to 2 inch x 2 inch
            qrcode.AutoResize = true;
            qrcode.UOM = RasterEdge.XImage.BarcodeCreator.UnitOfMeasure.INCH;
            qrcode.BarcodeWidth = 2F;
            qrcode.BarcodeHeight = 2F;
            //  Set image resolution to 300 dpi.
            qrcode.Resolution = 300;

            //  Set all margins to 0
            qrcode.LeftMargin = 0;
            qrcode.RightMargin = 0;
            qrcode.TopMargin = 0;
            qrcode.BottomMargin = 0;

            String inputFilePath = @"W:\Projects\Test-Files\XDoc.PDF Overview.pdf";
            String outputFilePath = @"W:\Projects\Test-Output\RasterEdge.com\barcode-qrcode-pdf.pdf";

            PDFDocument doc = new PDFDocument(inputFilePath);
            //  Draw the barcode at position (300, 360) in pixels on the 1st page.
            PDFPage page = (PDFPage)doc.GetPage(0);
            qrcode.DrawBarcode(page, 300, 360);


            //  Create and add a link to the same area of the QRCode
            PDFLinkAction action = PDFLinkActionURI.Create("https://www.rasteredge.com");
            //  Position (300, 360) in pixels; Width and height: 2 inch (192 pixels).
            RectangleF area = new RectangleF(300, 360, 192, 192);
            PDFLinkSetting link = new PDFLinkSetting(area, action);
            //  Add the link to the 1st page.
            PDFLinkHandler.AddLink(doc, 0, link);

            doc.Save(outputFilePath);






How to generate QR Code barcode in TIFF file using C#.NET


The following C# source code explains how to create QR Code barcode in an existing Tiff file using C#.NET



            RasterEdge.XImage.BarcodeCreator.QRCode qrcode = new RasterEdge.XImage.BarcodeCreator.QRCode();

            qrcode.Data = "https://www.rasteredge.com";

            //  Set barcode size to 2 inch x 2 inch
            qrcode.AutoResize = true;
            qrcode.UOM = RasterEdge.XImage.BarcodeCreator.UnitOfMeasure.INCH;
            qrcode.BarcodeWidth = 2F;
            qrcode.BarcodeHeight = 2F;
            //  Set image resolution to 300 dpi.
            qrcode.Resolution = 300;

            //  Set all margins to 0
            qrcode.LeftMargin = 0;
            qrcode.RightMargin = 0;
            qrcode.TopMargin = 0;
            qrcode.BottomMargin = 0;

            String inputFilePath = @"W:\Projects\Test-Files\XDoc.PDF Overview.tiff";
            String outputFilePath = @"W:\Projects\Test-Output\RasterEdge.com\barcode-qrcode-tiff.tiff";

            TIFFDocument tiffDoc = new TIFFDocument(inputFilePath);

            //  Draw the barcode at position (100, 200) in pixels on the 1st page.
            BasePage page = tiffDoc.GetPage(0);
            qrcode.DrawBarcode(page, 100, 200);

            tiffDoc.Save(outputFilePath);






How to generate QR Code barcode in Office Word, Excel, PowerPoint files using C#.NET


The following C# source code explains how to generate, insert QR Code barcode in a Word (.docx) file using C#.NET



            RasterEdge.XImage.BarcodeCreator.QRCode qrcode = new RasterEdge.XImage.BarcodeCreator.QRCode();

            qrcode.Data = "https://www.rasteredge.com";

            //  Set barcode size to 1 inch x 1 inch
            qrcode.AutoResize = true;
            qrcode.UOM = RasterEdge.XImage.BarcodeCreator.UnitOfMeasure.INCH;
            qrcode.BarcodeWidth = 1F;
            qrcode.BarcodeHeight = 1F;
            //  Set image resolution to 300 dpi.
            qrcode.Resolution = 300;

            //  Set all margins to 0
            qrcode.LeftMargin = 0;
            qrcode.RightMargin = 0;
            qrcode.TopMargin = 0;
            qrcode.BottomMargin = 0;

            String inputFilePath = @"W:\Projects\Test-Files\word-empty.docx";
            String outputFilePath = @"W:\Projects\Test-Output\RasterEdge.com\barcode-qrcode-word.docx";

            DOCXDocument doc = new DOCXDocument(inputFilePath);

            //  Draw the barcode at position (100, 200) in pixels on the 1st page.
            BasePage page = doc.GetPage(0);

            REImage image = new REImage(qrcode.ToImage());
            page.AddImage(image, new PointF(100F, 200F));

            doc.Save(outputFilePath);






How to draw, print QR Code barcode in JPG, PNG, Bitmap images using C#.NET


The C# sample code below shows how to generate, draw QR Code barcode in an image file (JPG, PNG, or BMP) using C#.NET



            RasterEdge.XImage.BarcodeCreator.QRCode qrcode = new RasterEdge.XImage.BarcodeCreator.QRCode();

            qrcode.Data = "https://www.rasteredge.com";

            //  Set barcode size to 2 inch x 2 inch
            qrcode.AutoResize = true;
            qrcode.UOM = RasterEdge.XImage.BarcodeCreator.UnitOfMeasure.INCH;
            qrcode.BarcodeWidth = 2F;
            qrcode.BarcodeHeight = 2F;
            //  Set image resolution to 300 dpi.
            qrcode.Resolution = 300;

            //  Set all margins to 0
            qrcode.LeftMargin = 0;
            qrcode.RightMargin = 0;
            qrcode.TopMargin = 0;
            qrcode.BottomMargin = 0;

            Bitmap qrcodeBitmap = qrcode.ToImage();
            qrcodeBitmap.Save(@"W:\Projects\Test-Output\RasterEdge.com\barcode-qrcode.png");