How to Encrypt PDF Files

PDF files have become as commonplace as MS office files. Sometimes sensitive information is on these files and one needs to be able to protect the files from unauthorized users. Read on to find out how to encrypt PDF files in adobe acrobat.

Encrypt PDF Files via Adobe Acrobat

  • First run Adobe Acrobat.
  • Now go to the menu bar and select “Document”.
  • Go down to the security option near the bottom in the “Document” drop down menu and select the “Restrict opening & Editing” option.
  • A new window should pop-up on your screen with the title “Password Security – Settings”. You will be able to choose the compatibility settings (meaning which versions of acrobat can access the PDF file. I chose Adobe acrobat 5.0 and higher.
  •  Next you will click on the box next to “Require password to open the document”. You will now be able to enter your personal password for the PDF file.
  • Once you have created your password click on “Ok” at the bottom. Adobe acrobat will now prompt you to confirm the password by typing it again.
  • Now that you confirmed your password, you will need to save your document for the password settings to initialize.
  • Go to the menu bar under “File” and select the save option of simply hit Ctrl & S.
  •   After saving close the PDF file and open it again adobe should prompt you for a password.
  •  PDF FILES ARE NOW SECURE!!

C# Encrypt PDF Files

If you are a programmer and don’t want to install Adobe Acrobat. PDF component is a good choice for you. Recommend you a good PDF component  – Spire.PDF, a professional PDF component which can help you easily encrypt PDF files.

  • Free Download Spire.PDF for .NET (Free Register before Download)
  • Install Spire.PDF for .NET and create a project in Visual Studio.
  • Copy the demo C# code below into the project to encrypt any PDF files:
  • After finish writing code, press F5 to start project.
Note: Before encrypt PDF files, please make sure Spire.PDF and Visual Studio are correctly installed on your system

C# Code:

       static void Main(string[] args)
             {
	    //Create a pdf document.
	    PdfDocument doc = new PdfDocument();

	    // Create one page
	    PdfPageBase page = doc.Pages.Add();

	    //Draw the page
	    DrawPage(page);

	    //encrypt
	    doc.Security.KeySize = PdfEncryptionKeySize.Key128Bit;
	    doc.Security.OwnerPassword = "e-iceblue";
	    doc.Security.UserPassword = "test";
	    doc.Security.Permissions = PdfPermissionsFlags.Print | PdfPermissionsFlags.FillFields;

	    //Save pdf file.
	    doc.SaveToFile("Encryption.pdf");
	    doc.Close();

	    //Launching the Pdf file.
	     System.Diagnostics.Process.Start("Encryption.pdf");
	 }

Full Code Here

Effect Screenshot:

 

Spire.PDF Function Details:

Leave a Reply