java pdfbox 解析报错_pdfbox 读取文件报错 java.io.IOException: Page tree root must be a dictionary...
pdfbox java.io.IOException: Page tree root must be a dictionary
示例代碼
public static void main(String[] args) {
try (InputStream sampleInputs = new ClassPathResource("sample/untitle2.pdf").getInputStream();
PDDocument doc = PDDocument.load(sampleInputs, MemoryUsageSetting.setupTempFileOnly())) {
// get the document catalog
PDAcroForm acroForm = doc.getDocumentCatalog().getAcroForm();
// as there might not be an AcroForm entry a null check is necessary
if (acroForm != null) {
// Retrieve an individual field and set its value.
PDTextField field = (PDTextField) acroForm.getField("sampleField");
field.setValue("Text Entry");
// If a field is nested within the form tree a fully qualified name
// might be provided to access the field.
field = (PDTextField) acroForm.getField("fieldsContainer.nestedSampleField");
field.setValue("Text Entry");
}
// Save and close the filled out form.
// doc.save("target/FillFormField.pdf");
} catch (IOException e) {
e.printStackTrace();
}
}
maven 中添加配置
org.springframework.boot
spring-boot-maven-plugin
maven-resources-plugin
參考:http://maven.apache.org/plugins/maven-resources-plugin/examples/filter.html
總結
以上是生活随笔為你收集整理的java pdfbox 解析报错_pdfbox 读取文件报错 java.io.IOException: Page tree root must be a dictionary...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 内存占用测试大揭秘:选对软件、跑全面测试
- 下一篇: java如何接受字符_java中stri