pdfmake icon indicating copy to clipboard operation
pdfmake copied to clipboard

Problem with custom font

Open nicolacardi opened this issue 1 year ago • 4 comments

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

nicolacardi avatar Apr 22 '23 14:04 nicolacardi

same here, any solution?

Deibi12 avatar Apr 24 '23 15:04 Deibi12

For reference: image image

Jackyyans avatar May 08 '23 08:05 Jackyyans

以供参考: 图像 图像 How do you define multiple fonts that are used in different languages

Kimser avatar Nov 16 '23 06:11 Kimser

same problem here, any solution? I use Angular V17

12michel34 avatar Dec 06 '23 10:12 12michel34