toondaey / nestjs-pdf

Nest js pdf generator
MIT License
78 stars 38 forks source link

ENOTDIR: not a directory, open <root>/<template>/html.ejs #125

Open aauffray opened 2 years ago

aauffray commented 2 years ago

Hi,

I'm having a problem with pdf generation.

Here's the module setup in app.module.ts

    PDFModule.register({
      isGlobal: true,
      view: {
        root: './src/modules/pdf/templates',
        engine: 'ejs',
      },
    }),

And the code that is supposed to create my pdf buffer in my controller

const buffer = await this.pdfService.toBuffer('invoice.html.ejs', {locals: {...}});

I'm getting the following error:

ENOTDIR: not a directory, open 'src/modules/pdf/templates/invoice.html.ejs/html.ejs'

It looks like it's creating a path that appends /html.ejs to my path.

If I just pass invoice as the template parameter, I get this :

Error: ENOENT: no such file or directory, open 'src/modules/pdf/templates/invoice/html.ejs'

I suppose I'm doing something wrong with my configuration, but I can't find what that would be. I can assure the file exists in src/modules/pdf/templates/invoice.html.ejs

Thanks in advance !

aauffray commented 2 years ago

I guess I can juste rename my template file as html.ejs and put it into an invoice folder for now, so the generated path src/modules/pdf/invoices/html.ejs can work.

I don't know if it is the intended way of doing things