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.

56 lines 2.21 kB
"use strict"; /** * 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.CPDFTextRange = void 0; class CPDFTextRange { pageIndex; location; length; textRangeIndex; constructor(pageIndex, location, length, textRangeIndex) { this.pageIndex = pageIndex; this.location = location; this.length = length; this.textRangeIndex = textRangeIndex; } static fromJson(json) { return new CPDFTextRange(json.pageIndex, json.location, json.length, json.textRangeIndex); } toJson() { return { pageIndex: this.pageIndex, location: this.location, length: this.length, textRangeIndex: this.textRangeIndex }; } /** * Returns a new CPDFTextRange that expands the current range by the given number of characters * before and after the original range. * * If the `before` value causes the start position to be less than 0, it will automatically * clamp the start to 0 and reduce the total length accordingly to avoid overflow. * * @param before The number of characters to include before the original range. Default is 0. * @param after The number of characters to include after the original range. Default is 0. * @returns A new CPDFTextRange instance with adjusted `location` and `length`. */ expanded(before = 0, after = 0) { let newStart = this.location - before; let newLength = this.length + before + after; if (newStart < 0) { newLength += newStart; newStart = 0; } return new CPDFTextRange(this.pageIndex, newStart, newLength, this.textRangeIndex); } } exports.CPDFTextRange = CPDFTextRange; //# sourceMappingURL=CPDFTextRange.js.map