This tutorial explains how to change PDF password using C# REST API. You will learn to automatically reset PDF password using C# Low Code API with the help of a .NET-Cloud SDK. This process requires existing password and new passwords.
Prerequisite
- Create an account API credentials to change the password
- Download Aspose.PDF Cloud SDK for Dotnet for changing the password in a PDF document
- Setup a C# project with the above SDK
Steps to Change Password of PDF using C# REST Interface
- Import the required classes from the API for changing the password
- Create the PdfApi object by passing the secret key and ID of the user
- Read the source PDF file into a memory stream and upload to the Cloud storage
- Create Base64String for old password, new user password, and new owner password
- Call the PostChangePasswordDocumentInStorage to change the password by passing the necessary arguments
- Call the DownloadFile() method to download the PDF file with new passwords
- Save the returned stream as a PDF file on the local storage
These steps explain how to change PDF password online using C# .NET-based API. Import the necessary classes, create a function to transform strings to base 64 strings, read and load the source PDF file, upload it to the Cloud storage, and generate base 64 strings for old password, new user password, and new owner password. Call the PostChangePasswordDocumentInStorage() by passing the file name in the Cloud storage, current password, new user password, new owner password, and save the resultant stream from the API call on the disk as a PDF file.
Code to Change Password of PDF File using C# RESTful Service
Use the above code to change password on Adobe PDF using C# REST API. The input PDF file should be password-protected, and you should know the existing password. If you don’t know the password, this code will not work.
This article has taught us the process to change a PDF password online. To decrypt an encrypted PDF file, refer to the article Decrypt PDF using C# REST API.