App crashes due to stack overflow when creating a TextBuilder object (malformed PDF)

Dear support team,

We were faced with the case when our application crashes when the user uploading a malformed PDF. The issue could be easily reproduced on both versions 11.3.0 (our licensed version) and 20.8.0.0 (most recent, trial).

This is a pretty critical issue for us - the whole app crashes with Stack Overflow (this kind of exception couldn’t be workarounded with try-catch ) and we were not able to find a way to identify such kind of issues in advance and prevent the processing of such PDFs.

Code sample:
Document pdfDocument = new Document(“document.pdf”);
TextBuilder builder = new TextBuilder(pdfDocument.Pages[1]);

Document to process:
document.pdf (47.5 KB)

We know that 11.3.0 is out of support now, but it would be great if can provide us with a way to identify that this document shouldn’t be processed (by validating some properties/collections/whatever).

Best regards,
Maksym Rusin

@mmrusin

We need to investigate and implement new type of exception in the API to handle such kind of invalid PDF files. For the sake of implementation, we have logged a ticket as PDFNET-48757 in our issue tracking system. We will further look into its details and keep you informed with its resolution status. Please be patient and spare us some time.

We apologize for the inconvenience.