Leadtools.Barcode Requires Barcode add-on license | Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
BarcodeWritePdf Class
See Also  Members   Example 
Leadtools.Barcode Namespace : BarcodeWritePdf Class



This class contains information for writing PDF417/MicroPDF417 barcodes.

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
Private Sub BarcodeWritePdfExample()
   ' Load an image
   RasterCodecs.Startup()
   Dim codecs As RasterCodecs = New RasterCodecs()
   codecs.ThrowExceptionsOnInvalidImages = True

   Dim image As RasterImage = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "barcode1.tif")

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

      ' Initialize linear barcodes
      BarcodeEngine.Startup(BarcodeMajorTypeFlags.Barcodes1d)
      barEngine = New BarcodeEngine()

      Dim data As BarcodeData = New BarcodeData()
      Dim rc As Rectangle = New Rectangle(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 = Color.Black
      barColor.SpaceColor = Color.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.InitializationReader Or BarcodeWriteFlags.Truncate, bar1d, barPDF, barDM, barQR, Rectangle.Empty)
      BarcodeEngine.Shutdown()
   Catch ex As BarcodeException
      MessageBox.Show(ex.Message)
   End Try

   RasterCodecs.Shutdown()
End Sub
C#Copy Code
private void BarcodeWritePdfExample() 

   // Load an image 
   RasterCodecs.Startup(); 
   RasterCodecs codecs = new RasterCodecs(); 
   codecs.ThrowExceptionsOnInvalidImages = true; 
   string fileName = LeadtoolsExamples.Common.ImagesPath.Path + "barcode1.tif"; 
   RasterImage image = codecs.Load(fileName); 
 
   BarcodeEngine barEngine; 
   try 
   { 
      // Unlock linear barcode support. 
      // Note that this is a sample key, which will not work in your toolkit 
      RasterSupport.Unlock(RasterSupportType.Barcodes1D, "TestKey"); 
 
      // Initialize linear barcodes 
      BarcodeEngine.Startup(BarcodeMajorTypeFlags.Barcodes1d); 
      barEngine = new BarcodeEngine(); 
 
      BarcodeData data = new BarcodeData(); 
      Rectangle rc = new Rectangle(100, 100, 0, 0); 
      data.Unit = BarcodeUnit.ScanlinesPerPixels; 
      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 = Color.Black; 
      barColor.SpaceColor = Color.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.InitializationReader | BarcodeWriteFlags.Truncate, bar1d, barPDF, barDM, barQR, Rectangle.Empty); 
      BarcodeEngine.Shutdown(); 
   } 
   catch (BarcodeException ex) 
   { 
      MessageBox.Show(ex.Message); 
   } 
 
   RasterCodecs.Shutdown(); 
}

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 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

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