user3415915
user3415915

Reputation: 11

How to set the height of the barcode as 25mm

As per the API of iText, it is mentioned that we can set the height of the barcode using the method public void setBarHeight(float barHeight), but it is not mentioned what is the measurement (unit) of the height. I need to have the barcode of height 25mm; so what should be the value passed to the mentioned method?

Upvotes: 1

Views: 807

Answers (1)

P̲̳x͓L̳
P̲̳x͓L̳

Reputation: 3653

This is for the class BarcodePostnet but it will apply same for others classes that extends BarCode class.

The unit used is PostScript Point. You shoud pass to the method value 70.86614f (72 / 25.4 * 25 milimeter = 70.866141732283464566929133858268 PostScript points)


Explanation

First read docs for the BarcodePostnet where you will see

    Implements the Postnet and Planet barcodes. The default parameters are:

    n = 72f / 22f; // distance between bars
    x = 0.02f * 72f; // bar width
    barHeight = 0.125f * 72f; // height of the tall bars
    size = 0.05f * 72f; // height of the short bars
    codeType = POSTNET; // type of code

Refering to the standard for the POSTNET barcodes

4.2.5 POSTNET Barcode Dimensions and Spacing POSTNET barcodes are subject to these standards for bar dimensions and spacing. Extraneous ink or ink voids must not cause any bar to fail to meet these standards:

a. A full bar must be 0.125 ±0.010 inch high.

b. A half bar must be 0.050 ±0.010 inch high.

c. All bars must be 0.020 ±0.005 inch wide

Therefore you can conclude that default unit is PostScript Point.

Upvotes: 2

Related Questions