@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.
48 lines (46 loc) • 1.55 kB
JavaScript
/**
* Copyright © 2014-2025 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.
*/
import { CPDFAnnotationType } from "../configuration/CPDFOptions";
/**
* @class CPDFAnnotation
* @property { CPDFAnnotationType } [type] Annotation type identifier
* @property { title } [title] Annotation title
* @property { number } [page] The page number where the note is located
* @property { string } [content] annotation content.
*/
export class CPDFAnnotation {
constructor(viewerRef, params) {
this.type = CPDFAnnotation.parseType(params.type);
this.title = params.title ?? '';
this.page = params.page ?? 0;
this.content = params.content ?? "";
this.uuid = params.uuid ?? "";
this._viewerRef = viewerRef;
}
static fromJson(json, viewerRef) {
return new this(viewerRef, json);
}
static fromJsonArray(jsonArray, viewerRef) {
return jsonArray.map(item => new this(viewerRef, item));
}
static parseType(type) {
if (Object.values(CPDFAnnotationType).includes(type)) {
return type;
}
return CPDFAnnotationType.UNKNOWN;
}
toJSON() {
const {
_viewerRef,
...data
} = this;
return data;
}
}
//# sourceMappingURL=CPDFAnnotation.js.map