@embedpdf/models
v2.3.0
Published
Shared type definitions, data models, and utility helpers (geometry, tasks, logging, PDF primitives) that underpin every package in the EmbedPDF ecosystem.
Readme
@embedpdf/models
Centralised type definitions & helper utilities shared by every EmbedPDF runtime and UI package. Keep your codebase error‑free with a single source of truth for documents, pages, annotations, geometry, async tasks, permissions, and more.
Documentation
Full reference & examples live at:
Why @embedpdf/models?
- Single source of truth – all packages agree on data shapes (e.g.
PdfDocumentObject,PdfAnnotationObject). - Strong typing – exhaustive enums, discriminated unions, generics; a huge boost to DX.
- Zero runtime cost – pure type exports & tiny helper functions, fully tree‑shakable.
Features
- Geometry helpers (
transformRect,rotateRect,boundingRect, …) - Logger with pluggable transports & log‑level filtering
- Promise‑like Task abstraction (cancellable / abortable)
- Rich PDF domain model: documents, pages, bookmarks, annotations, form fields, permissions, search
- Utility helpers (
unionFlags,PdfTaskHelper, …)
Installation
npm install @embedpdf/modelsBasic Usage
import { Rect, transformRect, Rotation } from '@embedpdf/models';
const pageSize = { width: 612, height: 792 }; // Letter size
const annotation: Rect = {
origin: { x: 100, y: 150 },
size: { width: 200, height: 50 },
};
// Rotate 90° and scale by 1.5×
const transformed = transformRect(pageSize, annotation, Rotation.Degree90, 1.5);
console.log(transformed);Learn More
Check the docs for deep dives into:
- Geometry API – positions, quads, rectangles
- Task abstraction – cancellable async workflows
- Complete Type Reference – every interface & enum used across the stack
License
MIT – see the LICENSE file.
