Tôi đang cố gắng điền vào PDF bằng cách sử dụng acrofields, tôi có thể thêm dữ liệu chuỗi hoàn hảo, nhưng có vấn đề trong việc thêm hình ảnh vào acrofields. Đây là mã của tôi để thêm dữ liệu chuỗi ..Thêm hình ảnh vào acrofield trong iText?
File f = new File("F:/Test/Agreement.pdf");
InputStream sourceTemplatePDFUrlStream = new BufferedInputStream(new FileInputStream(f));
File destinationFile = new File("F:/Test/ag1.pdf");
PdfReader reader = new PdfReader(sourceTemplatePDFUrlStream);
PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(
destinationFile));
AcroFields form = stamper.getAcroFields();
Image img = Image.getInstance("E:/signature/signature.png");
Set fields = form.getFields().keySet();
Hashtable val = new Hashtable();
val.put("name", "xxx");
val.put("city_street_zip", "xxx"+" "+"xxx"+" "+"xxx");
val.put("chck_1", "Yes");
val.put("chck_2", "No");
val.put("chck_3", "Yes");
val.put("street_address", "xxx");
val.put("account_num", "1234");
Enumeration enumeration = val.keys();
// iterate through Hashtable val keys Enumeration
while (enumeration.hasMoreElements()) {
String nextElement = (String) enumeration.nextElement();
String nextElementValue = (String) val.get(nextElement);
//System.out.println(nextElement + ":=================fillData===================:" + nextElementValue);
form.setField(nextElement, nextElementValue);
}
//Form flattening makes the form non-editable and saveable with the
//form val filled in
stamper.setFormFlattening(true);
stamper.close();
cho chúng ta thấy mã của bạn –
@VigneshVino sửa đang question..included tôi –
stack trace của bạn sẽ giúp tôi hiểu vấn đề u'r –