HTML JPG PDF XML DOCX
  Product Family
PDF

Decrypt PDF via .NET SDK

API for decrypting PDF documents using Aspose.PDF Cloud .NET SDK

Get Started

How to decrypt PDF via Cloud .NET SDK

For decrypt PDF documents, we’ll use Aspose.PDF Cloud .NET SDK This Cloud SDK assists .NET programmers in developing cloud-based PDF creator, annotator, editor, and converter apps using C#, ASP.NET, or other .NET languages for various cloud platforms.Open NuGet package manager, search for Aspose.PDF Cloud and install. You may also use the following command from the Package Manager Console.

Package Manager Console Command


     
    PM> Install-Package Aspose.Pdf-Cloud
     

Steps to decrypt PDF via .NET

Aspose.PDF Cloud developers can easily load & decrypt PDF in just a few lines of code.

  1. Create a new Configuration object with your Application Secret and Key
  2. Create an object to connect to the Cloud API
  3. Upload your encrypted document file
  4. Call API to Decrypt Pdf document.
  5. Checks the response and logs the result.
  6. Downloads the updated file for local use.
 

Decrypt PDF using Cloud .NET SDK


    using Aspose.Pdf.Cloud.Sdk.Api;
    using Aspose.Pdf.Cloud.Sdk.Model;

    namespace EncryptDecrypt
    {
        public class DecryptPdf
        {
            private string ToBase64(string str)
            { // Convert string to Base64. 
                var bytes = Encoding.UTF8.GetBytes(str);
                return Convert.ToBase64String(bytes);
            }

            public static async Task Decrypt(string documentName, string outputName, staring localFolder, string remoteFolder)
            {
                // Get your AppSid and AppSecret from https://dashboard.aspose.cloud (free registration required). 
		pdfApi = new PdfApi(AppSecret, AppSid);

                using (var file = File.OpenRead(Path.Combine(localFolder, documentName)))
		{ // Upload the local encrypted PDF to cloud storage folder name.
                    FilesUploadResult uploadResponse = await pdfApi.UploadFileAsync(Path.Combine(remoteFolder, documentName), documentName);
                    Console.WriteLine(uploadResponse.Uploaded[0]);
                }

                string ownerPassword = "Owner-Password";

                // Decrypt the PDF on cloud storage.
                AsposeResponse response = await pdfApi.PostDecryptDocumentInStorageAsync(
                    documentName,
                    ToBase64(ownerPassword),
                    folder: remoteFolder);

                // Checks the response and logs the result.
                if (response == null)
                    Console.WriteLine("DecryptPdf(): Unexpected error!");
                else if (response.Code < 200 || response.Code > 299)
                    Console.WriteLine("DecryptPdf(): Failed to decrypt document.");
                else
                {  // Downloads the updated file for local use.
                    Console.WriteLine("DecryptPdf(): document '{0} successfully decrypted.", documentName);
                    Stream stream = pdfApi.DownloadFile(Path.Combine(remoteFolder, documentName));
                    using var fileStream = File.Create(Path.Combine(localFolder, "decrypt_" + outputName));
                    stream.Position = 0;
                    await stream.CopyToAsync(fileStream);
                    Console.WriteLine("EncryptPdf(): File '{0}' successfully downloaded.", "decrypt_" + outputName);
               }
            }
        }
    }
 

Decrypt PDF

Decrypting a PDF document is crucial when access to its contents is restricted due to encryption. It allows authorized users to regain full control over the file, enabling editing, viewing, and content extraction. This process is especially important in workflows where secure documents must be accessed programmatically or integrated into larger systems.

Using tools like Aspose.PDF Cloud, decryption can be performed easily and securely with just the correct owner or user password. This ensures sensitive information remains protected while still allowing flexibility for those who need legitimate access.

Ultimately, decrypting a PDF enables smooth document handling and reinforces the importance of strong yet manageable document security practices. Decrypt PDF documents with Aspose.PDF Cloud .NET SDK.

With our .NET library you can:

  • Add PDF document’s header & footer in text or image format.
  • Add tables & text or image stamps to PDF documents.
  • Append multiple PDF documents to an existing file.
  • Work with PDF attachments, annotations, & form fields.
  • Apply encryption or decryption to PDF documents & set a password.
  • Delete all stamps & tables from a page or entire PDF document.
  • Delete a specific stamp or table from the PDF document by its ID.
  • Replace single or multiple instances of text on a PDF page or from the entire document.
  • Extensive support for converting PDF documents to various other file formats.
  • Extract various elements of PDF files & make PDF documents optimized.
  • You can try out our free Apps to test the functionality online.

  •