Remove password from the encrypted PDF document

With Spire.PDF for .NET, we can easily set the password to encrypt the PDF document by password. We can also use Spire.PDF to remove the password from the encrypted PDF document in C# and VB.NET. We need to load the encrypted PDF file with password by calling the method PdfDocument.LoadFromFile (string filename, string password) and then set the password as empty to remove the password.

Firstly, view the PDF with user password:

Remove password from the encrypted PDF document

Step 1: Load the password protected PDF document.

PdfDocument pdf = new PdfDocument();
pdf.LoadFromFile("Sample.pdf", "e-iceblue");

Step 2: Set the password as empty to remove the user password.

pdf.Security.UserPassword = string.Empty;

Step 3: Save the document to file.

pdf.SaveToFile("Decrypted.pdf");

Effective screenshot after removing the password from the PDF document:

Remove password from the encrypted PDF document

Full codes:

[C#]
using Spire.Pdf;

namespace RemovePassword
{
    class Program
    {
        static void Main(string[] args)
        {
            PdfDocument pdf = new PdfDocument();
            pdf.LoadFromFile("Sample.pdf", "e-iceblue");

            pdf.Security.UserPassword = string.Empty;

            pdf.SaveToFile("Decrypted.pdf");
        }
    }
}
[VB.NET]
Imports Spire.Pdf

Namespace RemovePassword
	Class Program
		Private Shared Sub Main(args As String())
			Dim pdf As New PdfDocument()
pdf.LoadFromFile("Sample.pdf", "e-iceblue")
pdf.Security.UserPassword = String.Empty
pdf.SaveToFile("Decrypted.pdf")
		End Sub
	End Class
End Namespace