Java Class «ImplPZN» – Generate PZN Barcode
- All Implemented Interfaces:
Cloneable
newInstance
static methods in the Barcode
class.
The PZN (Pharmazentralnummer) is a German barcode standard used to identify pharmaceutical products. It consists of 6 digits for the product identifier plus a check digit.
In the barcode symbol, the hyphen (-) is included by placing it in front of the number.
The human readable text line for the PZN barcode consists of the prefix 'PZN', followed by a space, then a hyphen, and then the 6-digit product identifier, followed by the check digit at the end. For example:
PZN -1234562PZN is not a standalone barcode type but uses the
Code 39
format to encode its
data. As a result, this class extends the abstract class LineageTwoWidth
, as Code 39 is a
type of two-width barcode. See the linked class description for more information.-
Field Summary
Fields inherited from class de.vwsoft.barcodelib4j.oned.LineageTwoWidth
DEFAULT_RATIO
-
Method Summary
Modifier and TypeMethodDescriptionvoid
setContent
(String content, boolean autoComplete, boolean appendOptionalChecksum) Sets the content to be encoded in the barcode.Methods inherited from class de.vwsoft.barcodelib4j.oned.LineageTwoWidth
getRatio, setRatio
Methods inherited from class de.vwsoft.barcodelib4j.oned.Barcode
clone, draw, draw, draw, getAddOn, getContent, getFont, getText, getTextOffset, isFontSizeAdjusted, isTextOnTop, isTextVisible, newInstance, newInstance, setAddOn, setCustomText, setFont, setFontSizeAdjusted, setTextOffset, setTextOnTop, setTextVisible, supportsAddOn, supportsAutoCompletion, supportsCustomText, supportsTextOnTop
-
Method Details
-
setContent
public void setContent(String content, boolean autoComplete, boolean appendOptionalChecksum) throws BarcodeException Sets the content to be encoded in the barcode.If the
autoComplete
parameter istrue
and the length of the content is 6, the method calculates the checksum and appends it to the content, ensuring a total length of 7. If the calculated checksum is 10, aBarcodeException
is thrown because this value is invalid.If
autoComplete
is false, the method validates that the content length is 7 and checks if the last digit matches the calculated checksum. If not, aBarcodeException
is thrown.- Overrides:
setContent
in classImplCode39
- Parameters:
content
- the PZN to be encoded in the barcodeautoComplete
- whether to automatically calculate and append a check digit if it is missingappendOptionalChecksum
- has no function, as PZN uses a fixed check digit which is not optional- Throws:
BarcodeException
- if the content is empty, contains invalid characters, is of incorrect length, has an invalid check digit, or if the calculated checksum is 10
-