@lp-labs/pdf-annotation-editor
v0.1.0
Published
Bounded PDF annotation geometry and lifecycle model.
Readme
@lp-labs/pdf-annotation-editor
A bounded headless model for annotation geometry, color, comments, and open/resolved lifecycle states, using caller-supplied page dimensions.
Install and quick start
npm install @lp-labs/pdf-annotation-editorimport { createPdfAnnotationEditor } from '@lp-labs/pdf-annotation-editor';
const editor = createPdfAnnotationEditor({
pageSizes: [{ width: 612, height: 792 }],
});
editor.add({
id: 'note-1',
kind: 'highlight',
geometry: { page: 0, x: 72, y: 120, width: 180, height: 16 },
color: '#ffdd55',
});
console.log(editor.list(0));API, types, and customization
createPdfAnnotationEditor(options)acceptsAnnotationEditorOptions.pageSizes, plus optionalmaxAnnotations(20,000) andmaxTextLength(10,000).AnnotationGeometryuses zero-based pages and points; rectangles must fit wholly inside the supplied page.PdfAnnotationhas anAnnotationKind(highlight,underline,strikeout,rectangle,note), six-digit hex color, optional contents, and anAnnotationStatus(open/resolved).add,update,resolve,remove, andlistmanage immutable returned records.PdfAnnotationEditorErrorusesinvalid,limit,not-found, orduplicate.
Interoperability and scope
Translate geometry and style in your PDF adapter; this model does not read or write annotation dictionaries, appearance streams, or PDF bytes. Coordinates are page-space values provided by the caller. Work is in-memory; listing is linear in annotation count.
ESM, CommonJS, and TypeScript declarations are included. There are no runtime or peer dependencies; TypeScript and Prettier are development-only.
Support
If this library is useful to you, consider supporting its maintenance with a donation via PayPal.
Author
Created by Libin Prasanth. Connect on LinkedIn for updates and discussion.
