ddast-util-to-pdfmake
v0.2.0
Published
ddast utility that compiles ddast into pdfmake's TDocumentDefinitions
Readme
ddast-util-to-pdfmake
A utility that transcribes an already-styled
ddast tree into
pdfmake's TDocumentDefinitions (docDefinition).
import { ddastToDocDefinition } from "ddast-util-to-pdfmake";
const dd = ddastToDocDefinition(styledDdastRoot, { baseDir: import.meta.dirname });Also usable as a unified Compiler (pdfmakeCompiler).
Responsibilities
- Transcribes only the information already written into ddast into pdfmake's key names
and shapes — it never computes a new value (color, size, lineHeight, fillColor, coordinates,
...) from a structural fact such as
depth/role/row position. - Three exceptions are the compiler's own job: assembling the named style dictionary (theme →
docDefinition.styles), joining a local image path withbaseDir, and validating an external link's URL scheme (rejectingjavascript:etc.). - Does not validate whether an image/font/attachment is actually allowed to be read — pdfmake
itself reads/fetches those, and the caller decides what's allowed via
pdfmake-render'sRenderPolicy.
For the full boundary of responsibilities (including the rationale for the three exceptions), see "compiler.ts (ddast → docDefinition)" in ARCHITECTURE.md.
