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

C# Imaging - Planet Barcode Generation Guide


C# Code to Generate PLANET Barcode on Documents & Images




C# Imaging - PLANET Barcode Generator Library Overview



RasterEdge barcode generating control library for C#, which belongs to .NET Imaging SDK, is designed for C#.NET developers to create high-quality linear and 2d barcode images in .NET projects. More than 20 barcode types are supported including PLANET barcode.


Related .net document control helps:
asp.net pdf viewer: ASP.NET PDF Viewer Control: view, navigate, zoom Adobe PDF document in C# ASP.NET
asp.net excel document viewer: ASP.NET Excel Document Viewer in C# Control: view office excel files online in ASP.NET web applications
asp.net iis document viewer: C# HTML5 Viewer: Deployment on IIS
asp.net sharepoint pdf editor: ASP.NET SharePoint PDF Editor Control: view, edit, annotate, redact PDF document in SharePoint sites
asp.net tiff document viewer: ASP.NET Tiff Document Viewer: view, annotate Tiff files in HTML using C# Control
asp.net webforms document viewer: ASP.NET WebForms application document viewer control: view, annotate, redact, convert files online in ASP.NET
asp.net text document viewer: C# HTML5 Viewer: Load, View, Convert, Annotate and Edit OpenOffice, CSV and Text file


The Postal Alpha Numeric Encoding Technique, i.e. PLANET barcode, is a linear bar code symbology used by United State Postal Service for mail identification and tracking. It can encode numeric data only with a length of 12 or 14 digits, including a mandatory checksum. Using RasterEdge .NET barcode writing control, users can easily create and draw PLANET with C# codings.


Detailed features are listed below:


Draw, paint PLANET bar codes on images of jpeg/jpg, png, gif, and bmp formats


Creating single or bulk PLANET bar codes on documents such as PDF, Office Word, Excel, PowerPoint and multi-page TIFF


Empower users to define the location of barcode on files by setting coordinates


Resize PLANET barcode and control other barcoding parameters in C#


Compatible with Microsoft Visual Studio 2005 and above, as well as .NET Framework 2.0 or later


Output readable PLANET images for almost all printers and scanners




C# Code for Customizing PLANET Barcode Generation



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




private static Linear CreateBarcode()
        {
            Linear barcode = new Linear();// create a barcode
            barcode.Type = BarcodeType.PLANET;// select barcode type
            barcode.Data = "01234567890";// set barcode data
            barcode.X = 1.0F;// set x
            barcode.Y = 60.0F;// set y
            barcode.Resolution = 96;// set resolution
            barcode.Rotate = Rotate.Rotate0;// set rotation
            barcode.BarcodeWidth = 200;
            barcode.BarcodeHeight = 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# to Create PLANET Barcode on Png, Jpeg, Gif and Bmp



.NET developers can use this barcode add-on component to create PLANET linear barcodes in C# projects. All the major raster image formats are supported for barcode generating, such as png, jpg, gif, and bmp. Users can create a single barcode or a number of bar codes on image file, and at the same time, you can freely define the exact area on the image where you want to put PLANET barcode. Demonstrated below is an example to write a PLANET postal bar code on a png image and save the image file to your local disk C.




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





Create PLANET on PDF, TIFF, Word, Excel and PowerPoint



Apart from printing PLANET 1D bar code on an image, users can also opt to generate PLANET barcode onto a single page within a document file, including PDF, Microsoft Office Word, (multi-page) TIFF, Excel and PowerPoint. You can control the accurate barcode location on the page by setting x and y coordinates using Visual C# programming language.



Generating PLANET Barcode on PDF



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




Creating PLANET Barcode on (Multi-page) TIFF



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




Drawing PLANET Barcode on Microsoft Word



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




Generating PLANET Barcode on 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(Linear 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");
        }




Writing PLANET Barcode on PowerPoint



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





C# Imaging - Entire C# Code to Generate PLANET Barcode



Here is the sample code for creating and customizing PLANET barcode with parameters listed above. Please feel free to make any modification according to your C# imaging program requirements.




// create REImage on which you want to draw the barcode
REImage reImage = new REImage("c:/Sample.png");

Linear barcode = new Linear();// create a barcode
barcode.Type = BarcodeType.PLANET;// select barcode type
barcode.Data = "01234567890";// set barcode data 

// PLANET size settings
barcode.UOM = RasterEdge.Imaging.Barcode.Creator.UnitOfMeasure.PIXEL;
barcode.X = 2.0F;
barcode.Y = 80F;
barcode.BarcodeHeight = 120;
barcode.BarcodeWidth = 120;
barcode.BottomMargin = 20;
barcode.TopMargin = 20;
barcode.BottomMargin = 20;
barcode.LeftMargin = 20;
barcode.RightMargin = 20;
barcode.AutoResize = false;
barcode.BarAlignment = AlignmentHori.Center;

// PLANET unique settings
barcode.ShortTallRatio = 0.4F;

// color related settings
barcode.BackColor = System.Drawing.Color.White;
barcode.ForeColor = System.Drawing.Color.Black;

// human-readable text related settings
barcode.ShowText = true;
barcode.TextFont = new Font("Arial", 9f, FontStyle.Regular);
barcode.TextMargin = 6F;
barcode.TextColor = System.Drawing.Color.Black;

// other related settings
barcode.Resolution = 96;
barcode.Rotate = Rotate.Rotate0;

barcode.DrawBarcode(reImage, 0, 0);// draw barcode on REImage with location x and y

reImage.Save(ImageType.PNG, @"c:/barcode.png");