←Select platform

BarcodeWritePdf Class

Summary

This class contains information for writing PDF417 and MicroPDF417 barcodes.

Syntax

C#
VB
C++
[DataContractAttribute(Namespace="http://Leadtools.Services.Barcode.DataContracts/2009/01", Name="BarcodeWritePdf")] 
public class BarcodeWritePdf 
  
<DataContractAttribute(Namespace="http://Leadtools.Services.Barcode.DataContracts/2009/01", Name="BarcodeWritePdf")> 
Public Class BarcodeWritePdf  
[DataContractAttribute(Namespace="http://Leadtools.Services.Barcode.DataContracts/2009/01", Name="BarcodeWritePdf")] 
public ref class BarcodeWritePdf  

Remarks

For a table containing information useful when writing PDF417 barcode data, see https://www.leadtools.com/sdk/barcode/pdf417-chart.

MicroPDF417 can only be printed in certain defined combinations of rows and columns. The possible value combinations are (wColumns x wRows):

  • 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
Example

C#
VB
using Leadtools.Services; 
using Leadtools.Services.Barcode.ServiceContracts; 
using Leadtools.Services.Barcode.ServiceImplementations; 
 
byte[] ConvertFromStringArray(string[] data) 
{ 
   if (data == null || data.Length == 0) 
      return null; 
 
   List<byte[]> list = new List<byte[]>(); 
   ASCIIEncoding ascii = new ASCIIEncoding(); 
 
   int length = 0; 
   for (int i = 0; i < data.Length; i++) 
   { 
      byte[] bytes = ascii.GetBytes(data[i]); 
      list.Add(bytes); 
      length += bytes.Length; 
      length++; 
   } 
 
   byte[] ret = new byte[length]; 
   int index = 0; 
   for (int i = 0; i < list.Count; i++) 
   { 
      byte[] bytes = list[i]; 
      bytes.CopyTo(ret, index); 
      index += bytes.Length + 1; 
   } 
 
   return ret; 
} 
 
public void BarcodeWritePdfExample() 
{ 
   BarcodeServiceClient client = new BarcodeServiceClient(); 
 
   RawBinaryData sourceBinaryData = new RawBinaryData(); 
   sourceBinaryData.Data = File.ReadAllBytes(Path.Combine(LEAD_VARS.ImagesDir, "barcode1.tif")); 
 
   RasterConvertOptions convertOptions = new RasterConvertOptions(); 
   convertOptions.Source = sourceBinaryData; 
   convertOptions.Destination = null; 
   convertOptions.Format = RasterImageFormat.RasPdf; 
   convertOptions.FirstPage = 1; 
   convertOptions.LastPage = 1; 
   convertOptions.BitsPerPixel = 24; 
   convertOptions.QualityFactor = 2; 
 
   LeadRectangle rc = new LeadRectangle(); 
   rc.X = 100; 
   rc.Y = 100; 
   rc.Width = 0; 
   rc.Height = 0; 
 
   string[] barcodeText; 
   barcodeText = new string[1]; 
   barcodeText[0] = "PDF417 Symbol"; 
 
   BarcodeData data = new BarcodeData(); 
   data.Unit = BarcodeUnit.ScanlinesPerPixels; 
   data.Location = rc; 
   data.Data = ConvertFromStringArray(barcodeText); 
 
   BarcodeColor barColor = new BarcodeColor(); 
   barColor.BarColor = "Black"; 
   barColor.SpaceColor = "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; 
 
   WriteOptions options = new WriteOptions(); 
 
   WriteBarcode2DPdf417 pdf417 = new WriteBarcode2DPdf417(); 
   pdf417.Type = WriteBarcode2DPdf417Type.Pdf417; 
   pdf417.Data = data; 
 
   options.Add(pdf417); 
 
 
   WriteRequest request = new WriteRequest(); 
 
   request.Code1d = bar1d; 
   request.CodeColor = barColor; 
   request.CodeDatamatrix = barDM; 
   request.CodePdf = barPDF; 
   request.CodeQr = barQR; 
   request.ConvertOptions = convertOptions; 
   request.TypeFlags = BarcodeMajorTypeFlags.BarcodesDatamatrixWrite; 
   request.Unit = BarcodeUnit.ScanlinesPerPixels; 
   request.WriteFlags = BarcodeWriteFlags.UseColors | BarcodeWriteFlags.Transparent | BarcodeWriteFlags.InitializationReader | BarcodeWriteFlags.DisableCompression; 
   request.WriteOptions = options; 
 
   WriteResponse response = client.Write(request); 
 
   if (response.Destination != null) 
   { 
      if (response.Destination is RawBinaryData) 
      { 
         File.WriteAllBytes(Path.Combine(LEAD_VARS.ImagesDir, "BarcodeWritePdf.Pdf"), (response.Destination as RawBinaryData).Data); 
      } 
   } 
 
   client.Close(); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images"; 
} 
Imports Leadtools.Services 
Imports Leadtools.Services.Barcode.ServiceContracts 
Imports Leadtools.Services.Barcode.ServiceImplementations 
 
