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.
Related .net document control helps:
asp.net mvc document viewer: ASP.NET MVC Document Viewer: view, annotate, redact files on ASP.NET MVC web projects
asp.net pdf page:
ASP.NET PDF Pages Edit Control: add, remove, sort, replace PDF pages online using C#
asp.net edit pdf text:
ASP.NET PDF Text Edit Control: online edit PDF text content using C# ASP.NET
asp.net edit pdf image:
ASP.NET PDF Image Edit Control: online insert, edit PDF images in C#
asp.net document viewer c#: ASP.NET Document Viewer using C#: Open, View, Annotate, Redact, Convert document files in ASP.NET using C#, HTML5, JQuer...
asp.net dicom viewer: ASP.NET Dicom Document Viewer Control: view, annotate dicom imaging files online in ASP.NET
asp.net excel web viewer: ASP.NET Excel Viewer in C# Control (MVC & WebForms): view Office Excel document in web browser.
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
System.Drawing.dll
Using Namespaces
using System.Drawing;
using RasterEdge.XImage.BarcodeCreator;
Note: When you get the error "Could not load file or assembly 'RasterEdge.Imaging.Basic' or any other assembly or one of its dependencies. An attempt to load a program with an incorrect format", please check your configure as follows:
If you are using x64 libraries/dlls, Right click the project -> Properties -> Build -> Platform target: x64.
If using x86, the platform target should be x86.
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;
//convert barcode to a bitmap and save it to image file
//Bitmap bmp = barcode.ToImage();
//bmp.Save(@"C:\barcode.bmp");
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");
}
|