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

Cannot read property 'TYPED_ARRAY_SUPPORT' of undefined (pdfmake v0.1.32) #1100

Closed
davidbeers opened this Issue Aug 11, 2017 · 9 comments

Comments

Projects
None yet
6 participants
@davidbeers
Copy link

davidbeers commented Aug 11, 2017

I've seen that #624 which first reports this issue is closed with note that a fix was released in Dec '16. However I see this error running in an Angular 2 application and webpack with pdfmake 0.1.32.

let pdfMake = require('pdfmake/build/pdfmake.js');
require('pdfmake/build/vfs_fonts.js');

@Component({
...
})
export class PdfReportComponent implements OnInit {
    ngOnInit() {
        let docDefinition = { content: 'PDF is in the house!' };
        pdfMake.createPdf(docDefinition).open();
    }
}

Stacktrace:

pdfmake.js:48 Uncaught TypeError: Cannot read property 'TYPED_ARRAY_SUPPORT' of undefined
    at Object.eval (webpack:///./~/pdfmake/build/pdfmake.js?:48:38)
    at Object.exports.byteLength (webpack:///./~/pdfmake/build/pdfmake.js?:169:32)
    at __webpack_require__ (webpack:///./~/pdfmake/build/pdfmake.js?:10:27)
    at Object.eval (webpack:///./~/pdfmake/build/pdfmake.js?:20:2086)
    at __webpack_require__ (webpack:///./~/pdfmake/build/pdfmake.js?:10:27)
    at Object.eval (webpack:///./~/pdfmake/build/pdfmake.js?:16:267)
    at Object.eval (webpack:///./~/pdfmake/build/pdfmake.js?:16:320)
    at __webpack_require__ (webpack:///./~/pdfmake/build/pdfmake.js?:10:27)
    ...

What am I missing, please?

@jovabe

This comment has been minimized.

Copy link

jovabe commented Aug 21, 2017

Having the same issue.

@ldevalbray

This comment has been minimized.

Copy link

ldevalbray commented Oct 15, 2017

Same issue here:s

@ldevalbray

This comment has been minimized.

Copy link

ldevalbray commented Oct 15, 2017

@liborm85 It would be really cool to fix it ! :D Thank you for your awesome work anyway

@liborm85

This comment has been minimized.

Copy link
Collaborator

liborm85 commented Oct 15, 2017

In issue #624 it was fixed by update webpack.

According to comment above is now error on other line (line 48), but on this line is this code:

__webpack_require__.p = "";

This has nothing to do with array. I do not know how to fix this error now.

@ldevalbray

This comment has been minimized.

Copy link

ldevalbray commented Oct 15, 2017

image
My logs say the error is there. And I do have the latest version of webpack :s

@ldevalbray

This comment has been minimized.

Copy link

ldevalbray commented Oct 15, 2017

Okay, I managed to solve it.
So, for anyone using webpack :

Import pdfMake like so :
import pdfMake from "pdfmake/build/pdfmake";
import pdfFonts from "pdfmake/build/vfs_fonts";
pdfMake.vfs = pdfFonts.pdfMake.vfs;

plus adding the config in webpack
exclude: [ /node_modules/, /pdfmake.js$/ ]

Good luck !

liborm85 added a commit that referenced this issue Oct 20, 2017

@liborm85

This comment has been minimized.

Copy link
Collaborator

liborm85 commented Oct 20, 2017

Solution added to readme by commit 4ad3c8d.

@liborm85 liborm85 closed this Oct 20, 2017

touchaqb added a commit to touchhealth/pdfmake that referenced this issue Nov 22, 2017

@nvizo

This comment has been minimized.

Copy link

nvizo commented Jan 27, 2018

I tried this but I am still getting the same error. Here is my config file.

var path = require('path');

module.exports = {
  plugins: [
    // your custom plugins                                                                                                       
  ],
  module: {
    rules: [
        {
            test: /\.js?$/,
            loader: 'babel-loader',
            exclude: [/node_modules/, /pdfmake.js$/ ]
        },
        {
            test: /\.scss$/,
            loaders: ["style-loader", "css-loader", "sass-loader"]
            //exclude: path.resolve(__dirname, 'src/app')                                                                        
        },
        {
            test: /\.(ttf|otf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/,
            loader: 'file-loader?name=fonts/[name].[ext]'
        }

    ]
  },
  resolve: {
        modules: [
            "browserify_components",
            "bower_components",
            "node_modules"
        ],
      extensions: ['.js','.jsx','.json'],
  },
}

@barocsi

This comment has been minimized.

Copy link

barocsi commented Feb 22, 2018

same here, still there using angular-cli 1.5, webpack 3.8.1

@barocsi barocsi referenced this issue Feb 22, 2018

Closed

Upgrade PDF make #60

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment