The attached file is a PDF created by SnagIt, a screen capture tool that can export to PDFs. It has invalid creation date and modified date properties - they are both set to an empty string, which is not an invalid date. This isn’t the only tool we’ve found that sets those dates using empty strings.
The problem we’re having is that Aspose.Pdf doesn’t handle those fields being empty strings very well. If you open the document using Aspose and try to access the Document.Info.CreatedDate or Document.Info.ModDate properties, an exception is thrown (Aspose.Pdf.Exceptions.InvalidValueFormatException) when it tries to parse the empty strings. This happens whether you’re setting or getting the property.
The obvious workaround is to work with the properties directly, which is what we’ve been doing, but is there any way to make it so those properties don’t throw exceptions just because someone stored an empty string where there should be a date string? The format a string needs to be in for a PDF date isn’t one of the standard types provided by the .NET date formatter, so you have to do it yourself, which works but is annoying to have to support. If in place of an empty string, or even a poorly formatted string, it could simply return a null value or Date.MinValue or something, it’d make handling these situations easier. For instance, it’d be nice to still be able to set the CreatedDate property to a valid date even if its current value isn’t valid, but instead you have to use the Item property and the text index “CreationDate” to access it, after formatting the date properly yourself.
This one is easily worked around, so it’s not that big of a deal, but if the handling of invalid date strings could be improved, it would make life a bit better for me and my clients.
Thanks,
Michael Whalen
Hi Michael,
I’d also be interested in a fix for this issue as it is stopping us upgrading our version of Aspose.pdf
Hi Martin,
We see a similar issue however we are not creating the PDFs but are using PDFs created by other sources.
Hi Kim,Freedom Solutions:
We see a similar issue however we are not creating the PDFs but are using PDFs created by other sources.
Attaching sample file
Hi Kim,
The issues you have found earlier (filed as PDFNET-40499) have been fixed in Aspose.PDF for .NET 25.6.