簡體   English   中英

由於 PdfDocument 拋出 NullPointerException,無法使用 itext 7.0.0 打開 PDF

[英]Unable to open PDF with itext 7.0.0 due to NullPointerException thrown by PdfDocument

當我嘗試在此鏈接http://www.health.state.mn.us/divs/hpsc/hep/merc/ctfapp2015b.pdf 上使用 itext 打開 pdf 時,我得到一個 NullPointerException 和以下堆棧跟蹤:

NullPointerException   com.itextpdf.kernel.pdf.tagging.ParentTreeHandler.registerMcr (ParentTreeHandler.java:154)
java.lang.NullPointerException
    at com.itextpdf.kernel.pdf.tagging.ParentTreeHandler.registerMcr(ParentTreeHandler.java:154)
    at com.itextpdf.kernel.pdf.tagging.ParentTreeHandler.registerAllMcrs(ParentTreeHandler.java:246)
    at com.itextpdf.kernel.pdf.tagging.ParentTreeHandler.<init>(ParentTreeHandler.java:101)
    at com.itextpdf.kernel.pdf.tagging.PdfStructTreeRoot.<init>(PdfStructTreeRoot.java:78)
    at com.itextpdf.kernel.pdf.PdfDocument.open(PdfDocument.java:1299)
    at com.itextpdf.kernel.pdf.PdfDocument.<init>(PdfDocument.java:199)

我的代碼很簡單:

(new PdfDocument(new PdfReader "blah.pdf"));

這個PDF有什么問題嗎? 是否需要傳遞某些類型的標志才能打開它?

編輯:使用 iText 7.0.0 時會發生這種情況。

您的文檔具有損壞的結構樹或標簽樹。 您還可以檢查打開標簽時 Acrobat(或任何其他 PDF 查看器)顯示的內容。 當您單擊一個標簽時,閱讀器無法找到與該標簽對應的內容。

我不認為你將能夠在 iText 7.0.0 中毫無例外地打開這個文檔,但是這個問題已經修復了(現在只打印記錄器錯誤並且沒有拋出異常),並且修復將在 7.0.1 中可用. 或者,如果您需要盡快修復,您可以查看當前的快照版本。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM