Best way to insert data into rendered report for "append"



  • I need to append a report with differend page size (A3), so I need to use append. First I'm rendering the repor and then I'm appending it with pdfUtils.

    I know that I can add data to the render command, but this doesn't seem to be necessary. The original req.data seems to be available in the rendered report anyway.

    I need to add some specific information to the appended report. How would I insert this information via the render command and how would I reach it from within the rendered report?

    Here is how I do it right now, without inserting any new data:

    const jsreport = require('jsreport-proxy')
    
    async function afterRender(req, res) {
      const blueprint = await jsreport.render({
          template: {
              shortid: 'rJxZpXJYwB',
              recipe: 'chrome-pdf'
          },
      })
    
      res.content = await jsreport.pdfUtils.append(res.content, blueprint.content)
    }
    


  • I ended up by simply appending my new data to req.data, like this:

        const blueprint = await jsreport.render({
          template: {
            shortid: 'rJxZpXJYwB',
            recipe: 'chrome-pdf'
          },
          data: {
            ...res.data,
            test: 'TEST ABC'
          }
        });
    

    What confuses me is that I don´t need to append any data if no new data is needed.

    Is the following true?

    • If no data is supplied to jsreport.render, jsreport will autmatically use res.data.

  • administrators

    Is the following true?
    If no data is supplied to jsreport.render, jsreport will autmatically use res.data.

    yes, right now it works like that. in terms of the data the render that originates from proxy automatically inherits the data of the current render


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.