Skip to content

Instantly share code, notes, and snippets.

@benvanderberg
Created September 23, 2020 23:20
Show Gist options
  • Save benvanderberg/9999e215e74cbdfe14b7e297a30da82f to your computer and use it in GitHub Desktop.
Save benvanderberg/9999e215e74cbdfe14b7e297a30da82f to your computer and use it in GitHub Desktop.
// Create an ExecutionContext using credentials
const executionContext = PDFToolsSdk.ExecutionContext.create(credentials);
// Create a new operation instance.
const removeProtectionOperation = PDFToolsSdk.RemoveProtection.Operation.createNew(),
input = PDFToolsSdk.FileRef.createFromLocalFile(
'resources/removeProtectionInput.pdf',
PDFToolsSdk.RemoveProtection.SupportedSourceFormat.pdf
);
// Set operation input from a source file.
removeProtectionOperation.setInput(input);
// Set the password for removing security from a PDF document.
removeProtectionOperation.setPassword("password");
// Execute the operation and Save the result to the specified location.
removeProtectionOperation.execute(executionContext)
.then(result => result.saveAsFile('output/removeProtectionOutput.pdf'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment