Print Triggers Chrome PDF



  • Template options:

    template: {
    content: templateString,
    engine: 'handlebars',
    recipe: 'chrome-pdf',
    chrome: {
    waitForJS: true
    }
    },

    Template string content:

    <html>
    <head>
    <head>
    <script>
    // do some calculations or something async
    setTimeout(function() {
    window.JSREPORT_READY_TO_START = true; //this will start the pdf printing
    }, 500);
    </script>
    </head>
    </head>
    <body>
    <script>
    // do some calculations or something async
    setTimeout(function() {
    window.JSREPORT_READY_TO_START = true; //this will start the pdf printing
    }, 500);
    </script>
    </body>
    </html>

    Works when waitForJS: false, but not when true. Am I missing something or do the triggers just not work? It seems like I have copied exactly how it is shown in documentation and yet no changes, just get console message 'Chrome will wait for printing trigger ' and nothing happens. Want to see if perhaps I missed something in the documentation or if I should just use the chromium print directly myself.



  • The same works for me. Are you sure you don't have some js errors? Try to run the same as html and check it in the browser console for errors.

    Also, try to send just this through your postman, does it pass for you?

    {
        "template": {  
            "content": "<script>window.JSREPORT_READY_TO_START = true;</script>",
            "engine": "handlebars",
            "recipe": "chrome-pdf",
            "chrome": { "waitForJS": true }
        }     
    }
    

Log in to reply
 

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