@adobe/pdfservices-node-sdk
Version:
The Adobe PDF Services Node.js SDK provides APIs for creating, combining, exporting and manipulating PDFs.
68 lines • 2.68 kB
JavaScript
;
/*
* Copyright 2024 Adobe
* All Rights Reserved.
*
* NOTICE: Adobe permits you to use, modify, and distribute this file in
* accordance with the terms of the Adobe license agreement accompanying
* it. If you have received this file from a source other than Adobe,
* then your use, modification, or distribution of it requires the prior
* written permission of Adobe.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.CombinePDFParams = void 0;
const CombinePDFJobInput_1 = require("../../../internal/params/CombinePDFJobInput");
const ObjectUtil_1 = require("../../../internal/util/ObjectUtil");
const ValidationUtil_1 = require("../../../internal/util/ValidationUtil");
const PageRanges_1 = require("../PageRanges");
/**
* Parameters for combining PDFs using {@link CombinePDFJob}.
*/
class CombinePDFParams {
/**
* Constructs a new `CombinePDFParams` instance.
*/
constructor() {
this._assetsToCombine = [];
}
/**
* Adds an {@link Asset} to combine.
*
* @param asset - The asset to be combined. Cannot be undefined.
* @param [pageRanges] - The page ranges to be combined for the input file. If not provided, all pages
* will be combined.
* @returns This `CombinePDFParams` instance.
*/
addAsset(asset, pageRanges) {
ObjectUtil_1.ObjectUtil.requireNonNullOrUndefined(asset, "Asset");
ObjectUtil_1.ObjectUtil.requireNonNull(pageRanges, "Page Ranges");
this._assetsToCombine.push(new CombinePDFJobInput_1.CombinePDFJobInput(asset, pageRanges ?? new PageRanges_1.PageRanges().addAll()));
return this;
}
/**
* @hidden
*/
validate() {
if (this._assetsToCombine.length === 0) {
throw new TypeError("No input was provided for combining files");
}
const firstAssetType = this._assetsToCombine[0].asset.constructor;
this._assetsToCombine.forEach((file) => {
if (!(file.asset instanceof firstAssetType)) {
throw new TypeError("All assets are not of same type.");
}
ValidationUtil_1.ValidationUtil.validateAssetWithPageOptions(file);
});
if (new Set(this._assetsToCombine.map((file) => file.asset)).size > 20) {
throw new RangeError("Only 20 unique input assets can be combined in one combine job instance");
}
}
/**
* @internal Used internally by this SDK, not intended to be called by clients.
*/
get assetsToCombine() {
return this._assetsToCombine;
}
}
exports.CombinePDFParams = CombinePDFParams;
//# sourceMappingURL=CombinePDFParams.js.map