Olivier BASTIN (506) wrote:

Hi,

I try to generate a pdf form with a barcode and precompleted field.

I can't have precompleted field and a barcode to a same form.

I'd define a button area and retrieve the positions like this:

float[] barcodebutton = form.getFieldPositions("barcode");
Rectangle rect = new Rectangle(barcodebutton[1], barcodebutton[2], barcodebutton[3], barcodebutton[4]);
PdfContentByte cb = stamper.getOverContent((int)photograph[0]);

Note that index 0 gives you a page number;
index 1, 2, 3 and 4 give you the coordinates.

I would create my barcode as an Image, for instance:

BarcodeEAN codeEAN = new BarcodeEAN();
codeEAN.setCodeType(Barcode.EAN13);
codeEAN.setCode("9780201615883");
Image imageEAN = codeEAN.createImageWithBarcode(cb, null, null);

Then I'd resize and position my barcode:
codeEAN.scaleToFit(rect.width(), rect.height());
codeEAN.setAbsolutePosition(barcodebutton[1] + (rect.width() - codeEAN.scaledWidth()) / 2,
 barcodebutton[2] + (rect.height() - codeEAN.scaledHeight()) / 2);

Now you are ready to add the image.
cb.addImage(codeEAN);

C'est simple comme bonjour ;-)
br,
Bruno


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to