UNPKG

@syncfusion/ej2-pdf

Version:

Feature-rich JavaScript PDF library with built-in support for loading and manipulating PDF document.

263 lines (262 loc) 11 kB
/** * `PdfPageImportOptions` class represents to customize the support of import PDF pages * * ```typescript * // Load an existing PDF document * let document: PdfDocument = new PdfDocument(data); * // Options to customize the support of import PDF pages. * let options: PdfPageImportOptions = new PdfPageImportOptions(); * // Sets the target page index to import * options.targetIndex = 1; * // Sets the rotation angle of the page to import * options.rotation = PdfRotationAngle.angle180; * // Sets the boolean value indicating whether the optimize resources while import pages or not * options.optimizeResources = true; * // Copy the first page and add it as second page with page rotation * document.importPage(0, options); * // Save the document * document.save('output.pdf'); * // Destroy the document * document.destroy(); * ``` */ var PdfPageImportOptions = /** @class */ (function () { /** * Initializes a new instance of the `PdfPageImportOptions` class. * * @param {object} [options] Optional configuration. * @param {number} [options.targetIndex] Target page index to import. * @param {PdfRotationAngle} [options.rotation] Rotation angle of the page. * @param {boolean} [options.optimizeResources] Whether to optimize resources. * @param {boolean} [options.groupFormFields] Whether to group form fields. * * ```typescript * // Load an existing PDF document * let document: PdfDocument = new PdfDocument(data); * // Options to customize the support of import PDF pages. * let options: PdfPageImportOptions = new PdfPageImportOptions({ * targetIndex: 2, rotation: PdfRotationAngle.angle90, optimizeResources: true, * groupFormFields: false}); * // Copy the first page and add it as second page with page rotation * document.importPage(0, options); * // Save the document * document.save('output.pdf'); * // Destroy the document * document.destroy(); */ function PdfPageImportOptions(options) { /** * Indicates whether the resources of the imported page should be optimized to avoid duplication. * * @private */ this._optimizeResources = true; /** * Determines whether form fields from the imported page must be grouped to avoid name conflicts. * * @private */ this._groupFormFields = false; if (options && 'targetIndex' in options && options.targetIndex !== null && typeof options.targetIndex !== 'undefined') { this._targetIndex = options.targetIndex; } if (options && 'rotation' in options && options.rotation !== null && typeof options.rotation !== 'undefined') { this._rotation = options.rotation; } if (options && 'optimizeResources' in options && options.optimizeResources !== null && typeof options.optimizeResources !== 'undefined') { this._optimizeResources = options.optimizeResources; } if (options && 'groupFormFields' in options && options.groupFormFields !== null && typeof options.groupFormFields !== 'undefined') { this._groupFormFields = options.groupFormFields; } } Object.defineProperty(PdfPageImportOptions.prototype, "targetIndex", { /** * Gets the target page index to import * * @returns {PdfRotationAngle} Page rotation angle. * ```typescript * // Load an existing PDF document * let document: PdfDocument = new PdfDocument(data); * // Options to customize the support of import PDF pages. * let options: PdfPageImportOptions = new PdfPageImportOptions(); * // Gets the target page index to import * let targetIndex: number = options.targetIndex; * // Save the document * document.save('output.pdf'); * // Destroy the document * document.destroy(); * ``` */ get: function () { return this._targetIndex; }, /** * Sets the target page index to import * * @param {number} value Target page index to import. * * ```typescript * // Load an existing PDF document * let document: PdfDocument = new PdfDocument(data); * // Options to customize the support of import PDF pages. * let options: PdfPageImportOptions = new PdfPageImportOptions(); * // Sets the target page index to import * options.targetIndex = 1; * // Copy the first page and add it as second page with page rotation * document.importPage(0, options); * // Save the document * document.save('output.pdf'); * // Destroy the document * document.destroy(); * ``` */ set: function (value) { this._targetIndex = value; }, enumerable: true, configurable: true }); Object.defineProperty(PdfPageImportOptions.prototype, "rotation", { /** * Gets the rotation angle of the page to import * * @returns {PdfRotationAngle} Page rotation angle. * ```typescript * // Load an existing PDF document * let document: PdfDocument = new PdfDocument(data); * // Options to customize the support of import PDF pages. * let options: PdfPageImportOptions = new PdfPageImportOptions(); * // Gets the rotation angle of the page to import * let rotation: PdfRotationAngle = options.rotation; * // Save the document * document.save('output.pdf'); * // Destroy the document * document.destroy(); * ``` */ get: function () { return this._rotation; }, /** * Sets the rotation angle of the page to import * * @param {PdfRotationAngle} value Page rotation angle. * * ```typescript * // Load an existing PDF document * let document: PdfDocument = new PdfDocument(data); * // Options to customize the support of import PDF pages. * let options: PdfPageImportOptions = new PdfPageImportOptions(); * // Sets the rotation angle of the page to import * options.rotation = PdfRotationAngle.angle270; * // Copy the first page and add it as second page with page rotation * document.importPage(0, options); * // Save the document * document.save('output.pdf'); * // Destroy the document * document.destroy(); * ``` */ set: function (value) { this._rotation = value; }, enumerable: true, configurable: true }); Object.defineProperty(PdfPageImportOptions.prototype, "optimizeResources", { /** * Gets the boolean value indicating whether the optimize resources while import pages or not * * @returns {boolean} Indicates resource optimization. * ```typescript * // Load an existing PDF document * let document: PdfDocument = new PdfDocument(data); * // Options to customize the support of import PDF pages. * let options: PdfPageImportOptions = new PdfPageImportOptions(); * // Gets the boolean value indicating whether the optimize resources while import pages or not * let resource: optimizeResources = options.optimizeResources; * // Save the document * document.save('output.pdf'); * // Destroy the document * document.destroy(); * ``` */ get: function () { return this._optimizeResources; }, /** * Sets the boolean value indicating whether the optimize resources while import pages or not * * @param {boolean} value Indicates resource optimization. * * ```typescript * // Load an existing PDF document * let document: PdfDocument = new PdfDocument(data); * // Options to customize the support of import PDF pages. * let options: PdfPageImportOptions = new PdfPageImportOptions(); * // Sets the boolean value indicating whether the optimize resources while import pages or not * options.optimizeResources = true; * // Copy the first page and add it as second page with page rotation * document.importPage(0, options); * // Save the document * document.save('output.pdf'); * // Destroy the document * document.destroy(); * ``` */ set: function (value) { this._optimizeResources = value; }, enumerable: true, configurable: true }); Object.defineProperty(PdfPageImportOptions.prototype, "groupFormFields", { /** * Gets the boolean value indicating whether the form fields are grouped or not while importing pages. * * @returns {boolean} value Indicates form fields grouping. * ```typescript * // Load an existing PDF document * let document: PdfDocument = new PdfDocument(data); * // Options to customize the support of import PDF pages. * let options: PdfPageImportOptions = new PdfPageImportOptions(); * // Gets the boolean value indicating whether the form fields are grouped or not while importing pages. * let groupFormfields: number = options.groupFormFields; * // Save the document * document.save('output.pdf'); * // Destroy the document * document.destroy(); * ``` */ get: function () { return this._groupFormFields; }, /** * Sets the boolean value indicating whether the form fields are grouped or not while importing pages. * * @param {boolean} value Indicates form fields grouping * ```typescript * // Load an existing PDF document * let document: PdfDocument = new PdfDocument(data); * // Options to customize the support of import PDF pages. * let options: PdfPageImportOptions = new PdfPageImportOptions(); * // Sets the boolean value indicating whether the form fields are grouped or not while importing pages. * options.groupFormFields = true; * // Copy the first page and add it as second page. * document.importPage(0, options); * // Save the document * document.save('output.pdf'); * // Destroy the document * document.destroy(); * ``` */ set: function (value) { this._groupFormFields = value; }, enumerable: true, configurable: true }); return PdfPageImportOptions; }()); export { PdfPageImportOptions };