A job that is used for securing PDF document with password(s). The password(s) is used for encrypting the PDF document and setting the restriction on certain features like printing, editing and copying in the PDF document.

The supported algorithm for encrypting the PDF document are listed here. The EncryptionAlgorithm enum can be used to set the encryption algorithm.

  • AES-128
  • AES-256

For AES-128 encryption the password supports LATIN-I characters only. For AES-256 encryption the password supports Unicode character set.

Example

Sample Usage:

        const readStream = fs.createReadStream("<SOURCE_PATH>");

const pdfServices = new PDFServices({
credentials: new ServicePrincipalCredentials({
clientId: process.env.PDF_SERVICES_CLIENT_ID,
clientSecret: process.env.PDF_SERVICES_CLIENT_SECRET
})
});

const inputAsset = await pdfServices.upload({
readStream,
mimeType: MimeType.PDF
});

const permissions = new Permissions({
permissions: [
Permission.PRINT_LOW_QUALITY,
Permission.EDIT_DOCUMENT_ASSEMBLY,
Permission.COPY_CONTENT
]
});

const params = new ProtectPDFParams({
userPassword: "openpassword",
ownerPassword: "permissionspassword",
permissions: permissions,
encryptionAlgorithm: EncryptionAlgorithm.AES_256,
contentEncryption: ContentEncryption.ALL_CONTENT_EXCEPT_METADATA,
});

const job = new ProtectPDFJob({inputAsset, params});

const pollingURL = await pdfServices.submit({job});

const pdfServicesResponse = await pdfServices.getJobResult({
pollingURL,
resultType: ProtectPDFResult
});

const resultAsset = pdfServicesResponse.result.asset;
const streamAsset = await pdfServices.getContent({asset: resultAsset});

Hierarchy (view full)

Constructors

  • Constructs a new ProtectPDFJob instance.

    Parameters

    • params: {
          inputAsset: Asset;
          outputAsset?: Asset;
          params: ProtectPDFParams;
      }

      The parameters for constructing an instance of ProtectPDFJob.

    Returns ProtectPDFJob

    Remarks

    External assets can be set as output only when input is external asset as well.

Properties

_inputAsset: Asset
_outputAsset?: Asset

Methods

  • Parameters

    Returns PDFServicesApiRequest

  • Parameters

    • executionContext: ExecutionContext

    Returns void

Generated using TypeDoc