在pdf版本1.2中,只有在新版本中创建pdfstamper(new pdfstamper(reader,fos'\0',true)-最后一个参数负责新版本)时,才会放置戳记,但当您尝试以戳记pdf格式创建新的com.aspose.pdf.document(contentfilepath)时,会崩溃:
Caused by: java.lang.NullPointerException
at com.aspose.pdf.internal.l1if.l1v.<init>(Unknown Source)
at com.aspose.pdf.internal.l6if.lf.lf(Unknown Source)
at com.aspose.pdf.internal.l0h.l0p.lj(Unknown Source)
at com.aspose.pdf.PageCollection.<init>(Unknown Source)
at com.aspose.pdf.ADocument.l1h(Unknown Source)
at com.aspose.pdf.ADocument.lI(Unknown Source)
at com.aspose.pdf.ADocument.<init>(Unknown Source)
at com.aspose.pdf.Document.<init>(Unknown Source)
在调试中,我在页面集合中看到suppressedexception错误unmodifiablerandomaccesslist
不幸的是,我不能附加的pdf文件,因为它的机密数据。如第20.10节,第5.0.5节。
PdfStamper stamper = null;
FileOutputStream fos = null;
PdfReader reader = null;
String contentFilePathOut = "C:\\DISTR\\out.pdf";
try {
FileInputStream fis = new FileInputStream("C:\\DISTR\\source.pdf");
reader = new PdfReader(fis);
fos = new FileOutputStream(contentFilePathOut, true);
stamper = new PdfStamper(reader, fos, '\0', true);
PdfContentByte canvas = stamper.getOverContent(1);
ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("Hello people!"), 250, 750, 0);
} finally {
try {
if (stamper != null) {
stamper.close();
}
} catch (Exception ignore) {
}
try {
if (fos != null) {
fos.close();
}
} catch (Exception ignore) {
}
try {
if (reader != null) {
reader.close();
}
} catch (Exception ignore) {
}
}
try {
com.aspose.pdf.Document pdf = new com.aspose.pdf.Document(contentFilePathOut);
} catch (Exception e) {
throw new ServiceException(e);
}
暂无答案!
目前还没有任何答案,快来回答吧!