toondaey / nestjs-pdf

Nest js pdf generator
MIT License
83 stars 37 forks source link

Auto configuration failed #204

Open EasySouls opened 1 month ago

EasySouls commented 1 month ago

Whenever I invoke any of my methods that would generate a pdf, I get the following error:

[Nest] 5270  - 08/21/2024, 10:26:05 AM   ERROR [ExceptionsHandler] html-pdf: Unknown Error
Auto configuration failed
124513700824896:error:25066067:DSO support routines:DLFCN_LOAD:could not load the shared library:dso_dlfcn.c:185:filename(libproviders.so): libproviders.so: cannot open shared object file: No such file or directory
124513700824896:error:25070067:DSO support routines:DSO_load:could not load the shared library:dso_lib.c:244:
124513700824896:error:0E07506E:configuration file routines:MODULE_LOAD_DSO:error loading dso:conf_mod.c:285:module=providers, path=providers
124513700824896:error:0E076071:configuration file routines:MODULE_RUN:unknown module name:conf_mod.c:222:module=providers

If that matters, Im running the project on Ubuntu 22.04. My nest files look like the following:

@Controller('reports')
export class ReportsController {
  constructor(private readonly reportsService: ReportsService) {}

  @Post('overview')
  async generateOverviewReport(@Body() body: OverviewReportReq) {
    const fileObservable = this.reportsService.generateOverviewReport(body);
    const file = await firstValueFrom(fileObservable);
    return new StreamableFile(file);
  }
}
@Injectable()
export class ReportsService {
  constructor(private readonly pdfService: PDFService) {}

  private readonly logger = new Logger(ReportsService.name);

  generateOverviewReport(dto: OverviewReportReq) {
    this.logger.log(
      `Generating overview report for ${dto.startDate} - ${dto.endDate}`,
    );
    return this.generatePDFToStream('overview', { locals: dto });
  }

  /**
   * @returns Observable<FileInfo>;
   */
  generatePDFToFile(template: string, filename: string, options?: PDFOptions) {
    return this.pdfService.toFile(template, filename, options);
  }

  generatePDFToStream(template: string, options?: PDFOptions) {
    return this.pdfService.toStream(template, options);
  }

  generatePDFToBuffer(
    template: string,
    options?: PDFOptions,
  ): Observable<Buffer> {
    return this.pdfService.toBuffer(template, options);
  }
}