Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to remove restrictions for a secured PDF..? C#

    • 1
    • 0
    • 0
    • 2
    • 0
    • 0
    • 0
    • 4.19k
    Answer it

    Hi guys, How to allow copy content option for a secured PDF. Currently am using Spire.PDF library, it is giving result as I except, it is a free version supports only for below 10 page PDFs, but my pdfs have more than 200 pages. Any other solutions?, also worked with PdfSharp library, it is not supporting Adobe 6 featured pdfs. Googled many times, but still am not getting solutions for this..

    here is code for Spire.PDF

    string input = @"C:\xxxx\2006-Catalog.pdf";
    string output = @"C:\xxxx\Unlocked-2006-Catalog.pdf ";
    PdfDocument doc = new PdfDocument();
    doc.LoadFromFile(input);
    doc.Security.ResetPermissions(Spire.Pdf.Security.PdfPermissionsFlags.AccessibilityCopyContent);
    doc.SaveToFile(output);
    Console.WriteLine("Done");
    

 2 Answer(s)

  • Hi,

    The password of secured PDF is mandatory to copy its content. You can open PDF file by this method: Spire.Pdf.PdfDocument(string filename, string password) Then, modify passwords by resetting owner password and user password as empty. Below shows the whole code of modifying passwords of secured PDF file,

     //load a encrypted file and decrypt it
     string input = @"C:\xxxx\2006-Catalog.pdf";
     string output = @"C:\xxxx\Unlocked-2006-Catalog.pdf ";
     PdfDocument doc = new PdfDocument(input, "password");
    
     //reset PDF passwords and set user password permission
     doc.Security.OwnerPassword = "";
     doc.Security.UserPassword = "";
     doc.Security.Permissions = PdfPermissionsFlags.Print | PdfPermissionsFlags.FillFields;
    
     //Save pdf file.
     doc.SaveToFile(output);
     doc.Close();
    

    if you find the answer helpful please mark it correct, so that, other developmentnt community can take advantage.

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: