C# PDF-417 Barcode Generator Library
C# PDF 417 Barcode Writing Guide


Tutorial for PDF-417 Barcode Generator for C#.NET Imaging Application





C# PDF417 Generator Add-On Overview



This PDF 417 bar code generator for Visual C# is actually a composing functionality of RasterEdge DocImage SDK for .NET. It is a fully-featured barcode add-on library DLL written in C#.NET for developers to quickly add PDF-417 barcodes on image formats including PNG, JPG, GIF, BMP, as well as other file formats such TIFF, PDF, Microsoft Office Word, Excel and PowerPoint.


Related .net document control helps:
asp.net image viewer: ASP.NET Image Viewer Control(MVC & WebForms): view, annotate, redact, convert image files in html, JQuery
asp.net mvc document viewer: ASP.NET MVC Document Viewer: view, annotate, redact files on ASP.NET MVC web projects
asp.net document viewer: EdgeDoc:ASP.NET Document Viewer C# Control: Open, view, annotate, redact, convert documents online in C#, VB.NET, AS...
asp.net excel viewer: ASP.NET Excel Viewer in C# Control (MVC & WebForms): view Office Excel document in web browser.
asp.net pdf editor: EdgePDF: ASP.NET PDF Editor Web Control: Online view, annotate, redact, edit, process, convert PDF documents
asp.net pdf viewer: ASP.NET PDF Viewer Control: view, navigate, zoom Adobe PDF document in C# ASP.NET
asp.net powerpoint viewer: ASP.NET PowerPoint Document Viewer Control (MVC & WebForms): view ppt, pptx files online in C# using ASP.NET


Detailed features are listed below:


Create two-dimensional PDF-417 barcodes in .NET Windows Forms projects


Streaming PDF-417 2D bar code images in ASP.NET web form/web site


Write & draw PDF-417 on various raster image formats and .pdf, .docx, .xlsx, .pptx files using C# language


Provide detailed tutorial for PDF-417 generation with Visual C# sample codes


Support creating C# PDF-417, Macro PDF 417, PDF 417 Truncated (Composite PDF 417)




C# Code for Customizing PDF417 Barcode Generation



You can easily generator PDF417 barcode and save it  to image files/object using this C#.NET barcode generator control. The following steps will show how to create a PDF417 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 PDF417 barcode.




private static PDF417 CreateBarcode()
        {
            PDF417 barcode = new PDF417();// create a Data Matrix barcode
            barcode.Data = "123456789";// encode data into Data Matrix barcode    
            barcode.X = 5.0F;// set module size
            barcode.RightMargin = barcode.LeftMargin = barcode.TopMargin = barcode.BottomMargin = barcode.X; // the minimum value for each margin should be equal to 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;
        }





How to Create C# PDF 417 Barcode on Image



In order to create a PDF 417 bar code on images, you need to integrate .NET barcode generator component DLL into your C#.NET imaging project first. Below is the C# sample coding to draw PDF-417 at user-defined area on a png image. Please feel free to change the barcode location as you wish or shift image format to gif, jpeg or bmp.





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





How to Insert C# PDF 417 Barcode on Document



Apart from generating & printing PDF-417 barcode in image editing project, this C#.NET PDF-417 generator library can also help you insert PDF-417 barcode into a PDF, TIFF, Word, Excel or PowerPoint document. View detailed Visual C# samples below.



Generate PDF 417 Barcode on PDF Using C# Code



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(PDF417 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");
        }




Insert PDF 417 Barcode on TIFF with C# Code



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(PDF417 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");
        }




Create PDF 417 Barcode on Word in C# Code



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(PDF417 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 PDF 417 Barcode Image on Excel in C#



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(PDF417 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");
        }




Write PDF 417 Barcode Image on PowerPoint in C#



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(PDF417 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");
        }