Table of Contents

Class BarcodePdf417

Namespace
iTextSharp.text.pdf
Assembly
iTextSharp.LGPLv2.Core.dll

Generates the 2D barcode PDF417. Supports dimensioning auto-sizing, fixed and variable sizes, automatic and manual error levels, raw codeword input, codeword size optimization and bitmap inversion. The output can be a CCITT G4 Image or a raw bitmap. @author Paulo Soares (psoares@consiste.pt)

public class BarcodePdf417
Inheritance
BarcodePdf417
Inherited Members

Constructors

BarcodePdf417()

Creates a new BarcodePDF417 with the default settings.

public BarcodePdf417()

Fields

ABSOLUTE_MAX_TEXT_SIZE

protected const int ABSOLUTE_MAX_TEXT_SIZE = 5420

Field Value

int

AL

protected const int AL = 28

Field Value

int

ALPHA

protected const int ALPHA = 65536

Field Value

int

AS

protected const int AS = 27

Field Value

int

BYTESHIFT

protected const int BYTESHIFT = 913

Field Value

int

BYTE_MODE

protected const int BYTE_MODE = 901

Field Value

int

BYTE_MODE_6

protected const int BYTE_MODE_6 = 924

Field Value

int

BitPtr

protected int BitPtr

Field Value

int

CwPtr

protected int CwPtr

Field Value

int

ISBYTE

protected const int ISBYTE = 1048576

Field Value

int

LL

protected const int LL = 27

Field Value

int

LOWER

protected const int LOWER = 131072

Field Value

int

MACRO_LAST_SEGMENT

protected const int MACRO_LAST_SEGMENT = 922

Field Value

int

MACRO_SEGMENT_ID

protected const int MACRO_SEGMENT_ID = 928

Field Value

int

MAX_DATA_CODEWORDS

protected const int MAX_DATA_CODEWORDS = 926

Field Value

int

MIXED

protected const int MIXED = 262144

Field Value

int

ML

protected const int ML = 28

Field Value

int

MOD

protected const int MOD = 929

Field Value

int

NUMERIC_MODE

protected const int NUMERIC_MODE = 902

Field Value

int

PAL

protected const int PAL = 29

Field Value

int

PDF417_AUTO_ERROR_LEVEL

The error level correction is set automatically according to ISO 15438 recomendations.

public const int PDF417_AUTO_ERROR_LEVEL = 0

Field Value

int

PDF417_FIXED_COLUMNS

The size will be at least codeColumns with a variable number of codeRows .

public const int PDF417_FIXED_COLUMNS = 2

Field Value

int

PDF417_FIXED_RECTANGLE

The size of the barcode will be at least codeColumns*codeRows .

public const int PDF417_FIXED_RECTANGLE = 1

Field Value

int

PDF417_FIXED_ROWS

The size will be at least codeRows with a variable number of codeColumns .

public const int PDF417_FIXED_ROWS = 4

Field Value

int

PDF417_FORCE_BINARY

One single binary segment is used

public const int PDF417_FORCE_BINARY = 32

Field Value

int

PDF417_INVERT_BITMAP

Inverts the output bits of the raw bitmap that is normally bit one for black. It has only effect for the raw bitmap.

public const int PDF417_INVERT_BITMAP = 128

Field Value

int

PDF417_USE_ASPECT_RATIO

Auto-size is made based on aspectRatio and yHeight .

public const int PDF417_USE_ASPECT_RATIO = 0

Field Value

int

PDF417_USE_ERROR_LEVEL

The error level correction is set by the user. It can be 0 to 8.

public const int PDF417_USE_ERROR_LEVEL = 16

Field Value

int

PDF417_USE_MACRO

Use Macro PDF417 Encoding @see #setMacroFileId(String) @see #setMacroSegmentId(int) @see #setMacroSegmentCount(int)

public const int PDF417_USE_MACRO = 256

Field Value

int

PDF417_USE_RAW_CODEWORDS

No text interpretation is done and the content of codewords is used directly.

public const int PDF417_USE_RAW_CODEWORDS = 64

Field Value

int

PL

protected const int PL = 25

Field Value

int

PS

protected const int PS = 29

Field Value

int

PUNCTUATION

protected const int PUNCTUATION = 524288

Field Value

int

SPACE

protected const int SPACE = 26

Field Value

int

START_CODE_SIZE

protected const int START_CODE_SIZE = 17

Field Value

int

START_PATTERN

protected const int START_PATTERN = 130728

Field Value

int

STOP_PATTERN

protected const int STOP_PATTERN = 260649

Field Value

int

STOP_SIZE

protected const int STOP_SIZE = 18

Field Value

int

SegmentArrayList

protected BarcodePdf417.SegmentList SegmentArrayList

Field Value

BarcodePdf417.SegmentList

TEXT_MODE

protected const int TEXT_MODE = 900

Field Value

int

Properties

AspectRatio

