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.

39 lines (37 loc) 3.34 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CPDFAnnotationFactory = void 0; var _CPDFOptions = require("../configuration/CPDFOptions"); var _CPDFEnumUtils = require("../util/CPDFEnumUtils"); var _CPDFAnnotation = require("./CPDFAnnotation"); var _CPDFCircleAnnotation = require("./CPDFCircleAnnotation"); var _CPDFFreeTextAnnotation = require("./CPDFFreeTextAnnotation"); var _CPDFInkAnnotation = require("./CPDFInkAnnotation"); var _CPDFLineAnnotation = require("./CPDFLineAnnotation"); var _CPDFLinkAnnotation = require("./CPDFLinkAnnotation"); var _CPDFMarkupAnnotation = require("./CPDFMarkupAnnotation"); var _CPDFSquareAnnotation = require("./CPDFSquareAnnotation"); /** * 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. */ class CPDFAnnotationFactory { static annotationMap = new Map([[_CPDFOptions.CPDFAnnotationType.HIGHLIGHT, (json, viewerRef) => _CPDFMarkupAnnotation.CPDFMarkupAnnotation.fromJson(json, viewerRef)], [_CPDFOptions.CPDFAnnotationType.UNDERLINE, (json, viewerRef) => _CPDFMarkupAnnotation.CPDFMarkupAnnotation.fromJson(json, viewerRef)], [_CPDFOptions.CPDFAnnotationType.SQUIGGLY, (json, viewerRef) => _CPDFMarkupAnnotation.CPDFMarkupAnnotation.fromJson(json, viewerRef)], [_CPDFOptions.CPDFAnnotationType.STRIKEOUT, (json, viewerRef) => _CPDFMarkupAnnotation.CPDFMarkupAnnotation.fromJson(json, viewerRef)], [_CPDFOptions.CPDFAnnotationType.INK, (json, viewerRef) => _CPDFInkAnnotation.CPDFInkAnnotation.fromJson(json, viewerRef)], [_CPDFOptions.CPDFAnnotationType.SQUARE, (json, viewerRef) => _CPDFSquareAnnotation.CPDFSquareAnnotation.fromJson(json, viewerRef)], [_CPDFOptions.CPDFAnnotationType.CIRCLE, (json, viewerRef) => _CPDFCircleAnnotation.CPDFCircleAnnotation.fromJson(json, viewerRef)], [_CPDFOptions.CPDFAnnotationType.LINE, (json, viewerRef) => _CPDFLineAnnotation.CPDFLineAnnotation.fromJson(json, viewerRef)], [_CPDFOptions.CPDFAnnotationType.ARROW, (json, viewerRef) => _CPDFLineAnnotation.CPDFLineAnnotation.fromJson(json, viewerRef)], [_CPDFOptions.CPDFAnnotationType.FREETEXT, (json, viewerRef) => _CPDFFreeTextAnnotation.CPDFFreeTextAnnotation.fromJson(json, viewerRef)], [_CPDFOptions.CPDFAnnotationType.LINK, (json, viewerRef) => _CPDFLinkAnnotation.CPDFLinkAnnotation.fromJson(json, viewerRef)]]); static create(json, viewerRef) { console.log(JSON.stringify(json, null, 2)); const type = (0, _CPDFEnumUtils.safeParseEnumValue)(json.type, Object.values(_CPDFOptions.CPDFAnnotationType), _CPDFOptions.CPDFAnnotationType.UNKNOWN); const annotationCreator = CPDFAnnotationFactory.annotationMap.get(type); return annotationCreator ? annotationCreator(json, viewerRef) : _CPDFAnnotation.CPDFAnnotation.fromJson(json, viewerRef); } static createFromArray(viewerRef, jsonArray) { return jsonArray.map(item => CPDFAnnotationFactory.create(item, viewerRef)); } } exports.CPDFAnnotationFactory = CPDFAnnotationFactory; //# sourceMappingURL=CPDFAnnotationFactory.js.map