LEADTOOLS Barcode (Leadtools.Barcode assembly) Send comments on this topic. | Back to Introduction - All Topics | Help Version 17.0.3.29
BarcodeWritePdf Class
See Also  Members  
Leadtools.Barcode Namespace : BarcodeWritePdf Class



The BarcodeWritePdf Class includes members that are available as an add-on to the LEADTOOLS Imaging Pro, Document, and Medical Imaging toolkits.

This class contains information for writing PDF417/MicroPDF417 barcodes.

Object Model

BarcodeWritePdf Class

Syntax

Visual Basic (Declaration) 
Public Class BarcodeWritePdf 
Visual Basic (Usage)Copy Code
Dim instance As BarcodeWritePdf
C# 
public class BarcodeWritePdf 
C++/CLI 
public ref class BarcodeWritePdf 

Example

Visual BasicCopy Code
Public Sub BarcodeWritePdfExample()
      ' Load an image
      Dim codecs As RasterCodecs = New RasterCodecs()
      codecs.ThrowExceptionsOnInvalidImages = True

      Dim image As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "barcode1.tif"))

      Dim barEngine As BarcodeEngine
      Try
         ' Unlock barcode support.
         ' Note that this is a sample key, which will not work in your toolkit
         RasterSupport.Unlock(RasterSupportType.Barcodes1D, "TestKey")

         ' Initialize barcodes
         barEngine = New BarcodeEngine()

         Dim data As BarcodeData = New BarcodeData()
         Dim rc As LeadRect = New LeadRect(100, 100, 0, 0)
         data.Unit = BarcodeUnit.ScanlinesPerPixels
         data.Location = rc
         data.SearchType = BarcodeSearchTypeFlags.Pdf417

         Dim barcodeText As String()
         barcodeText = New String(0) {}
         barcodeText(0) = "PDF417 Symbol"
         data.Data = BarcodeData.ConvertFromStringArray(barcodeText)

         Dim barColor As BarcodeColor = New BarcodeColor()
         barColor.BarColor = RasterColor.FromKnownColor(RasterKnownColor.Black)
         barColor.SpaceColor = RasterColor.FromKnownColor(RasterKnownColor.White)

         Dim bar1d As Barcode1d = New Barcode1d()
         Dim barPDF As BarcodeWritePdf = New BarcodeWritePdf()
         Dim barDM As BarcodeWriteDatamatrix = New BarcodeWriteDatamatrix()
         Dim barQR As BarcodeWriteQr = New BarcodeWriteQr()

         barPDF.AspectHeight = 0
         barPDF.AspectWidth = 0
         barPDF.Columns = 0
         barPDF.Rows = 0
         barPDF.EccLevel = BarcodePdf417EccLevelFlags.UsePercent
         barPDF.EccPercentage = 50
         barPDF.Justify = BarcodeJustifyFlags.Right
         barPDF.Module = 21
         barPDF.ModAspectRatio = 4

         barEngine.Write(image, data, barColor, BarcodeWriteFlags.Truncate, bar1d, barPDF, barDM, barQR, LeadRect.Empty)
      Catch ex As BarcodeException
         Console.WriteLine(ex.Message)
      End Try

   End Sub

