pdfmake
pdfmake copied to clipboard
Problem with custom font
I have an angular project I have installed pdfMake It generates my pdf. Everything seems ok. Now I want to install a new font and use it. Then I followed instructions: I placed my font (TitilliumWeb) in its different aspects (Regular, bold, italics, bolditalics) in example/fonts folder and launched
node build-vfs.js "./examples/fonts" OK, it creates a vfs_fonts.js file like:
this.pdfMake = this.pdfMake || {}; this.pdfMake.vfs = {
"TitilliumWeb-Black.ttf": "AAEAAAAPAIAAAwBwR0RFRgARAZoAAAEMAAAAFkdQT1NDfEofAAAcQAAAGZpHU1VCJ8AW5wAAAgAAAAGOT1MvMmvJguUAAAGgAAAAYGNtYXAorzP2AAADkAAAAaRnYXNwAAAAEAAAAQQAAAAIZ2x5Zms0XgkAADXcAAB0smhlYWQEdslgAAABaAAAAD...etc...
Now it was time to import it then I included
const pdfFonts = require("pdfmake/build/vfs_fonts");
pdfMake.vfs = pdfFonts.pdfMake.vfs;
Now I got the problem.
First of all if I console.log
console.log("pdfFonts.pdfMake.vfs:", pdfFonts.pdfMake.vfs);
it shows me Roboto and not Titillium (where the hell takes it from is a mistery for me)
But the main point is that when I write
pdfMake.fonts = {
TitilliumWeb: {
normal: 'TitilliumWeb-Regular.ttf',
bold: 'TitilliumWeb-Bold.ttf',
italics: 'TitilliumWeb-Italic.ttf',
bolditalics: 'TitilliumWeb-BoldItalic.ttf'
}
};
this stops the pdf generation.
Infact it arrives to
pdfMake.createPdf(docDefinition).download();
but there it doesn't do anything and does not throw any error
I have spent ONE WEEK so far on this without finding out any answer or doing any progress.
Any help to try to figure out what is wrong with my procedure is appreciated
same here, any solution?
For reference:
以供参考:
![]()
How do you define multiple fonts that are used in different languages
same problem here, any solution? I use Angular V17