itext7 PDF模板賦值。文本域、單選、多選都沒問題。只有影像域,怎么都沒法賦值一個image。文本倒是能賦進去。這個影像域究竟能不能賦值圖片?難道是我方向錯了?
uj5u.com熱心網友回復:
自己解決了。。uj5u.com熱心網友回復:
沒有用 過 itext7,你可以看看 奧多比的 arc pdf reader 的API。uj5u.com熱心網友回復:
javax.xml.parsers.DocumentBuilderFactory.setFeature(Ljava/lang/String;Z)V 請問這個錯誤如何解決try{
Map<String, String> params = new HashMap<>();
params.put("fill_15","測驗");
PdfDocument pdf = new PdfDocument(new PdfReader(templatePath), new PdfWriter(newPDFPath));
if (params != null && !params.isEmpty()) {// 有引數才替換
PdfAcroForm form = PdfAcroForm.getAcroForm(pdf, true);
Map<String, PdfFormField> fields = form.getFormFields(); // 獲取所有的表單域
for (String param : params.keySet()) {
PdfFormField formField = fields.get(param); // 獲取某個表單域
if (formField != null) {
//formField.setFont(getDefaultFont()).setValue(params.get(param)); // 替換值
formField.setValue(params.get(param)); // 替換值
}
}
// form.flattenFields();// 鎖定表單,不讓修改
}
pdf.close();
}catch (Exception e){
e.printStackTrace();
}
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itext7-core</artifactId>
<version>7.1.4</version>
<type>pom</type>
</dependency>
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/64907.html
標籤:組件/控件開發
上一篇:.NET CORE應用程式啟動
