Skip to content

Conversation

@ralfstx
Copy link
Member

@ralfstx ralfstx commented Dec 14, 2024

So far, font data had to be embedded directly within the document definition, despite being more logically associated with the renderer than the document itself. This also made it hard to inspect or debug document definitions due to the inclusion of large binary font data.

This commit introduces a new PdfMaker class that replaces the makePdf function. This class allows font data to be registered separately and reused across multiple documents. With this approach, font data is no longer part of the document definition.

Example:

const pdfMaker = new PdfMaker();
pdfMaker.registerFont(await readFile('path/to/MyFont.ttf'));
pdfMaker.registerFont(await readFile('path/to/MyFont-Bold.ttf'));
const pdf1 = await pdfMaker.makePdf(doc1);
const pdf2 = await pdfMaker.makePdf(doc2);

So far, font data had to be embedded directly within the document
definition, despite being more logically associated with the renderer
than the document itself. This also made it hard to inspect or debug
document definitions due to the inclusion of large binary font data.

This commit introduces a new `PdfMaker` class that replaces the
`makePdf` function. This class allows font data to be registered
separately and reused across multiple documents. With this approach,
font data is no longer part of the document definition.

Example:

```ts
const pdfMaker = new PdfMaker();
pdfMaker.registerFont(await readFile('path/to/MyFont.ttf'));
pdfMaker.registerFont(await readFile('path/to/MyFont-Bold.ttf'));
const pdf1 = await pdfMaker.makePdf(doc1);
const pdf2 = await pdfMaker.makePdf(doc2);
```
@ralfstx ralfstx merged commit f9e7be5 into main Dec 15, 2024
1 check passed
@ralfstx ralfstx deleted the pdf-maker branch December 15, 2024 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants