Class OneDimensionalCodeWriter
Encapsulates functionality and implementation that is common to one-dimensional barcodes.
public abstract class OneDimensionalCodeWriter : Writer
- Inheritance
-
OneDimensionalCodeWriter
- Implements
- Derived
- Inherited Members
Constructors
OneDimensionalCodeWriter()
protected OneDimensionalCodeWriter()
Properties
DefaultMargin
Gets the default margin.
public int DefaultMargin { get; }
Property Value
SupportedWriteFormats
returns supported formats
protected abstract IList<BarcodeFormat> SupportedWriteFormats { get; }
Property Value
Methods
CalculateChecksumDigitModulo10(string)
Calculates the checksum digit modulo10.
public static string CalculateChecksumDigitModulo10(string contents)
Parameters
contents
stringThe contents.
Returns
appendPattern(bool[], int, int[], bool)
Appends the given pattern to the target array starting at pos.
protected static int appendPattern(bool[] target, int pos, int[] pattern, bool startColor)
Parameters
target
bool[]encode black/white pattern into this array
pos
intposition to start encoding at in
target
pattern
int[]lengths of black/white runs to encode
startColor
boolstarting color - false for white, true for black
Returns
- int
the number of elements added to target.
checkNumeric(string)
Throw ArgumentException if input contains characters other than digits 0-9.
protected static void checkNumeric(string contents)
Parameters
contents
stringstring to check for numeric characters
Exceptions
- ArgumentException
if input contains characters other than digits 0-9.
encode(string)
Encode the contents to boolean array expression of one-dimensional barcode. Start code and end code should be included in result, and side margins should not be included.
public abstract bool[] encode(string contents)
Parameters
contents
stringbarcode contents to encode
Returns
- bool[]
a
bool[]
of horizontal pixels (false = white, true = black)
encode(string, IDictionary<EncodeHintType, object>)
Can be overwritten if the encode requires to read the hints map. Otherwise it defaults to {@code encode}.
protected virtual bool[] encode(string contents, IDictionary<EncodeHintType, object> hints)
Parameters
contents
stringbarcode contents to encode
hints
IDictionary<EncodeHintType, object>encoding hints
Returns
- bool[]
a
bool[]
of horizontal pixels (false = white, true = black)
encode(string, BarcodeFormat, int, int)
Encode a barcode using the default settings.
public BitMatrix encode(string contents, BarcodeFormat format, int width, int height)
Parameters
contents
stringThe contents to encode in the barcode
format
BarcodeFormatThe barcode format to generate
width
intThe preferred width in pixels
height
intThe preferred height in pixels
Returns
- BitMatrix
The generated barcode as a Matrix of unsigned bytes (0 == black, 255 == white)
encode(string, BarcodeFormat, int, int, IDictionary<EncodeHintType, object>)
Encode the contents following specified format. {@code width} and {@code height} are required size. This method may return bigger size {@code BitMatrix} when specified size is too small. The user can set both {@code width} and {@code height} to zero to get minimum size barcode. If negative value is set to {@code width} or {@code height}, {@code IllegalArgumentException} is thrown.
public virtual BitMatrix encode(string contents, BarcodeFormat format, int width, int height, IDictionary<EncodeHintType, object> hints)
Parameters
contents
stringformat
BarcodeFormatwidth
intheight
inthints
IDictionary<EncodeHintType, object>