PdfReader not opened with owner password error in iText

34,510

Solution 1

Add this code after PdfReader definition

PdfReader.unethicalreading = true;

Solution 2

For iText 7 it is

PdfReader pdfReader = new PdfReader(PATH + name + ".pdf");
pdfReader.setUnethicalReading(true);

See also: itext7-how-decrypt-pdf-document-owner-password

Share:
34,510
Ankur
Author by

Ankur

Updated on July 09, 2022

Comments

  • Ankur
    Ankur almost 2 years

    With reference to this

    http://stackoverflow.com/questions/17524857/merging-pdf-in-asp-net-c-sharp/17525948?noredirect=1#comment25485091_17525948 
    

    question of mine, I have user IText for merging the pdf documents. I am getting " PdfReader not opened with owner password " for some files. Any suggestions

  • Pradeep
    Pradeep over 8 years
    Thanks! Worked like a charm Not sure why it would be unethical to open a file via iTextSharp if I can open it otherwise without any warning or issues :)
  • 321X
    321X almost 3 years
    Don't forget that the PdfReader is disposable and it should be disposed afterwards or use the using statement