"fs is not defined" in the prebuild version
See original GitHub issueHi, I don’t use NodeJS so I use the prebuild version of PDFKit to generate the PDF. I imported the library in the HTML file `<script src="Scripts/blob-stream.js" type="text/javascript"></script>
<script src="Scripts/pdfkit.js" type="text/javascript"></script>`It worked well with built-in fonts.
When I registered a font from a file and used it
doc.registerFont('OpenSans-Regular', 'fonts/OpenSans-Regular.ttf', 'OpenSans-Regular'); doc.font('OpenSans-Regular');
I got this error
Uncaught ReferenceError: fs is not defined at Object.fontkit.openSync (pdfkit.js:16213) at Function.PDFFont.open (pdfkit.js:12888) at PDFDocument.font (pdfkit.js:14673)
Can anyone please guide me how to solve this problem?
Thanks!
Issue Analytics
- State:
- Created 7 years ago
- Comments:6
Top Results From Across the Web
"fs is not defined" in the prebuild version #715 - foliojs/pdfkit
Hi, I'm trying to load custom font ttf files in the prebuilt version but currently getting the error: "Uncaught ReferenceError: fs is not...
Read more >Node script ReferenceError: fs is not defined error in test script
I get this error: fs = require('fs'); ^ ReferenceError: fs is not defined at Object.<anonymous> ...
Read more >Getting Started - ESBuild
Getting Started. #Install esbuild. First, download and install the esbuild command locally. A prebuilt native executable can be installed using npm (which ...
Read more >pkg - npm
Package your Node.js project into an executable. Latest version: 5.8.0, last published: 6 months ago. Start using pkg in your project by ...
Read more >Built-in Functions — Python 3.11.1 documentation
The Python interpreter has a number of functions and types built into it that are always available. They are listed here in alphabetical...
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 FreeTop 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
Top GitHub Comments
Hi, You are right, I didn’t load the font data correclty. Here’s the code for those who need it (jQuery doesn’t support binary datatype on ajax call)
@ninbit It has been a long time since I worked with that project so I can’t remember. However, I guess
font
is just my local object to define font name and url. You can define it the way you like, just make sure that you can pass it to the above function to load it and render your text.You get CORS error because you dev site and your font are not on the same domain, I guess. I used localhost for my dev site so I had no problem with it.
It’s not relevant to this topic though but I’m willing to help.