typepress-pdf
v0.4.0
Published
Pure Rust HTML/CSS → PDF engine — Node.js binding
Maintainers
Readme
TypePress PDF
Pure Rust HTML/CSS → PDF engine. No browser required.
import { TypePress } from 'typepress-pdf';
const tp = new TypePress();
// HTML → PDF
await tp.htmlToPdf('report.html', 'report.pdf', {
size: 'A3',
landscape: true,
});
// Markdown → PDF
await tp.mdToPdf('README.md', 'readme.pdf');Install
npm install typepress-pdfThe package auto-downloads the typepress binary for your platform on first use.
API
new TypePress(binaryPath?: string)
Create a TypePress instance. Auto-discovers or downloads the binary.
tp.convert(input, output, options?)
Convert HTML/Markdown → PDF.
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| size | string | — | Page size: A4, A3, Letter |
| landscape | boolean | false | Landscape orientation |
| margin | string | — | Margins e.g. '20mm' |
| inputFormat | 'html' \| 'md' | 'html' | Input format |
tp.htmlToPdf(input, output, options?)
tp.mdToPdf(input, output, options?)
Convenience methods. Return the output path.
