.NET IOException (Invalid pdf format) raised by PdfFileSecurity instance


#1

I have a set of .pdf files that were created for me by a third party and I would like to concatenate a subset of those files into a single .pdf file (based on user input), then set the permissions to disallow editing the document. I'm using VB.NET.

I am able to concatenate the .pdf files (as MemoryStreams) in one MemoryStream. (And I'm able to write this resulting stream to Response.OutputStream and it works as expected.) However, when I initialize a new PdfFileSecurity instance with that resulting MemoryStream and try to execute any method (eg. ChangePassword() or SetPriviledge()), I get the following IOException:

Invalid pdf format:pdf head signature is not found!


Could the individual .pdf files be missing some necessary information? Or is some header information lost in the concatenation that I need to add back to the file?

Thanks in advance for your help.


#2

Dear sthomas,

Thanks for considering Aspose.

Please reset the position at the begining of the result stream concatenated by many pdfs after concatenated like the following:

pdfStream.Position = 0

Any more question is welcome.

Best regards.