Clearer exception messages when Outline Dictionaries break PDF specification rules
In the past iText threw generic exceptions when a PDF's Outline Dictionary violated the PDF specification. We've added some additional checks to our library in order to improve our logging in these cases.
Instead of throwing generic Java or .NET exceptions we now throw specific PdfExceptions
. This makes it easier for our users to understand the issue, as well as to filter out PDFs with such issues.
For example; instead of throwing a generic java.lang.NullPointerException
or System.
NullReferenceException
we now throw:
com.itextpdf.kernel.PdfException: Document outline is corrupted: some outline (PDF object: "6 0 R Modified;") lacks the required parent entry.
com.itextpdf.kernel.PdfException: Document outline is corrupted: some outline (PDF object: "6 0 R Modified;") lacks the required title entry.
This makes it possible to catch these specific problems in code and either repair the document, or reject it as input.