BennyFranco / ng-pdf-make

This is library creates a bridge to use pdfmake library with your angular 2 implementation.
16 stars 15 forks source link

The package isn't working in an Angular app #19

Open ArturGudiev opened 3 years ago

ArturGudiev commented 3 years ago

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?

rabiee3 commented 3 years ago

I am using pdfmake in my angular 11 project normally, however i am using the service only without importing the module, so try that