Free Support Forum -

Problem in reading Password protected pdf file

Hi All,

I am using Aspose.Pdf.Kit [Runtime version - v1.1.4322 and Version -] for reading PDF files. I am facing some problems while trying to read a password protected PDF file.

I have 4 types of files-

1. Files with only document open password. *

2. Files with document open password and Permission password.

3. Files with only permission password.

4. Files with no password.

The code which I am using is reading the all type of files successfully, except the first type * [Files with only document open password]. I am getting this error when trying to read the first type of file - "{System.IO.IOException: Invalid pdf format:pdf head signature is not found!
at வ.Ꭲ.Ꮍ()
at வ.೐.ച()
at வ.೐..ctor(Stream is_Renamed, SByte[] ownerPassword)
at வ.೐..ctor(Stream is_Renamed)
at Aspose.Pdf.Kit.Form.ᾓ()
at Aspose.Pdf.Kit.Form..ctor(Stream srcStream)

My code look like the below code -

System.IO.FileStream pdfInputStream = null;

System.IO.MemoryStream pdfOutputStream = null;

string inputFileName="abc.pdf";

string deryptionPassword="1234";

pdfInputStream = new FileStream(inputFileName, FileMode.Open, FileAccess.Read);

pdfOutputStream = new MemoryStream(System.Convert.ToInt32(pdfInputStream.Length));

PdfFileSecurity oPdfFileSecurity = new PdfFileSecurity(pdfInputStream, pdfOutputStream);


Aspose.Pdf.Kit.Form pdfform = new Aspose.Pdf.Kit.Form(pdfOutputStream);

foreach (string fieldName in pdfform.FieldsNames)



The code is throwing the above described error on grey colored line("Aspose.Pdf.Kit.Form pdfform = new Aspose.Pdf.Kit.Form(pdfOutputStream);"), its not throwing this error with other types of files except the first type of file. Please tell me, where I am wrong? Any pointer would be helpfull.

Thanks in advance,

- Anand

Hi Anand,

Are you using the latest version of Aspose.Pdf.Kit? If not, please download Aspose.Pdf.Kit for .NET

If problem persists, then please share the problematic PDF with us, so we could into the matter in detail.

We’re sorry for the inconvenience.