您好我正在尝试读取由servlet上传的PDF文件。
这是代码
//out = byte array
out = readInItem(item);
fileToUpload = new ByteArrayInputStream(out.toByteArray());
Map<String, AcroFields.Item> pdfBoxNames = new HashMap<String, AcroFields.Item>();
PdfReader reader = new PdfReader(fileToUpload);
ByteArrayOutputStream os = new ByteArrayOutputStream();
PdfStamper stamper = new PdfStamper(reader, os);
AcroFields acroFields = stamper.getAcroFields();
pdfBoxNames = acroFields.getFields();
我的pdf就像这个%PDF-1.6
一样开始错误讯息是 java.io.IOException:找不到PDF标题签名。
答案 0 :(得分:1)
面对同样的异常!确保您已为此设置了TableHeader
和作者PageEvent
。我刚添加它们,这个例外消失了!希望它能帮到你
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(filePath));
TableHeader includeHeader = new TableHeader();
writer.setPageEvent(includeHeader);