xdp-pdf-render
v0.1.0-canary.20260614130440.6277cd3
Published
Render PDF documents from XDP templates, XSD schemas, and XML data — no SAP/Adobe dependency
Downloads
57
Maintainers
Readme
xdp-pdf-render
Render PDF documents from XDP templates, XSD schemas, and XML data — no SAP/Adobe dependency.
Replaces SAP Adobe Forms Service by taking an XDP template, an XSD schema, and XML data — and producing a PDF — entirely in Node.js with zero SAP dependencies.
Installation
npm install xdp-pdf-renderUsage
Programmatic API
import { render } from 'xdp-pdf-render';
import { readFileSync, writeFileSync } from 'fs';
const result = await render({
xdp: readFileSync('templates/invoice.xdp', 'utf8'),
xsd: readFileSync('schemas/invoice.xsd', 'utf8'),
data: readFileSync('data/invoice-001.xml', 'utf8'),
});
if (result.success) {
writeFileSync('output/invoice.pdf', result.data);
console.log('PDF generated successfully');
} else {
console.error(`[${result.error.code}] ${result.error.message}`);
}CLI
# Render a PDF
xdp-pdf render --xdp template.xdp --xsd schema.xsd --data data.xml --output invoice.pdf
# Validate without rendering
xdp-pdf validate --xdp template.xdp --xsd schema.xsd --data data.xml
# Inspect parsed template structure
xdp-pdf inspect --xdp template.xdp --output jsonArchitecture
The module follows a Handler → Workflow → Domain → Lib layered pattern:
src/
├── index.ts ← Public API
├── cli.ts ← CLI entry point
├── workflows/ ← Orchestration (I/O + Pure)
│ └── render-pdf.ts
├── domain/ ← Pure Functions (NO I/O)
│ ├── parsing/
│ ├── validation/
│ ├── mapping/
│ └── layout/
├── rendering/ ← I/O Boundary (PDF generation)
├── lib/ ← Generic Utilities
├── config/ ← Configuration as Data
└── errors/ ← Error definitionsAll domain functions are pure (no I/O, no side effects) and return a Result<T> type:
type Result<T> = { success: true; data: T } | { success: false; error: ErrorResult };Pipeline
XDP Template + XSD Schema + XML Data
│
Parse (pure)
│
Validate (pure)
│
Map data → layout (pure)
│
Calculate positions (pure)
│
Paginate (pure)
│
Render PDF (I/O)
│
BufferDevelopment
npm install
npm run build
npm testLicense
MIT
