@syncfusion/ej2-pdf
Version:
Feature-rich JavaScript PDF library with built-in support for loading and manipulating PDF document.
69 lines (68 loc) • 2.74 kB
JavaScript
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 { PdfAutomaticField } from './automatic-field';
/**
* Represents an abstract class for all dynamic fields.
*
* ```typescript
* // Create a new document.
* const document: PdfDocument = new PdfDocument();
* // Create the first section within the document.
* const section: PdfSection = document.addSection();
* // Add a page to section1.
* let page: PdfPage = section.addPage();
* // Initialize the standard font.
* const font: PdfStandardFont = new PdfStandardFont(PdfFontFamily.helvetica, 13);
* // Initialize the solid brush.
* const brush: PdfBrush = new PdfBrush({ r: 255, g: 0, b: 255 });
* // Create a dynamic field with font and brush.
* const sectionNumField: PdfDynamicField = new PdfSectionNumberField({ font: font, brush: brush });
* // Draw the section number field field onto the page graphics.
* sectionNumField.draw(page.graphics, { x: 150, y: 10 });
* // Save the document.
* document.save('output.pdf');
* // Destroy the document.
* document.destroy();
* ```
*/
var PdfDynamicField = /** @class */ (function (_super) {
__extends(PdfDynamicField, _super);
function PdfDynamicField() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* Initializes the base properties of the automatic 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} Method return nothing.
* @private
*/
PdfDynamicField.prototype._initializeBase = function (font, brush, stringFormat) {
_super.prototype._initializeBase.call(this, font, brush, stringFormat);
};
/**
* Resolves the runtime page from the graphics context.
*
* @private
* @param {PdfGraphics} graphics The graphics context.
* @returns {PdfPage} The current page.
*/
PdfDynamicField.prototype._getPageFromGraphics = function (graphics) {
return graphics._page;
};
return PdfDynamicField;
}(PdfAutomaticField));
export { PdfDynamicField };