I need to generate a PDF417 barcode and fill it in a PDF field for which I have the filed identifier using ITEXT API.
I have used several ways such as
Way 1
PdfContentByte cb = stamper.getUnderContent(1);
BarcodePDF417 pf = new BarcodePDF417();
pf.setText("Some text value for encoding");
Rectangle size = pf.getBarcodeSize();
PdfTemplate template = cb.createTemplate(size.getWidth(), size.getHeight());
pf.placeBarcode(template, BaseColor.BLACK, 5, 5);
Image image = Image.getInstance(template);
image.setAbsolutePosition(35f, 40f);
cb.addImage(image);
The issue here is the barcode is not of right size and is not placed at correct position.
Way 2.
BarcodePDF417 barcode = new BarcodePDF417();
barcode.setText("Some text value for encoding");
barcode.placeBarcode(cb, BaseColor.BLACK, 5, 5);
Here too the issue is same, the barcode is not of right size and is not placed at correct position.
I know the field IDENTIFIER for the filed where I need to place the barcode specifically. Is there a way with which I can get the cell and generate the barcode image of exact size of this cell and place it in?
Thank you for all the help!