@zenuinebit/pdf-reports
v0.1.0
Published
PDF output for tables and GST reports (Node). Built on pdfkit.
Readme
@zenuinebit/pdf-reports
PDF output for tables and GST reports, for Node. Built on pdfkit; no browser needed. Uses the Table shape from @zenuinebit/report-export, so the same data can go to CSV, Excel or PDF.
import { renderTablePDF, renderTablesPDF, renderGstReportPDF } from "@zenuinebit/pdf-reports";
import { table } from "@zenuinebit/report-export";
// A GST report: summary, B2B, B2CS, by rate, HSN, invoices (empty sections left out)
const pdf = await renderGstReportPDF(report, {
subtitle: "ZenuineBit Foods - April 2025",
footer: "Confidential",
generatedOn: "Generated 2025-05-01",
locale: "en-IN", // 1,28,388.00
});
await fs.writeFile("gst-april.pdf", pdf);
// Any table
const sales = table("Sales", rows, [
{ header: "Invoice", value: "number" },
{ header: "Qty", value: "qty", type: "number" },
{ header: "Amount", value: "amount", type: "money" }, // integer minor units
]);
await renderTablePDF(sales, { totals: true }); // adds a Total row for money columns
await renderTablesPDF([sales, returns], { title: "Month end", pagePerTable: true });What you get
- Header row repeated on every page, zebra rows, "Page X of Y" and an optional footer.
- Money and numbers are right-aligned. Money cells are integers in minor units and are formatted for
locale. - Column widths follow the content; long text is cut with
...instead of overflowing. Wide tables (more than 6 columns) switch to landscape automatically. totals: trueadds a bold Total row under each table that has money columns and more than one row.renderGstReportPDFturns it on by default.
Good to know
- The built-in font covers Latin-1 only, so characters such as the rupee sign print as
?. Passfont(andfontBold) with a TrueType font such as Noto Sans to print them. generatedOnis not added automatically, so the same input always gives the same PDF.- One line per row: this is for tables of figures, not for paragraphs of text.
Not included: charts, images, custom cell styling, and invoices (see @zenuinebit/invoice-pdf).