Sets the barcode aspect ratio. A ratio or 0.5 will make the barcode width twice as large as the height.

public float AspectRatio { get; set; }

Property Value

float

BitColumns

Gets the number of X pixels of outBits .

public int BitColumns { get; }

Property Value

int

the number of X pixels of outBits

CodeColumns

Sets the number of barcode data columns. This number may be changed to keep the barcode valid.

public int CodeColumns { get; set; }

Property Value

int

CodeRows

Gets the number of Y pixels of outBits . It is also the number of rows in the barcode.

public int CodeRows { get; set; }

Property Value

int

the number of Y pixels of outBits

Codewords

Gets the codeword array. This array is always 928 elements long. It can be writen to if the option PDF417_USE_RAW_CODEWORDS is set.

public int[] Codewords { get; }

Property Value

int[]

the codeword array

ErrorLevel

Gets the error level correction used for the barcode. It may different from the previously set value.

public int ErrorLevel { get; set; }

Property Value

int

the error level correction used for the barcode

LenCodewords

Sets the length of the codewords.

public int LenCodewords { get; set; }

Property Value

int

MacroFileId

Sets the File ID for macro PDF417 encoding

public string MacroFileId { set; }

Property Value

string

MacroSegmentCount

Sets the segment count for macro PDF417 encoding @see #setMacroSegmentId(int)

public int MacroSegmentCount { set; }

Property Value

int

MacroSegmentId

Sets the segment id for macro PDF417 encoding @see #setMacroSegmentCount(int)

public int MacroSegmentId { set; }

Property Value

int

Options

Sets the options to generate the barcode. This can be all the PDF417_* constants.

public int Options { get; set; }

Property Value

int

OutBits

Gets the raw image bits of the barcode. The image will have to be scaled in the Y direction by yHeight .

public byte[] OutBits { get; }

Property Value

byte[]

The raw barcode image

Text

Sets the bytes that form the barcode. This bytes should be interpreted in the codepage Cp437.

public byte[] Text { get; set; }

Property Value

byte[]

YHeight

Sets the Y pixel height relative to X. It is usually 3.

public float YHeight { get; set; }

Property Value

float

Methods

Assemble()

protected void Assemble()

BasicNumberCompaction(int, int)

protected void BasicNumberCompaction(int start, int length)

Parameters

start int
length int

ByteCompaction6(int)

protected void ByteCompaction6(int start)

Parameters

start int

CalculateErrorCorrection(int)

protected void CalculateErrorCorrection(int dest)

Parameters

dest int

CheckSegmentType(Segment, char)

protected static bool CheckSegmentType(BarcodePdf417.Segment segment, char type)

Parameters

segment BarcodePdf417.Segment
type char

Returns

bool

CreateDrawingImage(Color, Color)

public virtual SKBitmap CreateDrawingImage(Color foreground, Color background)

Parameters

foreground Color
background Color

Returns

SKBitmap

DumpList()

protected void DumpList()

GetImage()

Gets an Image with the barcode. The image will have to be scaled in the Y direction by yHeight for the barcode to have the right printing aspect. @throws BadElementException on error

public Image GetImage()

Returns

Image

the barcode Image

GetMaxSquare()

protected int GetMaxSquare()

Returns

int

GetSegmentLength(Segment)

protected static int GetSegmentLength(BarcodePdf417.Segment segment)

Parameters

segment BarcodePdf417.Segment

Returns

int

GetTextTypeAndValue(int, int)

protected int GetTextTypeAndValue(int maxLength, int idx)

Parameters

maxLength int
idx int

Returns

int

MaxPossibleErrorLevel(int)

protected static int MaxPossibleErrorLevel(int remain)

Parameters

remain int

Returns

int

NumberCompaction(int, int)

protected void NumberCompaction(int start, int length)

Parameters

start int
length int

OutCodeword(int)

protected void OutCodeword(int codeword)

Parameters

codeword int

OutCodeword17(int)

protected void OutCodeword17(int codeword)

Parameters

codeword int

OutCodeword18(int)

protected void OutCodeword18(int codeword)

Parameters

codeword int

OutPaintCode()

protected void OutPaintCode()

OutStartPattern()

protected void OutStartPattern()

OutStopPattern()

protected void OutStopPattern()

PaintCode()

Paints the barcode. If no exception was thrown a valid barcode is available.

public void PaintCode()

SetDefaultParameters()

Set the default settings that correspond to PDF417_USE_ASPECT_RATIO and PDF417_AUTO_ERROR_LEVEL .

public void SetDefaultParameters()

SetText(string)

Sets the text that will form the barcode. This text is converted to bytes using the encoding Cp437. @throws UnsupportedEncodingException if the encoding Cp437 is not supported

public void SetText(string s)

Parameters

s string

the text that will form the barcode

TextCompaction(int, int)

protected void TextCompaction(int start, int length)

Parameters

start int
length int