Remove Protection
Remove password security from a PDF document. This can only be accomplished with the owner password of the document which must be passed in the operation.
Rest API
See our public API Reference for Remove Protection
Remove security from PDFs
Use the below sample to remove security from a PDF document.
Please refer the API usage guide to understand how to use our APIs.
Java
.NET
Node JS
Rest API
Copied to your clipboard1// Get the samples from https://www.adobe.com/go/pdftoolsapi_java_samples2// Run the sample:3// mvn -f pom.xml exec:java -Dexec.mainClass=com.adobe.pdfservices.operation.samples.removeprotection.RemoveProtection45 public class RemoveProtection {67 // Initialize the logger.8 private static final Logger LOGGER = LoggerFactory.getLogger(RemoveProtection.class);910 public static void main(String[] args) {11 try {12 // Initial setup, create credentials instance.13 Credentials credentials = Credentials.servicePrincipalCredentialsBuilder()14 .withClientId("PDF_SERVICES_CLIENT_ID")15 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")16 .build();1718 // Create an ExecutionContext using credentials and create a new operation instance.19 ExecutionContext executionContext = ExecutionContext.create(credentials);20 RemoveProtectionOperation removeProtectionOperation = RemoveProtectionOperation.createNew();2122 // Set operation input from a source file.23 FileRef source = FileRef.createFromLocalFile("src/main/resources/removeProtectionInput.pdf");24 removeProtectionOperation.setInput(source);2526 // Set the password for removing security from a PDF document.27 removeProtectionOperation.setPassword("password");2829 // Execute the operation.30 FileRef result = removeProtectionOperation.execute(executionContext);3132 // Save the result to the specified location.33 result.saveAs("output/removeProtectionOutput.pdf");3435 } catch (IOException | ServiceApiException | SdkException | ServiceUsageException e) {36 LOGGER.error("Exception encountered while executing operation", e);37 }38 }39 }
Copied to your clipboard1// Get the samples from https://www.adobe.com/go/pdftoolsapi_net_samples2// Run the sample:3// cd RemoveProtection/4// dotnet run RemoveProtection.csproj56 namespace RemoveProtection7 {8 class Program9 {10 private static readonly ILog log = LogManager.GetLogger(typeof(Program));11 static void Main()12 {13 //Configure the logging14 ConfigureLogging();15 try16 {17 // Initial setup, create credentials instance.18 Credentials credentials = Credentials.ServicePrincipalCredentialsBuilder()19 .WithClientId("PDF_SERVICES_CLIENT_ID")20 .WithClientSecret("PDF_SERVICES_CLIENT_SECRET")21 .Build();2223 // Create an ExecutionContext using credentials.24 ExecutionContext executionContext = ExecutionContext.Create(credentials);2526 // Create a new operation instance27 RemoveProtectionOperation removeProtectionOperation = RemoveProtectionOperation.CreateNew();2829 // Set operation input from a source file.30 FileRef sourceFileRef = FileRef.CreateFromLocalFile(@"removeProtectionInput.pdf");31 removeProtectionOperation.SetInput(sourceFileRef);3233 // Set the password for removing security from a PDF document.34 removeProtectionOperation.SetPassword("password");3536 // Execute the operation.37 FileRef result = removeProtectionOperation.Execute(executionContext);3839 // Save the result to the specified location.40 result.SaveAs(Directory.GetCurrentDirectory() + "/output/removeProtectionOutput.pdf");41 }42 catch (ServiceUsageException ex)43 {44 log.Error("Exception encountered while executing operation", ex);45 }46 // Catch more errors here . . .47 }4849 static void ConfigureLogging()50 {51 ILoggerRepository logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());52 XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));53 }54 }55 }56
Copied to your clipboard1// Get the samples from http://www.adobe.com/go/pdftoolsapi_node_sample2// Run the sample:3// node src/removeprotection/remove-protection.js45 const PDFServicesSdk = require('@adobe/pdfservices-node-sdk');67 try {8 // Initial setup, create credentials instance.9 const credentials = PDFServicesSdk.Credentials10 .servicePrincipalCredentialsBuilder()11 .withClientId("PDF_SERVICES_CLIENT_ID")12 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")13 .build();1415 // Create an ExecutionContext using credentials16 const executionContext = PDFServicesSdk.ExecutionContext.create(credentials);1718 // Create a new operation instance.19 const removeProtectionOperation = PDFServicesSdk.RemoveProtection.Operation.createNew(),20 input = PDFServicesSdk.FileRef.createFromLocalFile(21 'resources/removeProtectionInput.pdf',22 PDFServicesSdk.RemoveProtection.SupportedSourceFormat.pdf23 );24 // Set operation input from a source file.25 removeProtectionOperation.setInput(input);2627 // Set the password for removing security from a PDF document.28 removeProtectionOperation.setPassword("password");2930 // Execute the operation and Save the result to the specified location.31 removeProtectionOperation.execute(executionContext)32 .then(result => result.saveAsFile('output/removeProtectionOutput.pdf'))33 .catch(err => {34 if(err instanceof PDFServicesSdk.Error.ServiceApiError35 || err instanceof PDFServicesSdk.Error.ServiceUsageError) {36 console.log('Exception encountered while executing operation', err);37 } else {38 console.log('Exception encountered while executing operation', err);39 }40 });41 } catch (err) {42 console.log('Exception encountered while executing operation', err);43 }
Copied to your clipboard1// Please refer our Rest API docs for more information2// https://developer.adobe.com/document-services/docs/apis/#tag/Remove-Protection34curl --location --request POST 'https://pdf-services.adobe.io/operation/removeprotection' \5--header 'x-api-key: {{Placeholder for client_id}}' \6--header 'Content-Type: application/json' \7--header 'Authorization: Bearer {{Placeholder for token}}' \8--data-raw '{9 "password": "mypassword",10 "assetID": "urn:aaid:AS:UE1:23c30ee0-2e4d-46d6-87f2-087832fca718"11}'1213// Legacy API can be found here14// https://documentcloud.adobe.com/document-services/index.html#post-removeProtection