pdfeasy icon indicating copy to clipboard operation
pdfeasy copied to clipboard

Error on using costume fonts Nuxt 3: Uncaught (in promise) TypeError: r.readFileSync is not a function

Open Shooteger opened this issue 1 year ago • 3 comments
trafficstars

Hello, please help me. I tried using a costume font exactly as in the example code. I made a public/fonts folder and added the fonts. Even with the https://domain and full path it does not work. I get this error:

Uncaught (in promise) TypeError: r.readFileSync is not a function

And then the text just disappears and does not get rendered in my PDF.

Please, how to use a costume font? I wanna use Inter (free to use from google fonts) but on my server, not remote link. I add the fonts like this:

    $pdf.addFonts([
      {
        name: 'Inter',
        normal: `fonts/Inter-Regular.ttf`,
        bold: `fonts/Inter-Bold.ttf`,
        italic: `fonts/Inter-Italic.ttf`,
        bolditalic: `fonts/Inter-BoldItalic.ttf`,
      }
    ]);

And then use it here:

$pdf.add([
     { raw: `TEST my font here`, text: { fontSize: 24, bold: true, font: 'Inter' } },
    ]);

But it does not work... see upper error. I just want my whole PDF using this font.

Shooteger avatar Aug 01 '24 06:08 Shooteger

Using it on the client side btw. in a component.

Shooteger avatar Aug 01 '24 06:08 Shooteger

is this package maintained or better to create a fork and self maintain it?

Shooteger avatar Sep 06 '24 13:09 Shooteger

@Shooteger I can't simulate your problem because mine worked normally. Could you upload your project somewhere so I can check?

Novout avatar Feb 07 '25 20:02 Novout