BlockNote
BlockNote copied to clipboard
Custom font in PDF export
Is your feature request related to a problem? Please describe. We use custom fonts in our production block editor and want the same fonts to be used in our exported PDFs. Currently, it appears as though the editor font is hardcoded to Inter: https://github.com/TypeCellOS/BlockNote/blob/main/packages/xl-pdf-exporter/src/pdf/pdfExporter.tsx#L57C10-L74
Describe the solution you'd like
- Add support for overriding the default page styles, allowing a font to be specified. Ideally, other style properties like page margin could be altered, too, for future flexibility.
- Support registering custom fonts, overriding the default
registerFontmethod.
Describe alternatives you've considered No alternatives come to mind, aside from perhaps forgoing the default block / inline style mappers and writing our own versions for every block or inline content type. Doing so would decrease the value provided by the package.
Additional context Happy to submit a PR.
Bonus
- [x] I'm a sponsor and would appreciate if you could look into this sooner than later 💖
(https://github.com/poggiolabs is a sponsor)
Hi!
Thanks for the feedback. A currently possible alternative is to subclass PDFExporter and override registerFont to register the alternative font files, and change the font type in this.styles.
Have you considered this? I agree this might not be very clear, so happy to accept a PR with a clearer API and / or documentation (or we can do this on the next iteration or if this approach doesn't work).