Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I use the fonts that come with my system? #1515

Closed
luckymore opened this issue May 9, 2024 · 1 comment
Closed

How do I use the fonts that come with my system? #1515

luckymore opened this issue May 9, 2024 · 1 comment

Comments

@luckymore
Copy link

Question

My scenario is that after generating a pdf on the server side, the user downloads it locally and views it using the system's Chinese fonts. like STBaoliTC-Regular

Is it possible to do that?

Description

When I try to do this, it reports an error no such file or directory, open 'STBaoliTC-Regular'

doc.font('STBaoliTC-Regular')

Code sample

const doc = new PDFDocument({
  size: [595, 842],
})
doc.pipe(fs.createWriteStream('output.pdf'))
doc.font('STBaoliTC-Regular')
doc.text('你好,世界!')
doc.end()

Your environment

  • pdfkit version: 0.15.0
  • Node version: v20.12.2
  • Browser version (if applicable):
  • Operating System: macOs 14.1 (23B2073)
@blikblum
Copy link
Member

Is it possible to do that?

No. You have to embed the font at server side using doc.registerFont

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants