@adobe/pdfservices-node-sdk
Version:
The Adobe PDF Services Node.js SDK provides APIs for creating, combining, exporting and manipulating PDFs.
75 lines • 3 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.HTMLToPDFParams = void 0;
const ValidationUtil_1 = require("../../../internal/util/ValidationUtil");
/**
* Parameters for converting HTML to PDF using {@link HTMLToPDFJob}.
*/
class HTMLToPDFParams {
/**
* Constructs a new `HTMLtoPDFParams` instance.
*
* @param params - The parameters for constructing an instance of `HTMLtoPDFParams`.
* @param [params.includeHeaderFooter] - Whether to include header and footer. If `true`, default header and footer
* will be included in resulting PDF.
* Default value is `false`.
* The default header consists of the date and the document title.
* The default footer consists of the file name and page number.
* @param [params.pageLayout] - The intended page layout of the resulting PDF file. The default layout sets the
* height as 8.5 inches and width as 11 inches.
* @param [params.dataToMerge] - The JSON data to merge.
* The data to be used by the javascript in the source html file to
* manipulate the HTML DOM before it gets converted to PDF.
* This mechanism is intended to be used to supply data that might otherwise be retrieved using ajax requests.
*
* To make use of this mechanism, the source html file must include a script element such as:
*
* ```html
* <script src='./json.js' type='text/javascript'></script>
* ```
* where json.js refers to the JSON data,
* And also Requires javascript in the source html file to make use of this JSON data to manipulate the HTML DOM.
*/
constructor(params) {
ValidationUtil_1.ValidationUtil.validateHTMLToPDFParams(params);
this._includeHeaderFooter = params.includeHeaderFooter;
this._pageLayout = params.pageLayout;
this._dataToMerge = params.dataToMerge ? JSON.stringify(params.dataToMerge) : undefined;
}
/**
* Returns whether to include header and footer.
*
* @returns `true` if header and footer are to be included, `false` otherwise.
*/
get includeHeaderAndFooter() {
return this._includeHeaderFooter;
}
/**
* Returns the page layout.
*
* @returns The page layout.
*/
get pageLayout() {
return this._pageLayout;
}
/**
* Returns the data to merge.
*
* @returns The data to merge.
*/
get dataToMerge() {
return this._dataToMerge ? JSON.parse(this._dataToMerge) : undefined;
}
}
exports.HTMLToPDFParams = HTMLToPDFParams;
//# sourceMappingURL=HTMLToPDFParams.js.map