Table of Contents

Class Barcode128

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

Implements the code 128 and UCC/EAN-128. Other symbologies are allowed in raw mode. The code types allowed are: CODE128 - plain barcode 128. CODE128_UCC - support for UCC/EAN-128 with a full list of AI. CODE128_RAW - raw mode. The code attribute has the actual codes from 0 to 105 followed by '\uffff' and the human readable text. The default parameters are: x = 0.8f; font = BaseFont.CreateFont("Helvetica", "winansi", false); size = 8; baseline = size; barHeight = size * 3; textint= Element.ALIGN_CENTER; codeType = CODE128; @author Paulo Soares (psoares@consiste.pt)

public class Barcode128 : Barcode
Inheritance
Barcode128
Inherited Members

Constructors

Barcode128()

Creates new Barcode128

public Barcode128()

Fields

CODE_A

public const char CODE_A = 'È'

Field Value

char

CODE_AB_TO_C

The charset code change.

public const char CODE_AB_TO_C = 'c'

Field Value

char

CODE_AC_TO_B

The charset code change.

public const char CODE_AC_TO_B = 'd'

Field Value

char

CODE_BC_TO_A

The charset code change.

public const char CODE_BC_TO_A = 'e'

Field Value

char

CODE_C

public const char CODE_C = 'Ç'

Field Value

char

DEL

public const char DEL = 'Ã'

Field Value

char

FNC1

public const char FNC1 = 'Ê'

Field Value

char

FNC1_INDEX

The code for UCC/EAN-128.

public const char FNC1_INDEX = 'f'

Field Value

char

FNC2

public const char FNC2 = 'Å'

Field Value

char

FNC3

public const char FNC3 = 'Ä'

Field Value

char

FNC4

public const char FNC4 = 'È'

Field Value

char

SHIFT

public const char SHIFT = 'Æ'

Field Value

char

STARTA

public const char STARTA = 'Ë'

Field Value

char

STARTB

public const char STARTB = 'Ì'

Field Value

char

STARTC

public const char STARTC = 'Í'

Field Value

char

START_A

The start code.

public const char START_A = 'g'

Field Value

char

START_B

The start code.

public const char START_B = 'h'

Field Value

char

START_C

The start code.

public const char START_C = 'i'

Field Value

char

Properties

BarcodeSize

Gets the maximum area that the barcode and the text, if any, will occupy. The lower left corner is always (0, 0).

public override Rectangle BarcodeSize { get; }

Property Value

Rectangle

the size the barcode occupies.

Code

Sets the code to generate. If it's an UCC code and starts with '(' it will be split by the AI. This code in UCC mode is valid: (01)00000090311314(10)ABC123(15)060916

public override string Code { set; }

Property Value

string

Methods

CreateDrawingImage(Color, Color)

public override SKBitmap CreateDrawingImage(Color foreground, Color background)

Parameters

foreground Color
background Color

Returns

SKBitmap

GetBarsCode128Raw(string)

Generates the bars. The input has the actual barcodes, not the human readable text.

public static byte[] GetBarsCode128Raw(string text)

Parameters

text string

the barcode

Returns

byte[]

the bars

GetHumanReadableUccean(string)

Gets the human readable text of a sequence of AI.

public static string GetHumanReadableUccean(string code)

Parameters

code string

the text

Returns

string

the human readable text

GetRawText(string, bool)

Converts the human readable text to the characters needed to create a barcode. Some optimization is done to get the shortest code. the character FNC1 is added

public static string GetRawText(string text, bool ucc)

Parameters

text string

the text to convert

ucc bool

true if it is an UCC/EAN-128. In this case

Returns

string

the code ready to be fed to GetBarsCode128Raw()

PlaceBarcode(PdfContentByte, BaseColor, BaseColor)

Places the barcode in a PdfContentByte . The barcode is always placed at coodinates (0, 0). Use the translation matrix to move it elsewhere. The bars and text are written in the following colors: barColor textColor Result null null bars and text painted with current fill color barColor null bars and text painted with barColor null textColor bars painted with current color text painted with textColor barColor textColor bars painted with barColor text painted with textColor

public override Rectangle PlaceBarcode(PdfContentByte cb, BaseColor barColor, BaseColor textColor)

Parameters

cb PdfContentByte

the PdfContentByte where the barcode will be placed

barColor BaseColor

the color of the bars. It can be null

textColor BaseColor

the color of the text. It can be null

Returns

Rectangle

the dimensions the barcode occupies

RemoveFnc1(string)

Removes the FNC1 codes in the text.

public static string RemoveFnc1(string code)

Parameters

code string

the text to clean

Returns

string

the cleaned text