Private Function ConvertFromStringArray(ByVal data As String()) As Byte() 
   If data Is Nothing OrElse data.Length = 0 Then 
      Return Nothing 
   End If 
 
   Dim list As New List(Of Byte()) 
   Dim ascii As ASCIIEncoding = New ASCIIEncoding() 
 
   Dim length As Integer = 0 
   Dim i As Integer = 0 
   Do While i < data.Length 
      Dim bytes As Byte() = ascii.GetBytes(data(i)) 
      list.Add(bytes) 
      length += bytes.Length 
      length += 1 
      i += 1 
   Loop 
 
   Dim ret As Byte() = New Byte(length - 1) {} 
   Dim index As Integer = 0 
   i = 0 
   Do While i < list.Count 
      Dim bytes As Byte() = list(i) 
      bytes.CopyTo(ret, index) 
      index += bytes.Length + 1 
      i += 1 
   Loop 
 
   Return ret 
End Function 
 
Public Sub BarcodeWritePdfExample() 
   Dim client As BarcodeServiceClient = New BarcodeServiceClient() 
 
   Dim sourceBinaryData As RawBinaryData = New RawBinaryData() 
   sourceBinaryData.Data = File.ReadAllBytes(Path.Combine(LEAD_VARS.ImagesDir, "barcode1.tif")) 
 
   Dim convertOptions As RasterConvertOptions = New RasterConvertOptions() 
   convertOptions.Source = sourceBinaryData 
   convertOptions.Destination = Nothing 
   convertOptions.Format = RasterImageFormat.RasPdf 
   convertOptions.FirstPage = 1 
   convertOptions.LastPage = 1 
   convertOptions.BitsPerPixel = 24 
   convertOptions.QualityFactor = 2 
 
   Dim rc As LeadRectangle = New LeadRectangle() 
   rc.X = 100 
   rc.Y = 100 
   rc.Width = 0 
   rc.Height = 0 
 
   Dim barcodeText As String() 
   barcodeText = New String(0) {} 
   barcodeText(0) = "PDF417 Symbol" 
 
   Dim data As BarcodeData = New BarcodeData() 
   data.Unit = BarcodeUnit.ScanlinesPerPixels 
   data.Location = rc 
   data.Data = ConvertFromStringArray(barcodeText) 
 
   Dim barColor As BarcodeColor = New BarcodeColor() 
   barColor.BarColor = "Black" 
   barColor.SpaceColor = "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 
 
   Dim options As WriteOptions = New WriteOptions() 
 
   Dim pdf417 As WriteBarcode2DPdf417 = New WriteBarcode2DPdf417() 
   pdf417.Type = WriteBarcode2DPdf417Type.Pdf417 
   pdf417.Data = data 
 
   options.Add(pdf417) 
 
 
   Dim request As WriteRequest = New WriteRequest() 
 
   request.Code1d = bar1d 
   request.CodeColor = barColor 
   request.CodeDatamatrix = barDM 
   request.CodePdf = barPDF 
   request.CodeQr = barQR 
   request.ConvertOptions = convertOptions 
   request.TypeFlags = BarcodeMajorTypeFlags.BarcodesDatamatrixWrite 
   request.Unit = BarcodeUnit.ScanlinesPerPixels 
   request.WriteFlags = BarcodeWriteFlags.UseColors Or BarcodeWriteFlags.Transparent Or BarcodeWriteFlags.InitializationReader Or BarcodeWriteFlags.DisableCompression 
   request.WriteOptions = options 
 
   Dim response As WriteResponse = client.Write(request) 
 
   If Not response.Destination Is Nothing Then 
      If TypeOf response.Destination Is RawBinaryData Then 
         File.WriteAllBytes(Path.Combine(LEAD_VARS.ImagesDir, "BarcodeWritePdf.Pdf"), (TryCast(response.Destination, RawBinaryData)).Data) 
      End If 
   End If 
 
   client.Close() 
End Sub 
 
Public NotInheritable Class LEAD_VARS 
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images" 
End Class 

Requirements

Target Platforms

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Services.Barcode.DataContracts Assembly