betterwrite / pdfeasy

📕 A JavaScript Client/Server Side PDF-Generator based in PDFKit
https://betterwrite.github.io/pdfeasy
MIT License
77 stars 4 forks source link

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

Open Shooteger opened 1 month ago

Shooteger commented 1 month ago

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 commented 1 month ago

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

Shooteger commented 1 week ago

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