Articles in this section

How to Remove Password in Protected WinForms PDF Using C# and VB.NET?

Syncfusion Essential PDF is a .NET PDF library used to create, read, and edit PDF documents. Using this library, you can remove a password from an encrypted PDF document using C# and VB.NET.

Steps to remove a password from a protected PDF programmatically:

  1. Create a new C# console application project. Create a console application project in WinForms PDF
  2. Install the Syncfusion.Pdf.WinForms NuGet package as reference to your .NET Framework application from NuGet.org. NuGet package reference in WinForms PDF
  3. Include the following namespaces in Program.cs file.

C#

using Syncfusion.Pdf.Parsing;

 

VB.NET

Imports Syncfusion.Pdf.Parsing

 

  1. Use the following code snippet to hide the signature field in a PDF document.

C#

// Load the password-protected PDF document
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("ProtectedDocument.pdf", "password");
// Setting permission flags to default
loadedDocument.Security.Permissions = PdfPermissionsFlags.Default;
// Change the user and owner passwords
loadedDocument.Security.UserPassword = string.Empty;
loadedDocument.Security.OwnerPassword = string.Empty;
// Save the password-removed PDF document
loadedDocument.Save("Output.pdf");
loadedDocument.Close(true);
// This will open the PDF file so the result will be seen in the default PDF Viewer
Process.Start("Output.pdf");

VB.NET

' Load the password-protected PDF document
Dim loadedDocument As New PdfLoadedDocument("ProtectedDocument.pdf", "password")
' Setting permission flags to default
loadedDocument.Security.Permissions = PdfPermissionsFlags.Default
' Change the user and owner passwords
loadedDocument.Security.UserPassword = String.Empty
loadedDocument.Security.OwnerPassword = String.Empty
' Save the password-removed PDF document
loadedDocument.Save("Output.pdf")
loadedDocument.Close(True)
' This will open the PDF file so the result will be seen in the default PDF Viewer
Process.Start("Output.pdf")
Note:

To remove only the open password in a protected PDF document, just empty the user password.

By executing the program, you will get the password-removed PDF document as follows. Output document screenshot in WinForms PDF

A complete working sample can be downloaded from RemovePasswordSample.zip.

Take a moment to peruse the documentation, where you can find other options like encrypt PDF document, protect an existing PDF document, changing the password of the PDF document, change the permission of the PDF document and features like digitally sign a PDF document and redaction with code examples.

Refer here to learn more about PDF encryption and decryption.

Note:

Starting with v16.2.0.x, if you reference Syncfusion® assemblies from the trial setup or the NuGet feed, include a license key in your projects. Refer to the link to learn about generating and registering the Syncfusion® license key in your application to use the components without a trial message.


Conclusion:

I hope you enjoyed learning about how to Remove Password in Protected WinForms PDF Using C# and VB.NET.

 

You can refer to our  .NET PDF library feature tour page to learn about its other groundbreaking features and documentation, and how to quickly get started with configuration specifications.For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to explore our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied