UNPKG

@adobe/pdfservices-node-sdk

Version:

The Adobe PDF Services Node.js SDK provides APIs for creating, combining, exporting and manipulating PDFs.

77 lines (76 loc) 2.87 kB
import { PDFServicesJob } from "./PDFServicesJob"; import { InsertPagesParams } from "../params/insertpages/InsertPagesParams"; import { Asset } from "../../io/Asset"; import { ExecutionContext } from "../../internal/ExecutionContext"; import { NotifierConfig } from "../../config/notifier/NotifierConfig"; /** * A job that can be used to insert pages of multiple PDF files into a base PDF file. * <p> * For more complex use cases, refer the {@link CombinePDFJob}. * <p> * * @example * Sample Usage: * ```js * const baseReadStream = fs.createReadStream("<SOURCE_PATH>"); * const readStreamToInsert = fs.createReadStream("<SOURCE_PATH>"); * * const credentials = new ServicePrincipalCredentials({ * clientId: process.env.PDF_SERVICES_CLIENT_ID, * clientSecret: process.env.PDF_SERVICES_CLIENT_SECRET * }); * * const pdfServices = new PDFServices({credentials}); * * const [baseAsset, assetToInsert] = await pdfServices.uploadAssets({ * streamAssets: [{ * readStream: baseReadStream, * mimeType: MimeType.PDF * }, { * readStream: readStreamToInsert, * mimeType: MimeType.PDF * }] * }); * * const params = new InsertPagesParams(baseAsset) * .addPagesToInsertAt({ * inputAsset: assetToInsert, * basePage: 1 * }); * * const job = new InsertPagesJob({params}); * * const pollingURL = await pdfServices.submit({job}); * * const pdfServicesResponse = await pdfServices.getJobResult({ * pollingURL, * resultType: InsertPagesResult * }); * * const resultAsset = pdfServicesResponse.result.asset; * const streamAsset = await pdfServices.getContent({asset: resultAsset}); * ``` */ export declare class InsertPagesJob extends PDFServicesJob { private readonly _insertPagesParams; private readonly _outputAsset?; /** * Constructs a new `InsertPagesJob` instance. * * @param params The parameters for constructing an instance of `InsertPagesJob`. * @param params.params {@link InsertPagesParams} object containing the input files and the page numbers * to insert at. Cannot be undefined. * @param [params.outputAsset] {@link Asset} object representing the output asset. * @remarks External assets can be set as output only when input is external asset as well. */ constructor(params: { params: InsertPagesParams; outputAsset?: Asset; }); /** * @hidden */ process(executionContext: ExecutionContext, notifierConfigList?: NotifierConfig[]): Promise<string>; private generatePDFServicesAPIRequest; private getFilesToInsert; }