Public NotInheritable Class LEAD_VARS
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
C#Copy Code
public void BarcodeWritePdfExample()
   {
      // Load an image
      RasterCodecs codecs = new RasterCodecs();
      codecs.ThrowExceptionsOnInvalidImages = true;
      string fileName = Path.Combine(LEAD_VARS.ImagesDir, "barcode1.tif");
      RasterImage image = codecs.Load(fileName);

      BarcodeEngine barEngine;
      try
      {
         // Unlock barcode support.
         // Note that this is a sample key, which will not work in your toolkit
         RasterSupport.Unlock(RasterSupportType.Barcodes1D, "TestKey");

         // Initialize barcodes
         barEngine = new BarcodeEngine();

         BarcodeData data = new BarcodeData();
         data.Unit = BarcodeUnit.ScanlinesPerPixels;
         LeadRect rc = new LeadRect(100, 100, 0, 0);
         data.Location = rc;

         data.SearchType = BarcodeSearchTypeFlags.Pdf417;
         string[] barcodeText;
         barcodeText = new string[1];
         barcodeText[0] = "PDF417 Symbol";
         data.Data = BarcodeData.ConvertFromStringArray(barcodeText);

         BarcodeColor barColor = new BarcodeColor();
         barColor.BarColor = RasterColor.FromKnownColor(RasterKnownColor.Black);
         barColor.SpaceColor = RasterColor.FromKnownColor(RasterKnownColor.White);

         Barcode1d bar1d = new Barcode1d();
         BarcodeWritePdf barPDF = new BarcodeWritePdf();
         BarcodeWriteDatamatrix barDM = new BarcodeWriteDatamatrix();
         BarcodeWriteQr barQR = new BarcodeWriteQr();

         barPDF.AspectHeight = 0;
         barPDF.AspectWidth = 0;
         barPDF.Columns = 0;
         barPDF.Rows = 0;
         barPDF.EccLevel = BarcodePdf417EccLevelFlags.UsePercent;
         barPDF.EccPercentage = 50;
         barPDF.Justify = BarcodeJustifyFlags.Right;
         barPDF.Module = 21;
         barPDF.ModAspectRatio = 4;

         barEngine.Write(image, data, barColor, BarcodeWriteFlags.Truncate, bar1d, barPDF, barDM, barQR, LeadRect.Empty);
      }
      catch (BarcodeException ex)
      {
         Console.WriteLine(ex.Message);
      }

   }

static class LEAD_VARS
{
   public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
SilverlightCSharpCopy Code
public void BarcodeWritePdfExample(RasterImage image)
{
   BarcodeEngine barEngine;
   try
   {
      // Unlock barcode support.
      // Note that this is a sample key, which will not work in your toolkit
      RasterSupport.Unlock(RasterSupportType.Barcodes1D, "TestKey");
      // Initialize barcodes
      barEngine = new BarcodeEngine();

      BarcodeData data = new BarcodeData();
      data.Unit = BarcodeUnit.ScanlinesPerPixels;
      LeadRect rc = new LeadRect(100, 100, 0, 0);
      data.Location = rc;

      data.SearchType = BarcodeSearchTypeFlags.Pdf417;
      string[] barcodeText;
      barcodeText = new string[1];
      barcodeText[0] = "PDF417 Symbol";
      data.Data = BarcodeData.ConvertFromStringArray(barcodeText);

      BarcodeColor barColor = new BarcodeColor();
      barColor.BarColor = RasterColor.FromKnownColor(RasterKnownColor.Black);
      barColor.SpaceColor = RasterColor.FromKnownColor(RasterKnownColor.White);

      Barcode1d bar1d = new Barcode1d();
      BarcodeWritePdf barPDF = new BarcodeWritePdf();
      BarcodeWriteDatamatrix barDM = new BarcodeWriteDatamatrix();
      BarcodeWriteQr barQR = new BarcodeWriteQr();

      barPDF.AspectHeight = 0;
      barPDF.AspectWidth = 0;
      barPDF.Columns = 0;
      barPDF.Rows = 0;
      barPDF.EccLevel = BarcodePdf417EccLevelFlags.UsePercent;
      barPDF.EccPercentage = 50;
      barPDF.Justify = BarcodeJustifyFlags.Right;
      barPDF.Module = 21;
      barPDF.ModAspectRatio = 4;

      barEngine.Write(image, data, barColor, BarcodeWriteFlags.Truncate, bar1d, barPDF, barDM, barQR, LeadRect.Empty);
   }
   catch (BarcodeException ex)
   {
      Console.WriteLine(ex.Message);
   }

}
SilverlightVBCopy Code
Public Sub BarcodeWritePdfExample(ByVal image As RasterImage)
  Dim barEngine As BarcodeEngine
  Try
    ' Unlock barcode support.
    ' Note that this is a sample key, which will not work in your toolkit
    RasterSupport.Unlock(RasterSupportType.Barcodes1D, "TestKey")
    ' Initialize barcodes
    barEngine = New BarcodeEngine()

    Dim data As BarcodeData = New BarcodeData()
    data.Unit = BarcodeUnit.ScanlinesPerPixels
    Dim rc As LeadRect = New LeadRect(100, 100, 0, 0)
    data.Location = rc

