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

419
Views
Creating and rendering a pdf from an ejs template

When I get a certain route called new page, I am trying to create a pdf file from an ejs file using the node-html-pdf or something like it, but with no success.

new page

  router.get('/newPage', function(req, res) {

    ejs.renderFile('secure/new_report_print', {
        data: {
            qryWaterLab: qryWaterLab,
            qryWaterContact: qryWaterContact,
            qryResult: qryResult,
            moment: moment,
            lSystemID: req.query.lSystemID,
            LabReportID: req.query.LabReportID
        },
        function(err, result) {
            // render on success
            if (result) {
                html =
                result;
            } else {
                res.end('An error occurred');
                console.log(err);
            }
          }
        });

        var options = {
            filename: 'report.pdf',
            format: 'A4',
            orientation: 'portrait',
            directory: './pdfs/',
            type: "pdf"
        };

        pdf.create(html, options).toFile(function(err, res) {
            if (err)
                return console.log(err);
            console.log(res);
        });
about 4 years ago · Santiago Trujillo
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!