How can I validate if a stream is a valid pdf document?

Hello,

So, are there any methods that can validate if a stream is a valid pdf document? With Aspose.Words I can use the method DetectFileFormat() and catch the UnsupportedFileFormatException when I instantiate the Document class to verify if a stream is a valid word document. And with Aspose.Pdf.Kit, is there something like that?

Thank you!

Regards,

André

Hi André,

If you want to know whether the input file stream is in a valid PDF file format, then you can capture the IOException in your code. When the input file is not in a valid format, you’ll receive the following message:

"Invalid pdf format:pdf head signature is not found!: v3.5.0.0"

However, I’m afraid that there is no exception class defined for this purpose in the current version of Aspose.Pdf.Kit.

If you have any further questions, please do let us know.

Regards,


Hello,

Thank you very much for the solution!

Regads,

André