Skip to content

ReferenceError: window is not defined (Angular 6 with dotnet core) #1905

@caioladislau

Description

@caioladislau

Hello guys!

I've followed all the documentation guidelines, I've been looking for some solved issues, I've tried to correct this of many ways.

But I still can not use this lib in my application in Angular 6 with dotnet core.

When I install the lib ("jspdf": "^1.4.1") and try to use that, the application crashes with the error: "... window is not defined.".

Error on debugger:
captura de tela de 2018-08-23 11-14-57

Error on browser:
captura de tela de 2018-08-23 11-15-50

My code:

...
import * as jsPDF from 'jspdf';
...
    ngOnInit(): void {

        let doc = new jsPDF({
            orientation: 'landscape',
            unit: 'in',
            format: [4, 2]
        });

        doc.text('Hello world!', 1, 1);
        doc.save('two-by-four.pdf');
   }
...

Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions