Embed Liberation Sans in invoice PDFs for PDF/A-3 compliance (v0.2.6)
Validate e-invoices / mustang (push) Successful in 41s
Validate e-invoices / mustang (push) Successful in 41s
An E-Rechnung checker flagged that generated invoices don't embed their fonts. Both invoicePdf.tsx and correctionInvoicePdf.tsx used react-pdf's built-in Helvetica/Helvetica-Bold, which is never embedded — PDF/A-3 (already required by this package's own Factur-X/ZUGFeRD pipeline) has no exemption for standard fonts. Vendors Liberation Sans (SIL OFL-1.1, metrically identical to Helvetica) and registers it via Font.register in a new fonts.ts, imported by both PDF modules. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import { Font } from "@react-pdf/renderer";
|
||||
|
||||
// Registered once here (not inline in invoicePdf.tsx/correctionInvoicePdf.tsx)
|
||||
// and imported by both for its side effect — avoids double-registering the
|
||||
// same family when renderEInvoice.ts imports both PDF modules in the same
|
||||
// process.
|
||||
//
|
||||
// Liberation Sans, not built-in Helvetica: PDF/A-3 (required by the
|
||||
// Factur-X/ZUGFeRD pipeline in src/einvoice/) has no exemption for the
|
||||
// standard/base-14 fonts react-pdf ships — every font actually used must be
|
||||
// embedded, and react-pdf only embeds fonts it has real font-file bytes for
|
||||
// via Font.register. Liberation Sans is metrically identical to Helvetica/
|
||||
// Arial (SIL Open Font License, see src/assets/fonts/LICENSE-OFL.txt), so
|
||||
// embedding it doesn't shift any existing layout.
|
||||
Font.register({
|
||||
family: "Liberation Sans",
|
||||
fonts: [
|
||||
{ src: new URL("./assets/fonts/LiberationSans-Regular.ttf", import.meta.url).pathname, fontWeight: "normal" },
|
||||
{ src: new URL("./assets/fonts/LiberationSans-Bold.ttf", import.meta.url).pathname, fontWeight: "bold" },
|
||||
],
|
||||
});
|
||||
Reference in New Issue
Block a user