Table of Contents

Class Barcode

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

Base class containing properties and methods commom to all barcode types. @author Paulo Soares (psoares@consiste.pt)

public abstract class Barcode
Inheritance
Barcode
Derived
Inherited Members

Constructors

Barcode()

protected Barcode()

Fields

CODABAR

A type of barcode

public const int CODABAR = 12

Field Value

int

CODE128

A type of barcode

public const int CODE128 = 9

Field Value

int

CODE128_RAW

A type of barcode

public const int CODE128_RAW = 11

Field Value

int

CODE128_UCC

A type of barcode

public const int CODE128_UCC = 10

Field Value

int

EAN13

A type of barcode

public const int EAN13 = 1

Field Value

int

EAN8

A type of barcode

public const int EAN8 = 2

Field Value

int

PLANET

A type of barcode

public const int PLANET = 8

Field Value

int

POSTNET

A type of barcode

public const int POSTNET = 7

Field Value

int

SUPP2

A type of barcode

public const int SUPP2 = 5

Field Value

int

SUPP5

A type of barcode

public const int SUPP5 = 6

Field Value

int

UPCA

A type of barcode

public const int UPCA = 3

Field Value

int

UPCE

A type of barcode

public const int UPCE = 4

Field Value

int

altText

The alternate text to be used, if present.

protected string altText

Field Value

string

barHeight

The height of the bars.

protected float barHeight

Field Value

float

baseline

If positive, the text distance under the bars. If zero or negative, the text distance above the bars.

protected float baseline

Field Value

float

checksumText

Shows the generated checksum in the the text.

protected bool checksumText

Field Value

bool

code

The code to generate.

protected string code

Field Value

string

codeType

The code type.

protected int codeType

Field Value

int

extended

Generates extended barcode 39.

protected bool extended

Field Value

bool

font

The text font. null if no text.

protected BaseFont font

Field Value

BaseFont

generateChecksum

The optional checksum generation.

protected bool generateChecksum

Field Value

bool

guardBars

Show the guard bars for barcode EAN.

protected bool guardBars

Field Value

bool

inkSpreading

The ink spreading.

protected float inkSpreading

Field Value

float

n

The bar multiplier for wide bars or the distance between bars for Postnet and Planet.

protected float n

Field Value

float

size

The size of the text or the height of the shorter bar in Postnet.

protected float size

Field Value

float

startStopText

Show the start and stop character '*' in the text for the barcode 39 or 'ABCD' for codabar.

protected bool startStopText

Field Value

bool

textAlignment

The text Element. Can be Element.ALIGN_LEFT , Element.ALIGN_CENTER or Element.ALIGN_RIGHT .

protected int textAlignment

Field Value

int

x

The minimum bar width.

protected float x

Field Value

float

Properties

AltText

Sets the alternate text. If present, this text will be used instead of the text derived from the supplied code.

public string AltText { get; set; }

Property Value

string

BarHeight

Gets the height of the bars.

public float BarHeight { get; set; }

Property Value

float

the height of the bars

BarcodeSize

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

public abstract Rectangle BarcodeSize { get; }

Property Value

Rectangle

the size the barcode occupies.

Baseline

Gets the text baseline. If positive, the text distance under the bars. If zero or negative, the text distance above the bars.

public float Baseline { get; set; }

Property Value

float

the baseline.

ChecksumText

Sets the property to show the generated checksum in the the text.

public bool ChecksumText { get; set; }

Property Value

bool

Code

Gets the code to generate.

public virtual string Code { get; set; }

Property Value

string

the code to generate

CodeType

Gets the code type.

public int CodeType { get; set; }

Property Value

int

the code type

Extended

Sets the property to generate extended barcode 39.

public bool Extended { get; set; }

Property Value

bool

Font

Gets the text font. null if no text.

public BaseFont Font { get; set; }

Property Value

BaseFont

the text font. null if no text

GenerateChecksum

The property for the optional checksum generation.

public bool GenerateChecksum { get; set; }

Property Value

bool

GuardBars

Sets the property to show the guard bars for barcode EAN.

public bool GuardBars { get; set; }

Property Value

bool

InkSpreading

public float InkSpreading { get; set; }

Property Value

float

N

Gets the bar multiplier for wide bars.

public float N { get; set; }

Property Value

float

the bar multiplier for wide bars

Size

Gets the size of the text.

public float Size { get; set; }

Property Value

float

the size of the text

StartStopText

Gets the property to show the start and stop character '*' in the text for the barcode 39.

public bool StartStopText { get; set; }

Property Value

bool

TextAlignment

Gets the text Element. Can be Element.ALIGN_LEFT , Element.ALIGN_CENTER or Element.ALIGN_RIGHT .

public int TextAlignment { get; set; }

Property Value

int

the text alignment

X

Gets the minimum bar width.

public float X { get; set; }

Property Value

float

the minimum bar width

Methods

CreateDrawingImage(Color, Color)

public abstract SKBitmap CreateDrawingImage(Color foreground, Color background)

Parameters

foreground Color
background Color

Returns

SKBitmap

CreateImageWithBarcode(PdfContentByte, BaseColor, BaseColor)

Creates an Image with the barcode. serves no other use @see #placeBarcode(PdfContentByte cb, Color barColor, Color textColor)

public Image CreateImageWithBarcode(PdfContentByte cb, BaseColor barColor, BaseColor textColor)

Parameters

cb PdfContentByte

the PdfContentByte to create the Image . It

barColor BaseColor

the color of the bars. It can be null

textColor BaseColor

the color of the text. It can be null

Returns

Image

the Image

CreateTemplateWithBarcode(PdfContentByte, BaseColor, BaseColor)

Creates a template with the barcode. serves no other use @see #placeBarcode(PdfContentByte cb, Color barColor, Color textColor)

public PdfTemplate CreateTemplateWithBarcode(PdfContentByte cb, BaseColor barColor, BaseColor textColor)

Parameters

cb PdfContentByte

the PdfContentByte to create the template. It

barColor BaseColor

the color of the bars. It can be null

textColor BaseColor

the color of the text. It can be null

Returns

PdfTemplate

the template

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 abstract 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