Footers in PhantomPDF



  • I am using the template layout as described in your blog article https://jsreport.net/blog/template-layouts to pass HTML content. I get the footer with page numbers printed if I run the template in Studio with sample data but the footer does not print when using the following render call:

     var reportRequest = { template:{
                            shortid:"HkLEC10iz",
                            content: reportData,
                            recipe:'phantom-pdf',
                            engine:'handlebars',
                            phantom: {orientation: '#pageorientation#'}
                            },
                            data: {
                                localStyling: '#mainSiteURL#css/#useStylesheet#.css', 
                                }
            };
    

    The script is

    function beforeRender(req, res, done) {
        var layout = '{#asset localCSS_layout.html @encoding=string}'
        req.template.content = layout.replace('$$$', req.template.content)
        done();
    }
    

    Hosting jsReport on remote Linux server, running as pm2 service, Phantomjs version 1.9.8. Expect script to run twice - once for template, once for footer - this happens in Studio but not from render call. Any ideas what could be wrong?



  • Is there a reason why you over-specify the template? Usually you just set the template.shortid and data.

     var reportRequest = { template:{
                            shortid:"HkLEC10iz",                      
                           },
                            data: {
                                localStyling: '#mainSiteURL#css/#useStylesheet#.css', 
                                }
            };
    

    Wouldn't this work as you expected?



  • I need to pass the content held in variable reportData and the page orientation also as the template is used by different reports. The rest is over-specification but adds clarity.
    I use a blank template (shortid:"HkLEC10iz") which calls the script to replace the '$$$' placeholder in a layout template (localCSS_layout.html). The footer is attached to the template and displays if run in Studio with sample data but not if called via render as above. Why is the footer not displaying?



  • I cannot replicate it so far. Could you please make a minimal example without sensitive data and export it to zip file and share it here or to my email?
    Also please attach which jsreport version you use. Thank you.


Log in to reply
 

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