@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.
72 lines • 2.92 kB
JavaScript
;
/**
* 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.CPDFTextWidget = void 0;
const CPDFOptions_1 = require("../../configuration/CPDFOptions");
const CPDFEnumUtils_1 = require("../../util/CPDFEnumUtils");
const CPDFWidget_1 = require("./CPDFWidget");
/**
* Class representing a text field form widget, storing basic information about the text field form.
* It includes general form attributes as well as the text content of the text field.
*
* @class CPDFTextWidget
* @group Forms
* @property {string} [text] - The text content of the text field.
* @property {boolean} [isMultiline] - Indicates if the text field is multiline (default: false).
* @property {string} [fontColor] - The font color of the text field (default: '#000000').
* @property {number} [fontSize] - The font size of the text field (default: 0).
* @property {CPDFAlignment} [alignment] - The alignment of the text field (default: CPDFAlignment.LEFT).
* @property { string } [familyName] - The font family name of the text field.
* @property { string } [styleName] - The font style name of the text field.
*/
class CPDFTextWidget extends CPDFWidget_1.CPDFWidget {
/**
* The text content of the text field.
*/
text;
isMultiline;
fontColor;
familyName;
styleName;
fontSize;
alignment;
constructor(params) {
super(params);
this.type = 'textField';
this.text = params.text ?? '';
this.isMultiline = params.isMultiline ?? false;
this.fontColor = params.fontColor ?? '#000000';
this.familyName = params.familyName ?? '';
this.styleName = params.styleName ?? '';
this.fontSize = params.fontSize ?? 14;
this.alignment = (0, CPDFEnumUtils_1.safeParseEnumValue)(params.alignment, Object.values(CPDFOptions_1.CPDFAlignment), CPDFOptions_1.CPDFAlignment.LEFT);
}
/**
* Update text widget properties with type safety
* @param updates Partial object containing properties to update
* @returns this instance for chaining
*
* @example
* textWidget.update({
* title: 'Updated Title',
* text: 'New text',
* fontColor: '#FF0000',
* fontSize: 14,
* alignment: CPDFAlignment.CENTER
* });
* await document.updateWidget(textWidget);
*/
update(updates) {
Object.assign(this, updates);
return this;
}
}
exports.CPDFTextWidget = CPDFTextWidget;
//# sourceMappingURL=CPDFTextWidget.js.map