Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

127
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!