views:

640

answers:

3

I have a fillable, saveable PDF file that has an owner password (that I don't have access to). I can fill it out in Adobe reader, export the FDF file, modify the FDF file, and then import it.

Then I tried to do it with iText(Sharp). I can't create a PdfStamper from my PdfReader because I didn't provide the owner password to the reader. Is there any way to do this programmatically or must I recreate the document? Even using FdfReader requires a PdfStamper. Am I missing anything? Anything legal that is - I'm pretty sure I could hack the document, but I can't. Ironically, recreating it would probably be ok.

A: 

Unless someone else chimes in, I'll assume the answer is "No"

I wound up regenerating the PDF in an unencrypted form.

CMPalmer
Why do you have 2 logins?
Aaron Smith
I posted the question from a customer site using my iPhone and I was in too big of a hurry (or too lazy) to authenticate via OpenID, so I just posted anonymously then forgot to set it to community wiki.
CMPalmer
+1  A: 

[I found this question several months after it was posted and I'm posting this solution now for anyone who comes across this question in a search.]

I was in the exact same situation: my customer had a PDF with fillable fields that I needed to programmatically access. Unfortunately the PDF was password protected and they didn't have the password so I found couldn't work with their file.

What I discovered was that iTextSharp version 4.0.4 (and later) enforces password restrictions, earlier versions did not. Check out this iText mailing list archive thread, and the response from Paulo Soares (one of the iTextSharp developers).

So I downloaded version 4.0.3 and sure enough it worked. In my case I didn't even have to change my code to use this older version.

You can download 4.0.3 (and all other versions) at SourceForge.

Jay Riggs
A: 

Hello i downloaded itextsharp's latest version 5.0.2 anfd tried running the code without any change. i got an exception "Bad password exception PdfReader not opened with owner password" at the line below

stamper = New iTextSharp.text.pdf.PdfStamper(reader, New System.IO.FileStream(outputFile, IO.FileMode.Create))

i am the owner i know the password i have to use it in coding

wat to do ?

Are you using the Open password or the Owner password. If you created the PDF with an "open" but no "owner", then you cannot make changes with iText at this time. You need to rebuild the PDF with either "no passwords" or "both open and owner passwords", then open it with the "owner" to make changes.
Mark Storer