0
我需要生成一個PDF417條碼,並在其中我有一個利用iText API的申請標識符的PDF欄填寫往裏面條碼PDF417的PDF。利用iText一個字段標識
我已經使用了幾種方式,如
路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);
這裏的問題是商品條碼不正確的大小,而不是放置在正確的位置。
路2
BarcodePDF417 barcode = new BarcodePDF417();
barcode.setText("Some text value for encoding");
barcode.placeBarcode(cb, BaseColor.BLACK, 5, 5);
這裏也是問題是相同的,條形碼是不正確的大小和沒有放置在正確的位置。
我知道的申請字段的標識符,我需要專門放置條形碼。 有沒有一種方法可以讓我得到細胞,並生成這個細胞的確切大小的條形碼圖像,並將其放入?
謝謝所有幫助!