Free Support Forum -

Pdf stream validation


i need to test if a pdf stream is a valid pdf document.

I created a Aspose.Pdf.Pdf instance by the Aspose.Pdf.Pdf(stream) constructor.

I hoped to receive an exception in case of an invalid pdf stream, but nothing.

It always loads both valid and fake pdf streams.

How can i do? Please help me.

I wrote this c# code:

public bool VerifyPdf(byte[] pdfContent)
if (pdfContent == null) return false;

	using (MemoryStream ms = new MemoryStream((pdfContent))
		Aspose.Pdf.Pdf pdf = new Aspose.Pdf.Pdf(ms);
		return true;
catch (Exception ex)
	string exception = ex.Message;

return false;



Thank you very much for considering Aspose.

I would like to share with you that Aspose.Pdf only allows you to create PDF files from scratch; it doesn’t allow you to validate existing PDF files. If you want to validate a PDF file then you’ll have to use Aspose.Pdf.Kit. And you can use BePdfFile property of the PdfFileInfo class for that matter.

I hope this helps. If you have any further questions, please do let us know.

Hi,thank you for your reply, even if it isn't the answer i desired to receive.

I bought Aspose.Pdf with the scope of both creating new Pdf "on the fly" and manipulating existing Pdf files, but know i'm a little confused: i'm not sure i choosen the right version of Aspose.Pdf product.

Currently i created a Pdf on the fly by loading an XML template and filling informations runtime, and this works fine. Next step will be:

1) create a Pdf index

2) insert into main Pdf other Pdf as attachments

3) insert into main Pdf other non Pdf attachments

4) manipulating existing Pdf files

What do you think about?

Thank you very much


As I shared earlier, currently we have two components to work with PDF files. Aspose.Pdf allows to create new PDF files and Aspose.Pdf.Kit allows to manipulate existing PDF files. However, we’re working on a merged version, which will be available at the start of June 2011. You may check the related blog posts on this link.

According to the current situation, you have correctly used Aspose.Pdf to create PDF file from XML template. However, in order to manipulate the PDF, you’ll have to use Aspose.Pdf.Kit. Please elaborate how exactly you want to manipulate the existing PDF files, so we could guide you accordingly.

We’re looking forward to help you out.