Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

131
Visualizações
jsReports assets nodejs

I am trying to add a css stylesheet as asset to a jsReport report.

  jsreport.render({
    template: {
      content: `

     
      <html>
      <link rel="stylesheet" type="text/css" href="/css/style.css">
          <head>
              <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
              <style>
                  {#asset /css/style.css}
              </style>
          </head>
          <body>
             ...
          </body>
      </html>

      `,
      
      engine: 'handlebars',
      recipe: 'html',
      assets: {
        allowedFiles: "static/**.js",
        publicAccessEnabled: true,
        searchOnDiskIfNotFoundInStore: true,
      },
    },
    data: newCart
  }).then((out) => {
    out.stream.pipe(res);
  }).catch((e) => {
    res.end(e.message);
  });

The problem is within the tags when I try to load the assets. Any idea on how to do this? Thanks in advance! :)

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

With jsreportonline.net I've always put the asset as the first line, so maybe something like the following would work.

    template: {
      content: `

      <style>
          {#asset /css/style.css @encoding=utf8}
      </style>     
      <html>
      <link rel="stylesheet" type="text/css" href="/css/style.css">
          <head>
              <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
          </head>
          <body>
             ...
          </body>
      </html>

      `,
      
      engine: 'handlebars',
      recipe: 'html',
      assets: {
        allowedFiles: "static/**.js",
        publicAccessEnabled: true,
        searchOnDiskIfNotFoundInStore: true,
      },
    },
    data: newCart
  }).then((out) => {
    out.stream.pipe(res);
  }).catch((e) => {
    res.end(e.message);
  });`
about 4 years ago · Juan Pablo Isaza Relatório

0

I "solved" the problem directly pasting the css in the tags as the issue was with the import of #asset.

Not the best solution but it worked :)

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda