UNPKG

@syncfusion/ej2-pdf

Version:

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

120 lines (119 loc) 4.9 kB
var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); import { PdfNumberStyle } from '../../enumerator'; import { PdfMultipleValueField } from './multiple-value-field'; /** * Represents a field with multiple numeric values. * * @private */ var PdfMultipleNumberValueField = /** @class */ (function (_super) { __extends(PdfMultipleNumberValueField, _super); function PdfMultipleNumberValueField() { var _this = _super !== null && _super.apply(this, arguments) || this; /** * Gets or sets the number style used to format numeric values. * * @private */ _this._numberStyle = PdfNumberStyle.numeric; return _this; } /** * Initializes the base properties of the field. * * @param {PdfFont} [font] The font used to draw the text. * @param {PdfBrush} [brush] The brush used to render the text. * @param {PdfStringFormat} [stringFormat] The text layout and alignment settings. * @returns {void} * @private */ PdfMultipleNumberValueField.prototype._initializeBase = function (font, brush, stringFormat) { _super.prototype._initializeBase.call(this, font, brush, stringFormat); }; Object.defineProperty(PdfMultipleNumberValueField.prototype, "numberStyle", { /** * Gets the current number formatting style of the field. * * ```typescript * // Create a new document. * const document: PdfDocument = new PdfDocument(); * // Add new page to document * const page: PdfPage = document.addPage(); * // Initialize standard font. * const font: PdfStandardFont = new PdfStandardFont(PdfFontFamily.helvetica, 12); * // Initialize solid brush * const brush: PdfBrush = new PdfBrush({ r: 0, g: 0, b: 0 }); * // Construct the field with specified properties. * const field: PdfPageNumberField = new PdfPageNumberField({ font: font, brush: brush, numberStyle: PdfNumberStyle.numeric }); * // Gets the current number formatting style of the field * const style: PdfNumberStyle = field.numberStyle; * // Draw the field on page graphics * field.draw(page.graphics, { x: 10, y: 10 }); * // Save the document. * document.save('Output.pdf'); * // Destroy the document * document.destroy(); * ``` * * @returns {PdfNumberStyle} The configured number style. */ get: function () { return this._numberStyle; }, /** * Sets the number formatting style of the field. * * ```typescript * // Create a new document. * const document: PdfDocument = new PdfDocument(); * // Add new page to document * const page: PdfPage = document.addPage(); * // Initialize standard font. * const font: PdfStandardFont = new PdfStandardFont(PdfFontFamily.helvetica, 12); * // Initialize solid brush * const brush: PdfBrush = new PdfBrush({ r: 0, g: 0, b: 0 }); * // Construct the field with specified properties. * const field: PdfPageNumberField = new PdfPageNumberField({ font: font, brush: brush}); * // Sets the number formatting style of the field. * field.numberStyle = PdfNumberStyle.numeric; * // Draw the field on page graphics * field.draw(page.graphics, { x: 10, y: 10 }); * // Save the document. * document.save('Output.pdf'); * // Destroy the document * document.destroy(); * ``` * * @param {PdfNumberStyle} value The number formatting style to apply. */ set: function (value) { this._numberStyle = value; }, enumerable: true, configurable: true }); /** * Returns the string representation of the field’s value used during rendering. * * @private * @param {PdfGraphics} graphics The graphics context used for rendering. * @returns {string} The formatted value to be rendered. */ PdfMultipleNumberValueField.prototype._getValue = function (graphics) { return ''; }; return PdfMultipleNumberValueField; }(PdfMultipleValueField)); export { PdfMultipleNumberValueField };