@x12i/reportix-composer-core
v0.6.0
Published
Reportix Composer rendering engine: HTML, PDF, DOCX, and PPTX export plus template store.
Downloads
287
Maintainers
Readme
@x12i/reportix-composer-core
The rendering engine and template store behind Reportix Composer. Every other surface (CLI, API, MCP server, UIs) is a thin wrapper around this package.
Install
npm install @x12i/reportix-composer-corePDF export uses Playwright Chromium. Install the browser once after adding this package:
npx playwright install chromiumQuick start
import {
renderToHtml,
renderToPdf,
renderToDocx,
renderToPptx,
TemplateStore,
createTemplateFromImage,
shutdown
} from "@x12i/reportix-composer-core";
const markdown = "# Quarterly report\n\nHello {{data.name}}.";
const { html, title } = await renderToHtml(markdown, "clean-report", {
data: { name: "world" }
});
const pdfBuffer = await renderToPdf(markdown, "clean-report", { data: { name: "world" } });
const docxBuffer = await renderToDocx(markdown, "clean-report", { data: { name: "world" } });
const pptxBuffer = await renderToPptx(markdown, "clean-report", { data: { name: "world" } }); // landscape 16:9; H1 = new slide
const store = new TemplateStore();
await store.list();
await store.get("clean-report");
await store.createFromHtml({
id: "my-report",
name: "My Report",
layoutHtml: "<!doctype html><html><head></head><body><!--CONTENT--></body></html>",
stylesCss: "body { font-family: Georgia, serif; }"
});
// Optional: draft a template from a design screenshot (requires Anthropic API key)
await createTemplateFromImage({
id: "from-design",
name: "From Design",
imageBuffer,
imageMediaType: "image/png",
anthropicApiKey: process.env.ANTHROPIC_API_KEY!
});
// Always close the headless browser when finished
await shutdown();renderToHtml / renderToPdf / renderToDocx / renderToPptx all take (markdown, templateId, options?), where options can
override templatesDir / assetsDir, supply frontmatterOverrides, or override PDF page settings (options.pdf).
PPTX slides are always landscape 16:9. Each # heading starts a new slide; an optional title slide is added when a document title is present.
Image assets
AssetStore registers reusable images under ~/.reportix-composer/assets (override with REPORTIX_COMPOSER_ASSETS_DIR or assetsDir). Reference them in Markdown or frontmatter as {{image:<token>}}; the renderers resolve tokens to data: URIs before format-specific output.
How templates work
A template is a directory with template.json, layout.html, and styles.css. Built-ins ship read-only inside
@x12i/reportix-composer-templates. User-created templates live in a writable directory (default
~/.reportix-composer/templates, overridable via REPORTIX_COMPOSER_TEMPLATES_DIR or templatesDir). Create / update / delete
only touch that directory, never the built-ins.
CSS is injected by replacing the template's </head> tag, so every layout.html must contain one.
Manifests include format-specific configs: docx (Word styles/page) and pptx (slide size/fonts/styles).
Environment variables
| Variable | Purpose |
| --- | --- |
| REPORTIX_COMPOSER_TEMPLATES_DIR | Override user templates directory |
| REPORTIX_COMPOSER_ASSETS_DIR | Override image assets directory |
| ANTHROPIC_API_KEY | Used by createTemplateFromImage when no key is passed inline |
Known limitations
- PDF/HTML images: absolute
http(s)URLs, data URIs, or{{image:<token>}}asset references. - DOCX / PPTX images: local paths, URLs, data URIs, and asset tokens; failures become
[image: alt]placeholders. - DOCX / PPTX code blocks: monospace paragraphs with shading — no syntax highlighting.
- DOCX fonts: must be names Word can resolve locally.
- PPTX overflow: content under a single H1 is not auto-split across slides.
themevsdocx.styles/pptx.styles: not kept in sync automatically after creation.- Raw HTML in markdown: passed through for HTML/PDF; dropped for DOCX and PPTX.
Related packages
@x12i/reportix-composer-cli— command-line tool@x12i/reportix-composer-api— HTTP server@x12i/reportix-composer-mcp-server— MCP server
