@denreport/targets
v0.1.0
Published
Exporters from the denreport IR to pdfme templates and self-contained ReportLab Python scripts. Bundles Noto Sans JP for Japanese typesetting.
Maintainers
Readme
@denreport/targets
Export targets for denreport's IR
(@denreport/core):
turn an IrDocument into a pdfme template + input
JSON, or a self-contained ReportLab Python
script. Also provides the font loading/validation used by both exporters
(resolveFontSetData, validateFont, detectFontFormat, ...). Bundles
the Regular and Bold weights of Noto Sans JP (SIL OFL 1.1) so Japanese
text renders correctly out of the box. (Per-target compatibility matrices —
COMPAT_MATRICES / checkCompat — live in
@denreport/core, not
here.)
Install
npm install @denreport/targetsUsage
import { readFile } from "node:fs/promises";
import { emptyDataFor, parseIr } from "@denreport/core";
import { EMBEDDED_FONT_URL, exportPdfme } from "@denreport/targets";
const parsed = parseIr(irJsonString);
if (!parsed.ok) throw new Error("invalid IR");
const regular = await readFile(EMBEDDED_FONT_URL);
const result = exportPdfme(parsed.document, emptyDataFor(parsed.document), {
regular,
});
if (result.ok) {
// result.template and result.inputs are ready for @pdfme/generator
} else {
console.error(result.errors, result.fontIssues);
}exportReportlab has the same signature and instead returns a ReportLab
Python script (ExportReportlabResult). Both require a FontSetData (raw
TTF bytes per font slot) — EMBEDDED_FONT_URL points at the bundled Noto
Sans JP font that ships in this package's assets/ directory.
See the monorepo README for the full picture, including the license terms that apply to exported output and the bundled font.
License
MIT. The bundled Noto Sans JP fonts are licensed separately under the SIL
Open Font License 1.1 (see assets/fonts/OFL.txt in this package).
