We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Error for Encrypted File - Invalid pdf format:pdf head signature is not found


When I tried for Building form of already encrypted file it throws error

The code is following

1st Take 1 method which will return me InputStream

PdfFileSecurity sec = new PdfFileSecurity(pdfInputStream, pdfOutputStream);

asposeResponse = sec.DecryptFile(permissionPassword);


return pdfOutputStream;

Than used that stream to make form using,

Form pdfForm = new Form(pdfFileStream, pdfOutputFileStream);

Here it throws error "Invalid pdf format:pdf head signature is not found"

Please Help me out



Please call the statement pdfFileStream.Seak(0, SeekOrigin.Begin) before passing it to the Form constructor.


Thanks, Its working ,

Can you please describe me why we have to use this method



It is because the DecryptFile method doesn't reset the stream pointer to the begining and when Form class tries to read from the same stream it is already at the end and thinks that the file is corrupt.