@siliph/pdf-engine
v0.3.0
Published
Complete browser-native PDF editing engine — parse, render, merge, split, edit text, fill forms, sign, encrypt, annotate, and export PDFs entirely client-side. No server required. TypeScript-first with tree-shaking support.
Downloads
214
Maintainers
Keywords
Readme
Install
npm install @siliph/pdf-engineThis is the umbrella package that re-exports everything from the core, UI, and plugin SDK packages. Recommended for most users.
Quick Start
import { mergePdfs, splitPdf, rotate, fillForm, addWatermark, search } from '@siliph/pdf-engine';
// Merge two PDFs
const merged = await mergePdfs([doc1, doc2]);
if (merged.ok) console.log(`${merged.value.getPageCount()} pages`);
// Split by ranges
const parts = await splitPdf(doc, [{ start: 0, end: 4 }, { start: 5, end: 9 }]);
// Rotate page 1 by 90°
const cmd = await rotate(doc, 0, 90);
if (cmd.ok) doc.applyCommand(cmd.value);
// Fill form fields
await fillForm(doc, { name: 'Jane', email: '[email protected]', agree: true });
// Add watermark
await addWatermark(doc, { text: 'DRAFT', opacity: 0.2, rotation: 45 });
// Search text (async generator)
for await (const hit of search(doc, 'total')) {
console.log(`Page ${hit.pageIndex}, offset ${hit.offset}`);
}Why Siliph?
| | Siliph | Sejda | Adobe SDK | PDF.js | pdf-lib | |---|---|---|---|---|---| | Runs in browser | ✅ | ❌ | ❌ | ✅ | ✅ | | Edit text in-place | ✅ | ✅ | ✅ | ❌ | ❌ | | Merge/Split | ✅ | ✅ | ✅ | ❌ | ✅ | | Digital signatures | ✅ | ✅ | ✅ | ❌ | ❌ | | AcroForms | ✅ | ✅ | ✅ | Read-only | ✅ | | Encryption | ✅ | ✅ | ✅ | ❌ | ❌ | | Full renderer | ✅ | ❌ | ✅ | ✅ | ❌ | | Tree-shakeable | ✅ | ❌ | ❌ | ❌ | Partial | | Plugin system | ✅ | ❌ | ❌ | ❌ | ❌ | | Zero dependencies | ✅ | ❌ | ❌ | ❌ | ❌ | | MIT license | ✅ | AGPL | Proprietary | Apache | MIT |
All 20 Task Functions
| Function | Description |
|----------|-------------|
| mergePdfs | Merge multiple documents into one |
| splitPdf | Split by page ranges |
| splitByBookmarks | Split at bookmark boundaries |
| splitBySize | Split into max-size chunks |
| extractPages | Extract specific pages |
| rotate | Rotate pages (90°/180°/270°) |
| crop | Crop (metadata or content clip) |
| compress | Remove unused resources |
| addWatermark | Add text watermark |
| setHeaderFooter | Headers/footers with page numbers |
| setMetadata | Set title, author, keywords |
| redact | Visual or permanent redaction |
| fillForm | Fill AcroForm fields |
| search | Full-text search (async generator) |
| mixPages | Alternate pages from multiple docs |
| addBackPages | Back pages for duplex printing |
| setBookmarks | Set document outline |
| getBookmarks | Read bookmarks |
| pdfToImages | Convert pages to PNG/JPEG |
14 Engines
Parser · Rendering · Font · Text · Image · Annotation · Forms · Security · Page · Export · Search · Selection · Graphics · Validation
Key Capabilities
- Parsing: Lazy object resolution, XRef streams, brute-force recovery, linearized PDFs
- Rendering: Canvas2D + OffscreenCanvas Workers, blend modes, transparency groups
- Fonts: TrueType, Type1, CID, CMap, ToUnicode, glyph LRU cache, Standard 14
- Text: In-place editing, kerning preservation, RTL/BiDi, selection + clipboard
- Images: JPEG, JPEG2000, JBIG2, CCITTFax, Flate, SMask compositing
- Security: RC4, AES-128, AES-256, PKCS#7 digital signatures, permissions
- Forms: All field types, validation, radio groups, appearance regeneration
- Export: Incremental save, full save with GC, streaming, Worker offload
- Accessibility: Screen reader text layer, ARIA, keyboard nav, focus trapping
- Validation: PDF/A-1b conformance checking
Performance
| Operation | Time | |-----------|------| | Parse 500-page (12MB) | ~85ms | | First page render | ~180ms | | Merge 150 pages | ~45ms | | Full-text search (200pg) | ~120ms | | AES-256 decrypt | ~95ms |
Packages
| Package | Description |
|---------|-------------|
| @siliph/pdf-engine | Umbrella (this package) |
| @siliph/pdf-engine-core | Parser, engines, task API |
| @siliph/pdf-engine-ui | Viewport, toolbar, accessibility |
| @siliph/pdf-engine-plugin-sdk | Plugin extension system |
Browser Support
Chrome 90+ · Firefox 90+ · Safari 15+ · Edge 90+ · Node.js 18+
Links
- 🌐 siliph.com — Documentation
- 📦 GitHub — Source code
- 🐛 Issues — Bug reports
- 💖 Sponsor — Support development
License
MIT
