Change PDF Password using C# REST API

This step‑by‑step guide shows you how to change a PDF password using the C# REST API. By using the .NET‑Cloud SDK, you’ll be able to reset PDF passwords automatically with the C# Low Code API, requiring only the existing password and the new password(s).

Prerequisite

Steps to Change Password of PDF using C# REST Interface

  1. Import the required classes from the API for changing the password
  2. Create the PdfApi object by passing the secret key and ID of the user
  3. Read the source PDF file into a memory stream and upload to the Cloud storage
  4. Create Base64String for old password, new user password, and new owner password
  5. Call the PostChangePasswordDocumentInStorage to change the password by passing the necessary arguments
  6. Call the DownloadFile() method to download the PDF file with new passwords
  7. 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

Simply run the snippet above to change the password of an Adobe PDF using the C# REST API. Just remember that the source file must already be encrypted and you must supply its existing password—without it, the code won’t work.

In this guide we’ve walked through how to change a PDF password online using our C# REST API. If you also need to remove encryption from a protected PDF, see the article Decrypt PDF using C# REST API.