Removing document restrictions in PDF

The PDF Creator enables you to create secure PDF documents and to view, print and process existing PDF documents.
If you have any questions about the installation and usage of the PDF Creator please post them here.
Post Reply
anshuman82
Posts: 21
Joined: Mon Feb 12 2007
Contact:

Removing document restrictions in PDF

Post by anshuman82 »

Hi,

I have a PDF file which has following security document restrictions like
1.Changing the document
2.Document Assembly
Creation of Document Assembly

How can remove these document restrictions in PDF using PDFCreator Active X.

Regds
Anshuman
Anshuman
Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan »

Hello,

You can open the file in the PDF Creator using the owner password and set/unset document restrictions.

Hopet his helps.
anshuman82
Posts: 21
Joined: Mon Feb 12 2007
Contact:

Removing document restrictions in PDF

Post by anshuman82 »

Hi Joan,

Thanks for reply.
I am using the below code for making a pdf a password protected file unprotected and removing the document restrictions as well.But the code is not working and file is not getting unprotected.. Could you please suggest what is wrong with code and how we can achieve the functionality?


acPDFCreatorLib.Initialize();
acPDFCreatorLib.SetLicenseKey("", "");
// Open a PDF document from file
string NewfileName = "ABC.pdf";

System.IO.FileStream file1 = new System.IO.FileStream(NewfileName, FileMode.Open, FileAccess.ReadWrite,
FileShare.ReadWrite);
using (IacDocument document = new IacDocument(null))
{
document.Open(file1, "pqr");

//Trying to assign empty user and owner passwords and setting no restrictions
document.Encrypt128("", "", 0);

// save modified document to a new file
Random number = new Random();
System.IO.FileStream file2 = new System.IO.FileStream(@"File_mod" + number.Next().ToString() + ".pdf", FileMode.CreateNew, FileAccess.Write,FileShare.Read);
document.Save(file2, IacFileSaveOption.acFileSaveAll); // save modified document
}
// terminate library to free resources
acPDFCreatorLib.Terminate();
Anshuman
Jose
Amyuni Team
Posts: 553
Joined: Tue Oct 01 2002
Contact:

Post by Jose »

Hello,

The remove or edit document security from a PDF document you will need to first open the document with the “owner” password.

Hope this helps?
anshuman82
Posts: 21
Joined: Mon Feb 12 2007
Contact:

Removing document restrictions in PDF

Post by anshuman82 »

Hi Joan,

As I explained in the code previous posts

I am opening the PDF with owner Id like

document.Open(file1, "pqr");

and then I am trying to assign empty user and owner passwords and set no restrictions
document.Encrypt128("", "", 0);

Please let me know what is wrong here or what else needs to be done :(

Regards
Anshuman
Anshuman
anshuman82
Posts: 21
Joined: Mon Feb 12 2007
Contact:

Removing document restrictions in PDF

Post by anshuman82 »

Hi,

I have owner password of a PDF file and I am trying to make this file non password protected and remove document restrictions on it.

Please let me know what is wrong in the code explained in previous posts or please share a sample code which achieve the requirements as I explained above.

Thanks
Anshuman
Anshuman
Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan »

Hello,

Please find here a VB code that opens an Encrypted pdf file and remove restrictions and passwords.

Hope this helps.

Code: Select all

Private Sub Decrypt_Click()

On Error GoTo report_error
    
    With CreatorRef

        ' Open a pdf file and remove passwords
        .SetLicenseKey Licensee, ActivationCode
        .Open App.Path & "Encrypt128.pdf", "owner"
        .Encrypt "", "", -60
        .Save App.Path & "\EncryptNoPassword.pdf", 0


MsgBox "Done"
        
   End With
   Exit Sub
   
report_error:
   MsgBox Err.Description
   MsgBox Err.Source

End Sub
Post Reply