public class RemoveProtectionOperation extends Object implements Operation
Sample Usage:
RemoveProtectionOperation removeProtectionOperation = RemoveProtectionOperation.createNew();
removeProtectionOperation.setInput(FileRef.createFromLocalFile("~/Documents/removeProtectionInput.pdf",
RemoveProtectionOperation.SupportedSourceFormat.PDF.getMediaType()));
removeProtectionOperation.setPassword("password");
Credentials credentials = Credentials.servicePrincipalCredentialsBuilder()
.withClientId("PDF_SERVICES_CLIENT_ID")
.withClientSecret("PDF_SERVICES_CLIENT_SECRET")
.build();
FileRef result = removeProtectionOperation.execute(ExecutionContext.create(credentials));
result.saveAs("output/removeProtectionOutput.pdf");
Modifier and Type | Class and Description |
---|---|
static class |
RemoveProtectionOperation.SupportedSourceFormat
Supported source file formats for
RemoveProtectionOperation . |
Modifier and Type | Method and Description |
---|---|
static RemoveProtectionOperation |
createNew()
Constructs a
RemoveProtectionOperation instance. |
FileRef |
execute(ExecutionContext context)
Executes this operation synchronously using the supplied context and returns a new FileRef instance for the resulting PDF file.
|
void |
setInput(FileRef sourceFileRef)
Sets an input file.
|
void |
setPassword(String password)
Specifies the intended password depending on the type of password security attached to the input PDF document.
|
public static RemoveProtectionOperation createNew()
RemoveProtectionOperation
instance.RemoveProtectionOperation
instancepublic void setInput(FileRef sourceFileRef)
sourceFileRef
- an input file; can not be nullpublic void setPassword(String password)
password
- password for the removal of security of the input PDF file; can not be null or emptypublic FileRef execute(ExecutionContext context) throws ServiceApiException, IOException, ServiceUsageException
The resulting file may be stored in the system temporary directory (per java.io.tmpdir System property).
See FileRef
for how temporary resources are cleaned up.
execute
in interface Operation
context
- the context in which to execute the operationServiceApiException
- if an API call results in an error responseIOException
- if there is an error in reading either the input source or the resulting PDF fileServiceUsageException
- if service usage limits have been reached or credentials quota has been exhaustedCopyright © 2023 Adobe. All rights reserved.