嘿伙计们,对于长篇大论和糟糕的语言,如果有不必要的细节,
我使用 excel 文档从一个 pdf 模板创建了多个 1page pdf,
我现在有
这样的东西
tempfile0.pdf
tempfile1.pdf
tempfile2.pdf
...
我试图合并所有使用 itext5 在单个 pdf 中创建文件,
但它表明结果 pdf
中的页面与第一页
tempfile1中的每个示例tempfile0.pdf 中 我想要的顺序不同 。
这里的 2000 页 是我使用的代码。
我使用的程序是:
1 从哈希图中填充一个
2 将填充的表单保存为一个 pdf
3 将所有文件合并为一个 pdf
public void fillPdfitext(int debut,int fin) throws IOException, DocumentException {
for (int i =debut; i < fin; i++) {
HashMap<String, String> currentData = dataextracted[i];
// textArea.appendText("\n"+pdfoutputname +" en cours de preparation\n ");
PdfReader reader = new PdfReader(this.sourcePdfTemplateFile.toURI().getPath());
String outputfolder = this.destinationOutputFolder.toURI().getPath();
PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(outputfolder+"\\"+"tempcontrat"+debut+"-" +i+ "_.pdf"));
// get the document catalog
AcroFields acroForm = stamper.getAcroFields();
// as there might not be an AcroForm entry a null check is necessary
if (acroForm != null) {
for (String key : currentData.keySet()) {
try {
String fieldvalue=currentData.get(key);
if (key=="ADRESSE1"){
fieldvalue = currentData.get("ADRESSE1")+" "+currentData.get("ADRESSE2") ;
acroForm.setField("ADRESSE", fieldvalue);
}
if (key == "IMEI"){
acroForm.setField("NUM_SERIE_PACK", fieldvalue);
}
acroForm.setField(key, fieldvalue);
// textArea.appendText(key + ": "+fieldvalue+"\t\t");
} catch (Exception e) {
// e.printStackTrace();
}
}
stamper.setFormFlattening(true);
}
stamper.close();
}
}
我的问题是如何在生成的 pdf 中保持文件的顺序相同
忽然笑
相关分类