I have a third-party PDF file with some form fields, that I need to fill out programmatically. PDF file is secured. Detailed security settings: SecurityMethod: Password Security, Document Open Password: No, ... Form Field Fill-in or Signing: Allowed...
When I'm trying to open and fill out the document manually, everything is ok, and I'm not asked for any password. But with the code, it fails with exception.
Here's the code (I'm using iTextSharp library):
var str = new MemoryStream();
var reader = new PdfReader(_path);
var stamper = new PdfStamper(reader, str);
Creating the PdfStamper object fails with exception: BadPasswordException. PdfReader not opened with owner password.
Any ideas, why it fails with code, but not manually? Thanks in advance.
Have you tried adding
PdfReader.unethicalreading = true;
before your reader
initialization?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With