PdfPig icon indicating copy to clipboard operation
PdfPig copied to clipboard

Object reference not set to an instance of an object in UglyToad.PdfPig.Parser.DocumentInformationFactory.Create

Open cysieks opened this issue 4 years ago • 2 comments

I have PDF file that is failing in UglyToad.PdfPig.Parser.DocumentInformationFactory.Create method, because "token" is null.

What is the reason to throw exception in this case? throw new PdfDocumentFormatException($"Unknown document information token was found {token?.GetType()?.Name}");

I think it could be better to just replace it with return DocumentInformation.Default;

Which I did in my local test, and the file was opened correctly. Version 0.1.5-alpha002

In version 0.1.4 it was failling in UglyToad.PdfPig.Parser.DocumentInformationFactory.GetEntryOrDefault

Thanks in advance

cysieks avatar Jun 02 '21 10:06 cysieks

Hi @cysieks am I understanding correctly that you no longer get this null reference exception when using version 0.1.5-alpha002?

EliotJones avatar Jun 10 '21 20:06 EliotJones

Sorry, my writing was misleading. This happens in version Version 0.1.5-alpha002.

In version 0.1.4 exception is raised in UglyToad.PdfPig.Parser.DocumentInformationFactory.GetEntryOrDefault

The problem was resolved, when I locally build the library, replacing line with exception throw new PdfDocumentFormatException($"Unknown document information token was found {token?.GetType()?.Name}"); to return DocumentInformation.Default;

cysieks avatar Jun 11 '21 07:06 cysieks