toondaey / nestjs-pdf

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

CSS don't load #108

Open ismailkoksal opened 3 years ago

ismailkoksal commented 3 years ago

I can't load my css

Project structure

src/
templates/
  index/
    css/
      style.css
    html.hbs

app.module.ts

PDFModule.register({
      isGlobal: true,
      view: {
        root: join(__dirname, '..', 'templates'),
        engine: 'handlebars',
        extension: 'hbs',
      },
    }),

html.hbs

<html>
<head>
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6" crossorigin="anonymous">
  <link href="css/style.css" rel="stylesheet">
</head>
<body>
  <h1 class="red">Hello World</h1>
</body>
</html>

style.css

.red {
  color: red;
}
dacxjo commented 3 years ago

@ismailkoksal Did you solve this?

ismailkoksal commented 3 years ago

@ismailkoksal Did you solve this?

@dacxjo No, i decided to put CSS in the HBS file.

telou1 commented 2 years ago

HI,

this is working for me:

> root/
  > assets/
       > stylesheets/
            > style.css

file.pug:

head meta(charset="UTF-8") meta(name="viewport", content="width=device-width, initial-scale=1.0") style include ../stylesheets/style.css

dacxjo commented 2 years ago

Thanks but I have uninstalled this package, instead, I'm using puppeteer with his pdf method to generate my documents