pdfmake icon indicating copy to clipboard operation
pdfmake copied to clipboard

Unhandled promise rejection TypeError: null is not a function

Open GauravNagpure opened this issue 3 years ago • 12 comments

I am using pdfmake with Angular application to generate pdf with table, which is working fine. Generated pdf is also the correct one. But I see this error in log

image

Not sure why see this error.

GauravNagpure avatar Jun 02 '22 08:06 GauravNagpure

Attach runnable example for reproduce issue.

liborm85 avatar Jun 02 '22 13:06 liborm85

    `const documentDefinition = {
      content: [
        {
          table: {
            widths: [100, '*', 200, '*'],
            body: [
              ['width=100', 'star-sized', 'width=200', 'star-sized'],
              [
                'fixed-width cells have exactly the specified width',
                { text: 'nothing interesting here', italics: true, color: 'gray' },
                { text: 'nothing interesting here', italics: true, color: 'gray' },
                { text: 'nothing interesting here', italics: true, color: 'gray' },
              ],
            ],
          },
        },
      ],
      pageSize: 'A4',
      pageOrientation: 'landscape',
      pageMargins: [20, 30, 20, 30],
    };
    pdfMake.createPdf(documentDefinition).download(`myPDF.pdf`);`

GauravNagpure avatar Jun 06 '22 08:06 GauravNagpure

This code works on playground correctly.

liborm85 avatar Jun 07 '22 11:06 liborm85

I am using +-- [email protected] | +-- @foliojs-fork/[email protected] | +-- @foliojs-fork/[email protected] | +-- [email protected] | -- [email protected]

with "@angular/cli": "^8.3.29" and node version v12.20.0

GauravNagpure avatar Jun 07 '22 13:06 GauravNagpure

Runnable example was requested above.

liborm85 avatar Jun 07 '22 14:06 liborm85

Hi @liborm85, thank you for your early replies. I have created same environment and added the snippet here. Please refer: https://github.com/GauravNagpure/pdfmake-issue

GauravNagpure avatar Jun 08 '22 12:06 GauravNagpure

Hi @liborm85, did you find the solution to the issue?

GauravNagpure avatar Jun 13 '22 10:06 GauravNagpure

Error is thrown on line with use arguments variable, but this is standard javascript variable (it is not related with pdfmake).

liborm85 avatar Jun 13 '22 11:06 liborm85

@liborm85 when I use download function on document object provided by createPdf method then only I get this error, can you please elaborate on how I can solve this error.

GauravNagpure avatar Jun 14 '22 14:06 GauravNagpure

I have no idea how to solve it, because problem is in angular probably does not support arguments variable.

liborm85 avatar Jun 15 '22 06:06 liborm85

Facing the same issue. I am using Angular 4. When tried creating PDF, it gave me error as mentioned by @GauravNagpure . @liborm85 Need a fix for this image

nilesh1095 avatar Aug 29 '22 16:08 nilesh1095

I have solved the problem by exchanging the Pdfmake to Version 1.xx

monovalar avatar May 24 '23 02:05 monovalar