PDF .NET Library Logo

How to draw Linear Barcodes

The following code snippet draws a linear barcode on a PDF page.

C# sample:

PDFDocument doc = new PDFDocument("barcode.pdf");

PDFTech.Barcodes.Barcode1D.Code_128 code128 = new PDFTech.Barcodes.Barcode1D.Code_128("1234567890", UnitOfMeasure.Pixel);

code128.CharSet = PDFTech.Barcodes.Code128.Auto;

if (code128.IsCodeValid())

{

      doc.CurrentPage.Body.Add1DBarcode(code128,130, 100);

}

if(!doc.Save())

      Console.WriteLine(doc.Error);

Back to PDF Code Library