Edit in GitHubLog an issue

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.

Copied to your clipboard
1// Get the samples from https://www.adobe.com/go/pdftoolsapi_java_samples
2// Run the sample:
3// mvn -f pom.xml exec:java -Dexec.mainClass=com.adobe.pdfservices.operation.samples.removeprotection.RemoveProtection
4
5 public class RemoveProtection {
6
7 // Initialize the logger.
8 private static final Logger LOGGER = LoggerFactory.getLogger(RemoveProtection.class);
9
10 public static void main(String[] args) {
11 try (InputStream inputStream = Files.newInputStream(new File("src/main/resources/removeProtectionInput.pdf").toPath())) {
12 // Initial setup, create credentials instance
13 Credentials credentials = new ServicePrincipalCredentials(
14 System.getenv("PDF_SERVICES_CLIENT_ID"),
15 System.getenv("PDF_SERVICES_CLIENT_SECRET"));
16
17 // Creates a PDF Services instance
18 PDFServices pdfServices = new PDFServices(credentials);
19
20 // Creates an asset(s) from source file(s) and upload
21 Asset asset = pdfServices.upload(inputStream, PDFServicesMediaType.PDF.getMediaType());
22
23 // Create parameters for the job
24 RemoveProtectionParams removeProtectionParams = new RemoveProtectionParams("password");
25
26 // Creates a new job instance
27 RemoveProtectionJob removeProtectionJob = new RemoveProtectionJob(asset, removeProtectionParams);
28
29 // Submit the job and gets the job result
30 String location = pdfServices.submit(removeProtectionJob);
31 PDFServicesResponse<RemoveProtectionResult> pdfServicesResponse = pdfServices.getJobResult(location, RemoveProtectionResult.class);
32
33 // Get content from the resulting asset(s)
34 Asset resultAsset = pdfServicesResponse.getResult().getAsset();
35 StreamAsset streamAsset = pdfServices.getContent(resultAsset);
36
37 // Creates an output stream and copy stream asset's content to it
38 Files.createDirectories(Paths.get("output/"));
39 OutputStream outputStream = Files.newOutputStream(new File("output/removeProtectionOutput.pdf").toPath());
40 LOGGER.info("Saving asset at output/removeProtectionOutput.pdf");
41 IOUtils.copy(streamAsset.getInputStream(), outputStream);
42 outputStream.close();
43 } catch (IOException | ServiceApiException | SDKException | ServiceUsageException e) {
44 LOGGER.error("Exception encountered while executing operation", e);
45 }
46 }
47 }
  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2024 Adobe. All rights reserved.