Repository navigation
Replies: 1 comment
|
Yes. pdf-lib 1.17.1 accepts both a plain base64 string and a complete data URI directly in Custom fonts also require the separate const pdfDoc = await PDFLib.PDFDocument.create();
pdfDoc.registerFontkit(fontkit);
const customFont = await pdfDoc.embedFont(fontDataUri);
const page = pdfDoc.addPage();
page.drawText('ůúřčž', { font: customFont, size: 20 });
const pdfBytes = await pdfDoc.save();Use a font that actually contains those Czech glyphs. If this still reports The abbreviated string in the question isn't enough to determine which encoding step went wrong, but data URIs themselves are supported. This avoids a separate References: embedFont API and string examples, fontkit installation and browser globals, and the 1.17.1 implementation. |
Uh oh!
There was an error while loading. Please reload this page.
Is possible to embed custom font encoded in base64 stored in js string like ''data:font/ttf;base64,8JCAgPS..." ?
I develop html page that loads from local html file and need export pdf files. Unfortunetly i need to use special characters like 'ůúřčž' and other, thats not possible with default fonts. When i try to load font from file i got Cross-Origin errors.
Becouse i resolved this problem before for images (using base64 encoded strings) iam curious if this is posible for font also?
This code resolves into Unknown font format error and i dont know what can i try next.
All reactions