Is it possible to create multiple docx File (serial letter)

  • Hello jsreporters

    I was wondering if there is an inbuilt function to create multiple word documents from a single jsreport call or if I would need to programmatically loop through all my documents I want to create and setup a single call for each individually?

    I was looking through the online available documentation but didn't really found something mentioning multiple document creation.

    Thanks already in advance for any help or hints.

  • This can be done using jsreport script

    const jsreport = require('jsreport-proxy')
    async function afterRender(req, res) { 
      for (let i = 0; i < 100; i++) {   ​
        ​const result = await jsreport.render({ template: { name: 'my another template' }, data: { } })  
        // do something with the result.content

  • @jan_blaha thx for the information looking into it and trying it out

    Why did you require('jsreport-proxy') though? shouldn't that be require('jsreport')?

  • administrators

    hi, jsreport-proxy is a subset of the jsreport api specifically designed to work with the running jsreport server, it is not the same than require('jsreport') because that exports a way to create and initialize a new server, so it won't let you work with the existing running one

  • @jan_blaha Is it possible to call such a script directly without an corresponding Template?

    I'm asking, because I've build up my script creating several reports of TemplateB and attached that one to a TemplateA

    However TemplateA is basically empty and unneccessary and only there so the script can be executed.

  • @bjrmatos Ah ok I was mainly wondering because in my IDE it told me to install the module using npm but couldn't find it... so I thought it must be jsreport directly since that installation worked. I guess that warning or Info should be just ignored then.

  • Is it possible to call such a script directly without an corresponding Template?

    This isn't possible. You need to attach it to a template, but that shouldn't be a problem.

Log in to reply

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