Cannot import `fontkit` from @pdf-lib/fontkit
See original GitHub issueI am building an Angular project and trying to import fontkit as described in the README instruction.
import fontkit from '@pdf-lib/fontkit'
gives an error that says Module '"/node_modules/@pdf-lib/fontkit/fontkit"' has no default export.
I tried using import * as fontkit from '@pdf-lib/fontkit'
, and this error does go away, but instead when I am registering this fontkit and using my custom font, it gives the error that says fontkit.create is not a function.
What I want to achieve is to write my Chinese characters on the pdf. How should I import this fontkit
and use it correctly?
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
@pdf-lib/fontkit - npm
An advanced font engine for Node and the browser. Latest version: 1.1.1, last published: 2 years ago. Start using @pdf-lib/fontkit in your ...
Read more >Attempted import error: 'create' is not exported from 'fontkit ...
js Attempted import error: 'create' is not exported from 'fontkit' (imported as 'fontkit'). I tried to use different versions of this package, ...
Read more >pdf-lib with fontkit won't allow custom fonts | Velo by Wix
All is working perfectly except that when trying to embed a custom font I get the error that fontkit.create() is not an existing...
Read more >@pdf-lib/fontkit examples - CodeSandbox
Learn how to use @pdf-lib/fontkit by viewing and forking @pdf-lib/fontkit example apps on CodeSandbox.
Read more >@pdf-lib/fontkit NPM | npm.io
import fontkit from '@pdf-lib/fontkit'; import fs from 'fs'; // open a font synchronously const fontData = fs.readFileSync('font.ttf'); const font ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hello @Pomelool! You can add
"esModuleInterop": true
or"allowSyntheticDefaultImports": true
to the"compilerOptions"
section of your Angular project’stsconfig.json
file. For example:or
I hope this helps. Please let me know if you have any additional questions!
@btielen thanks a ton! Fixed everything for me as well.