Barcode-Lib4J requires Java 9+

Java Class «ImplPZN»  –  Generate PZN Barcode

All Implemented Interfaces:
Cloneable

public class ImplPZN extends ImplCode39
Implementation of PZN (the older 7-digit format). To generate instances, please use one of the 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 -1234562
PZN 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.
  • 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 is true 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, a BarcodeException 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, a BarcodeException is thrown.

      Overrides:
      setContent in class ImplCode39
      Parameters:
      content - the PZN to be encoded in the barcode
      autoComplete - whether to automatically calculate and append a check digit if it is missing
      appendOptionalChecksum - 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