    data.SearchType = BarcodeSearchTypeFlags.Pdf417
    Dim barcodeText As String()
    barcodeText = New String(0){}
    barcodeText(0) = "PDF417 Symbol"
    data.Data = BarcodeData.ConvertFromStringArray(barcodeText)

    Dim barColor As BarcodeColor = New BarcodeColor()
    barColor.BarColor = RasterColor.FromKnownColor(RasterKnownColor.Black)
    barColor.SpaceColor = RasterColor.FromKnownColor(RasterKnownColor.White)

    Dim bar1d As Barcode1d = New Barcode1d()
    Dim barPDF As BarcodeWritePdf = New BarcodeWritePdf()
    Dim barDM As BarcodeWriteDatamatrix = New BarcodeWriteDatamatrix()
    Dim barQR As BarcodeWriteQr = New BarcodeWriteQr()

    barPDF.AspectHeight = 0
    barPDF.AspectWidth = 0
    barPDF.Columns = 0
    barPDF.Rows = 0
    barPDF.EccLevel = BarcodePdf417EccLevelFlags.UsePercent
    barPDF.EccPercentage = 50
    barPDF.Justify = BarcodeJustifyFlags.Right
    barPDF.Module = 21
    barPDF.ModAspectRatio = 4

    barEngine.Write(image, data, barColor, BarcodeWriteFlags.Truncate, bar1d, barPDF, barDM, barQR, LeadRect.Empty)
  Catch ex As BarcodeException
    Console.WriteLine(ex.Message)
  End Try

End Sub

Remarks

A PDF417 barcode size is dependent on the following values:

  • Number of Columns
  • Number of Rows
  • X Module Size
  • Module Aspect Ratio
To calculate barcode Width use the following equation:
Width= ((Number of Columns * 17) + 73) * (X Module Size)
This includes the Quiet Zone, Indicators, Start and Stop patterns.

To calculate barcode Height use the following equation:
Height=(Number of Rows + 4) * (X Module Size) * (Module Aspect Ratio)
The 4 added to Number of Rows is to account for the Quiet Zone.

If the number of columns and rows are not specified the default behavior is to find the minimum number of columns that the data requires to fit in its rows.

The Quiet Zone for a barcode is a minimum required white space before the start of the barcode symbols. The purpose is to delineate non-barcode information from the barcode data to prevent a reader from picking up information that doesn’t pertain to the barcode. For a PDF417 the Quiet Zone is 2 Modules on each side.

AspectHeight and AspectWidth properties are needed in special case when the number of barcode codewords equal to 4 (i.e. small barcodes).

If there isn’t a valid row column combination available to fit the encoded data or if the number of the specified columns and rows cannot fit the data. The function will return "Function Not Successful".

For a table containing information useful when writing PDF417 barcode data see http://www.leadtools.com/SDK/Document/Document-Addon-Barcodepdf-chart.htm.

MicroPDF417 may only be printed in certain defined combinations of rows and columns. Possible values are (wColumns x wRows)and maximum capacity are displayed in the table below:

  • 0 x 0 (Default)
  • 1 x 11
  • 1 x 14
  • 1 x 17
  • 1 x 20
  • 1 x 24
  • 1 x 28
  • 2 x 8
  • 2 x 11
  • 2 x 14
  • 2 x 17
  • 2 x 20
  • 2 x 23
  • 2 x 26
  • 3 x 6
  • 3 x 8
  • 3 x 10
  • 3 x 12
  • 3 x 15
  • 3 x 20
  • 3 x 26
  • 3 x 32
  • 3 x 38
  • 3 x 44
  • 4 x 4
  • 4 x 6
  • 4 x 8
  • 4 x 10
  • 4 x 12
  • 4 x 15
  • 4 x 20
  • 4 x 26
  • 4 x 32
  • 4 x 38
  • 4 x 44

Inheritance Hierarchy

System.Object
   Leadtools.Barcode.BarcodeWritePdf

Requirements

Target Platforms: Microsoft .NET Framework 2.0, Windows 2000, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7

See Also

Leadtools.Barcode requires a Barcode Module license and unlock key. For more information, refer to: Imaging Pro/Document/Medical Features