CombineFilesOperation

CombineFilesOperation

Combines multiple PDF files into a single PDF file. Allows specifying which pages of the source files to combine.

Sample Usage:



 const credentials = DCServicesSdk.Credentials.serviceAccountCredentialsBuilder()
           .fromFile("dc-services-sdk-credentials.json")
           .build(),
       executionContext = DCServicesSdk.ExecutionContext.create(credentials),
       combineFilesOperation = DCServicesSdk.CombineFiles.Operation.createNew(),
       input1 = DCServicesSdk.FileRef.createFromLocalFile('test/resources/combinePagesInput1.pdf'),
       input2 = DCServicesSdk.FileRef.createFromLocalFile('test/resources/combinePagesInput1.pdf'),

 combineFilesOperation.addInput(input1);
 combineFilesOperation.addInput(input2);

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

Methods

(static) createNew() → {CombineFilesOperation}

Constructs a CombineFilesOperation instance.

Returns:

A new CombineFilesOperation instance.

Type
CombineFilesOperation

addInput(sourceFileRefnon-null, pageRangesopt)

Specifies particular pages of a PDF file (media type "application/pdf") to be combined with other files. The pages will be added after the pages of any previously specified files. If the pageRanges argument is not provided, all pages of the PDF will be added in the combined PDF.

Parameters:
Name Type Attributes Description
sourceFileRef FileRef

A PDF file to be combined.

pageRanges PageRanges <optional>

Page ranges of the PDF file to be combined.

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

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>