RemoveProtectionOperation

RemoveProtectionOperation

An operation that allows to remove password security from a PDF document.

Sample Usage:


 const credentials = PDFServicesSdk.Credentials.serviceAccountCredentialsBuilder()
           .fromFile("pdfservices-api-credentials.json")
           .build(),
       executionContext = PDFServicesSdk.ExecutionContext.create(credentials),
       RemoveProtection = PDFServicesSdk.RemoveProtection,
       removeProtectionOperation = RemoveProtection.Operation.createNew(),
       input = PDFServicesSdk.FileRef.createFromLocalFile('~/Documents/removeProtectionInput.pdf', RemoveProtection.SupportedSourceFormat.pdf);

 removeProtectionOperation.setInput(input);
 removeProtectionOperation.setPassword("password");

 removeProtectionOperation.execute(executionContext)
     .then(result => result.saveAsFile('output/removeProtectionOutput.pdf'))
     .catch(err => console.log(err));

Members

(static, constant) SupportedSourceFormat

Description:
Properties:
Name Type Description
pdf string

Represents "application/pdf" media type

Supported source file formats for RemoveProtectionOperation.

Methods

(static) createNew() → {RemoveProtectionOperation}

Description:
Returns:

A new RemoveProtectionOperation instance.

Type
RemoveProtectionOperation

setInput(sourceFileRefnon-null)

Description:
  • Sets an input file.

Parameters:
Name Type Description
sourceFileRef FileRef

An input file.

setPassword(passwordnon-null)

Description:
  • Specifies the intended password depending on the type of password security attached to the input PDF document.

Parameters:
Name Type Description
password String

Password for the removal of security of the input PDF file.

execute(contextnon-null) → {Promise.<FileRef>}

Description:
  • Executes this operation using the supplied context and returns a Promise which resolves to the operation result.

    The resulting file may be stored in the system temporary directory (per the os.tempdir(), symlinks are resolved to the actual path). See FileRef for how temporary resources are cleaned up.

Parameters:
Name Type Description
context ExecutionContext

The context in which the operation will be executed.

Throws:
  • if an API call results in an error response.

    Type
    ServiceApiError
  • if service usage limits have been reached or credentials quota has been exhausted.

    Type
    ServiceUsageError
Returns:

A promise which resolves to the operation result.

Type
Promise.<FileRef>