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

registerAFMFonts not using default Helvetica font exports #2

Closed
jarommadsen opened this issue Aug 19, 2019 · 1 comment
Closed

registerAFMFonts not using default Helvetica font exports #2

jarommadsen opened this issue Aug 19, 2019 · 1 comment

Comments

@jarommadsen
Copy link

jarommadsen commented Aug 19, 2019

I was running into the same errors as this issue and was particularly confused about this error:

Uncaught (in promise) TypeError: Cannot read property 'split' of undefined
    at new AFMFont (pdfkit.es5.js:2453)
    at new StandardFont (pdfkit.es5.js:2700)
    at Function.open (pdfkit.es5.js:3096)
    at PDFDocument.font (pdfkit.es5.js:3170)
    at PDFDocument.initFonts (pdfkit.es5.js:3132)
    at new PDFDocument (pdfkit.es5.js:4890)
    at new PDFBuilder (PDFBuilder.js:42)
    at PDFCreator.createID (index.jsx:40)
    at PDFCreator.componentDidMount (index.jsx:72)

The proposed workaround was to do a direct import from raw-loader:

import Helvetica from '!!raw-loader!pdfkit/js/data/Helvetica.afm'

This was strange to me as removing the !!raw-loader! portion still seemed to work and furthermore adding !!raw-loader! to the require.context call did not fix the error.

Turns out you just needed to use the default export of the files to avoid the error:

fs.writeFileSync(`data/${match[0]}`, ctx(key).default);

Not sure if this was a pdfkit update or what but it'd be good to update that line.


"pdfkit": "^0.10.0"
"webpack": "^4.39.2"
"arraybuffer-loader": "^1.0.7"
"raw-loader": "^3.1.0"
"transform-loader": "^0.2.4"

@blikblum
Copy link
Owner

The raw-loader changed how data is exported see: webpack-contrib/raw-loader#69

I updated the code accordingly

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