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.

66 lines 2.36 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CPDFInkAnnotation = 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 CPDFAnnotation_1 = require("./CPDFAnnotation"); /** * @class CPDFInkAnnotation * @group Annotations * @property {string} color - The color of the ink annotation. * @property {number} alpha - The alpha value of the ink annotation. * @property {number} borderWidth - The border width of the ink annotation. * @property {number[][][]} [inkPath] - The ink path data representing the strokes of the ink annotation. */ class CPDFInkAnnotation extends CPDFAnnotation_1.CPDFAnnotation { color; alpha; borderWidth; inkPath; constructor(params) { super({ ...params, rect: params.rect ?? { left: 0, top: 0, right: 0, bottom: 0 } }); this.type = 'ink'; this.color = params.color ?? '#FF0000'; const alpha = params.alpha ?? 255; this.alpha = Math.max(0, Math.min(255, alpha)); const bw = params.borderWidth ?? 0; this.borderWidth = Math.max(0, bw); this.inkPath = params.inkPath ?? undefined; } /** * Update ink annotation properties with type safety * @param updates Partial object containing properties to update * @returns this instance for chaining * * @example * inkAnnotation.update({ * title: 'Updated Title', * content: 'Updated content', * color: '#FF0000', * alpha: 200, * borderWidth: 2, * }); * await document.updateAnnotation(inkAnnotation); */ update(updates) { Object.assign(this, updates); return this; } toJSON() { return { ...super.toJSON(), color: this.color, alpha: this.alpha, borderWidth: this.borderWidth, inkPath: this.inkPath, }; } } exports.CPDFInkAnnotation = CPDFInkAnnotation; //# sourceMappingURL=CPDFInkAnnotation.js.map