UNPKG

@compdfkit_pdf_sdk/react_native

Version:

ComPDFKit for React Native is a comprehensive SDK that allows you to quickly add PDF functionality to Android, iOS, and React Native applications.

68 lines 2.59 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CPDFFreeTextAnnotation = void 0; /** * Copyright © 2014-2026 PDF Technologies, Inc. All Rights Reserved. * * THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW * AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT. * UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES. * This notice may not be removed from this file. */ const CPDFOptions_1 = require("../configuration/CPDFOptions"); const CPDFEnumUtils_1 = require("../util/CPDFEnumUtils"); const CPDFAnnotation_1 = require("./CPDFAnnotation"); /** * @class CPDFFreeTextAnnotation * @group Annotations * @property {CPDFAlignment} alignment - The alignment of the text in the annotation. * @property {CPDFTextAttribute} textAttribute - The text attribute of the annotation. * @property { number } [alpha] The alpha of the annotation */ class CPDFFreeTextAnnotation extends CPDFAnnotation_1.CPDFAnnotation { alignment; textAttribute; alpha; constructor(params) { super(params); this.type = 'freetext'; this.alignment = (0, CPDFEnumUtils_1.safeParseEnumValue)(params.alignment, Object.values(CPDFOptions_1.CPDFAlignment), CPDFOptions_1.CPDFAlignment.LEFT); this.textAttribute = params.textAttribute ?? { color: '#000000', familyName: 'Helvetica', styleName: '', fontSize: 14 }; const alpha = params.alpha ?? 255; this.alpha = Math.max(0, Math.min(255, alpha)); } /** * Update free text annotation properties with type safety * @param updates Partial object containing properties to update * @returns this instance for chaining * * @example * freeTextAnnotation.update({ * title: 'Updated Title', * content: 'Updated content', * alignment: CPDFAlignment.CENTER, * textAttribute: { * fontSize: 14, * fontFamily: 'Times', * styleName: 'Bold', * color: '#00FF00' * }, * alpha: 200 * }); * await document.updateAnnotation(freeTextAnnotation); */ update(updates) { Object.assign(this, updates); return this; } toJSON() { return { ...super.toJSON(), alignment: this.alignment, textAttribute: this.textAttribute, alpha: this.alpha }; } } exports.CPDFFreeTextAnnotation = CPDFFreeTextAnnotation; //# sourceMappingURL=CPDFFreeTextAnnotation.js.map