ng-pdf-make
ng-pdf-make copied to clipboard
The package isn't working in an Angular app
I created a new Angular 11 app, installed the package using npm install ng-pdf-make --save
, and, having previously imported PdfmakeModule
, I used it in the AppComponent.
import {Component, OnInit} from '@angular/core';
import {PdfmakeService} from 'ng-pdf-make';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.sass']
})
export class AppComponent implements OnInit{
title = 'test-project2';
option = 'option1';
constructor(public pdfmake: PdfmakeService) {
}
ngOnInit(): void {
this.pdfmake.create();
this.pdfmake.configureStyles({ header: { fontSize: 18, bold: true } });
this.pdfmake.addText('This is a header, using header style', 'header');
this.pdfmake.addText('This is a header, using a custom style', { fontSize: 16, bold: true });
this.pdfmake.download();
}
}
But I got the following error
Error: node_modules/ng-pdf-make/pdfmake/pdfmake.module.d.ts:1:22 - error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class.
This likely means that the library (ng-pdf-make) which declares PdfmakeModule has not been processed correctly by ngcc, or is not compatible with Angular Ivy. Check if a newer version of the library is available, and update if so. Also consider checking with the library's authors to see if the library is expected to be compatible with Ivy.
1 export declare class PdfmakeModule { ~~~~~~~~~~~~~
How can I fix this issue to use the module in a simple Angular 11 app?
I am using pdfmake in my angular 11 project normally, however i am using the service only without importing the module, so try that