C#: Online Guide
How To: Barcode Generator
QR Code
QR Code
  |  
Home ›› XImage.Barcode Generator ›› C# Barcode Generator: QR Code

C# Imaging - QR Code Image Generation Tutorial


Create QR Code Barcode on C# Images, TIFF, PDF, Word, Excel and PowerPoint




C# Imaging - QR Code Barcode Add-on Overview



By using this .NET QR Code barcode generator add-on component, developers can create & draw scannable QR Codes on different image files (png, jpeg, gif and bmp) and insert them into common documents like TIFF, PDF, MS Word, Excel and PowerPoint using Visual C#.NET programming code. Following are some barcoding features offered by this .NET QR Code encoder DLL.


Detailed features are listed below:


Written in C# managed code, compatible with .NET Framework 2.0 and above


Generating, writing QR Code bar codes on PNG, JPG, GIF, and BMP image files with specified location


C# tutorial and sample codes to draw, insert QR Codes in PDF, TIFF, MS Word, Excel and PowerPoint


Control QR Code barcode size by setting size related properties


Use C# code to adjust bar code image format, location, resolution, orientation, version, color and more


Compatible with ISO+IEC+18004 QR Code bar code symbology specification




C# Code for Customizing QR Code Barcode Generation



You can easily generator QR Code barcode and save it  to image files/object using this C#.NET barcode generator control. The following steps will show how to create a QR Code type barcode encoding numeric data text "123456789" into the image object with XImage.Barcode.Creator.


Add References


  RasterEdge.Imaging.Basic.dll


  RasterEdge.Imaging.Drawing.dll


  RasterEdge.Imaging.Font.dll


  RasterEdge.Imaging.Processing.dll


  RasterEdge.XImage.BarcodeCreator.dll


Using Namespaces


  using RasterEdge.XImage.BarcodeCreator;


Please copy the sample code as follow to generator a QR Code barcode.




private static QRCode CreateBarcode()
        {
            QRCode barcode = new QRCode();// create a Data Matrix barcode
            barcode.Data = "123456789";// encode data into Data Matrix barcode    
            barcode.X = 5.0F;// set module size
            // the minimum value for each margin should be equal to X
            barcode.RightMargin = barcode.LeftMargin = barcode.TopMargin = barcode.BottomMargin = barcode.X;
            barcode.Resolution = 96;// set barcode printing resolution   
            barcode.Rotate = Rotate.Rotate0;// set rotation
            barcode.BarcodeHeight = 200;
            barcode.BarcodeWidth = 200;
            barcode.AutoResize = true;

            return barcode;
        }





C# Imaging - Draw QR Code on Image File



This C# QR Code barcode generator add-on supports drawing QR Code two-dimensional bar code at any specified location on a target image file. The supported image formats include png, gif, jpeg and bmp. Copy Visual C# sample code below to your .NET imaging application to create and insert a QR Code bar code on a sample png image.




private static void AddBarcodeToImage(QRCode barcode)
        {
            REImage image = new REImage(inputDirectory + "Sample.png");
            barcode.DrawBarcode(image, 150F, 150F);
            image.Save(ImageType.PNG, outputDirectory + "Sample_Barcode.png");
        }





C# Imaging - Create QR Code on Document Page



Apart from generating QR Code on image files, C#.NET barcode creator plug-in of RasterEdge DocImage SDK for .NET can also create QR Code in common document files, like TIFF, PDF, Word, Excel and PowerPoint. Using this C#.NET barcode creating control, you can also customize the location of generated QR Code barcode on target document file.



Generate QR Code on C# PDF Page



Add References(Extra)


  RasterEdge.Imaging.Basic.Codec.dll


  RasterEdge.XImage.Raster.dll


  RasterEdge.XImage.Raster.Core.dll


  RasterEdge.XDoc.PDF.dll


Using Namespace(Extra)


  RasterEdge.XDoc.PDF;


  RasterEdge.Imaging.Basic;


  RasterEdge.Imaging.Raster.Core;



private static void AddBarcodeToPDF(QRCode barcode)
        {
            PDFDocument docx = new PDFDocument(inputDirectory + "Sample.pdf");
            BasePage page = docx.GetPage(0);
            REImage image = new REImage(barcode.ToImage());
            page.AddImage(image, new PointF(100F, 100F));
            docx.Save(outputDirectory + "Sample_Barcode.pdf");
        }




Create QR Code on C# TIFF File



Add References(Extra)


  RasterEdge.Imaging.Basic.Codec.dll


  RasterEdge.XImage.Raster.dll


  RasterEdge.XImage.Raster.Core.dll


  RasterEdge.XDoc.TIFF.dll


Using Namespace(Extra)


  RasterEdge.XDoc.TIFF;


  RasterEdge.Imaging.Basic;


  RasterEdge.Imaging.Raster.Core;




private static void AddBarcodeToTIFF(QRCode barcode)
        {
            TIFFDocument docx = new TIFFDocument(inputDirectory + "Sample.tif");
            BasePage page = docx.GetPage(0);
            REImage image = new REImage(barcode.ToImage());
            page.AddImage(image, new PointF(100F, 100F));
            docx.Save(outputDirectory + "Sample_Barcode.tif");
        }




Draw QR Code on C# Word Document



Add References(Extra)


  RasterEdge.XDoc.Word.dll


  RasterEdge.XImage.Raster.dll


  RasterEdge.XImage.Raster.Core.dll


  RasterEdge.XDoc.Office.Inner.Common.dll


  RasterEdge.XDoc.Office.Inner..Office03.dll


Using Namespace(Extra)


  RasterEdge.XDoc.Word;


  RasterEdge.Imaging.Basic;


  RasterEdge.Imaging.Raster.Core;




private static void AddBarcodeToWord(QRCode barcode)
        {
            DOCXDocument docx = new DOCXDocument(inputDirectory + "Sample.docx");
            BasePage page = docx.GetPage(0);
            REImage image = new REImage(barcode.ToImage());
            page.AddImage(image, new PointF(100F, 100F));
            docx.Save(outputDirectory + "Sample_Barcode.docx");
        }




Generate QR Code on C# Excel Sheet



Add References(Extra)


  RasterEdge.XDoc.Excel.dll


  RasterEdge.XImage.Raster.dll


  RasterEdge.XImage.Raster.Core.dll


  RasterEdge.XDoc.Office.Inner.Common.dll


  RasterEdge.XDoc.Office.Inner..Office03.dll


Using Namespace(Extra)


  RasterEdge.XDoc.Excel;


  RasterEdge.Imaging.Basic;


  RasterEdge.Imaging.Raster.Core;




private static void AddBarcodeToExcel(QRCode barcode)
        {
            XLSXDocument docx = new XLSXDocument(inputDirectory + "Sample.xlsx");
            BasePage page = docx.GetPage(0);
            REImage image = new REImage(barcode.ToImage());
            page.AddImage(image, new PointF(100F, 100F));
            docx.Save(outputDirectory + "Sample_Barcode.xlsx");
        }




Draw QR Code Barcode on C# PowerPoint Slide



Add References(Extra)


  RasterEdge.XDoc.PowerPoint.dll


  RasterEdge.XImage.Raster.dll


  RasterEdge.XImage.Raster.Core.dll


  RasterEdge.XDoc.Office.Inner.Common.dll


  RasterEdge.XDoc.Office.Inner..Office03.dll


Using Namespace(Extra)


  RasterEdge.XDoc.PowerPoint;


  RasterEdge.Imaging.Basic;


  RasterEdge.Imaging.Raster.Core;




private static void AddBarcodeToPowerPoint(QRCode barcode)
        {
            PPTXDocument docx = new PPTXDocument(inputDirectory + "Sample.pptx");
            BasePage page = docx.GetPage(0);
            REImage image = new REImage(barcode.ToImage());
            page.AddImage(image, new PointF(100F, 100F));
            docx.Save(outputDirectory + "Sample_Barcode.pptx");
        }