Node.js PDF SDK for Editing Existing PDFs
Edit existing PDF text and objects from Node.js 20+ with TypeScript support, asynchronous operations, explicit layout modes, and structured result diagnostics.
Working Example
Read PDF bytes, await the edit, and validate the response
Download the public quick-start PDF as input.pdf. This byte-input example checks both errors and the expected change count before writing the result.
Supported Operations
Call typed APIs for text, pages, images, forms, vectors, and fonts
Typed text requests
Build literal or regular-expression replace, insert, delete, and style operations with TypeScript types.
Read the operation guideExplicit layout modes
Choose source anchoring, supported reflow with fallback, or required reflow on each request.
Read the operation guidePDF object operations
Work asynchronously with pages, images, vector paths, AcroForms, Form XObjects, and fonts.
Read the operation guideByte-oriented output
Save to a server path or use getBytes() to return, store, or pass the edited PDF onward.
Read the operation guideStructured Text Extraction
Extract typed reading units from a document or page
Analyze the current session as classified text blocks with reading order, source-element provenance, page-space bounds, and relationships. Each asynchronous call reflects the current session state.
Read the structured-text guideLayout and Diagnostics
Choose between anchored placement, reflow when possible, and required reflow
Select how replacement text should behave when its length changes: keep it anchored to the original position, reflow it when the document structure supports reflow, or require reflow and return an error when it cannot be applied.
sourceAnchored()retains the selected source position.reflowWhenSupported()permits source-anchored fallback.requireReflow()reports unsupported targets as errors.
Framework Integration
Return edited bytes from an Express route
The route reads uploaded bytes from Multer memory storage, checks the SDK result, and returns the edited PDF. Configure upload-size limits in Multer, authentication in Express middleware, timeouts in the HTTP server or deployment platform, and error responses in Express error-handling middleware.
Compatibility and Limits
Check runtime and deployment constraints
- The package targets Node.js 20+. Node.js support does not establish compatibility with edge-worker runtimes.
- PDFDancer uses a hosted service; installing the npm package does not create an offline PDF processor.
- Text selectors require editable PDF text rather than outlines, paths, page images, or unsupported encodings.
- reflowWhenSupported() can fall back to source-anchored placement. Inspect per-change diagnostics.
- Font registration does not guarantee that a font includes every replacement character.
- Saving output does not certify PDF/A conformance, preserve signatures, or provide security redaction.
Node.js Resources
Continue from the TypeScript quick start to the API reference
Questions
Node.js PDF SDK questions
Start Using PDFDancer Today
Get started in seconds with our free tier. No credit card required.
Want to evaluate first? Run the anonymous quick start. Current usage limits are on the pricing page.