Show blocks only on the last page using pdf utils

  • I need to show an html block only on the last page of the report.
    Using a script I'm able to hide the block only on the first page, on the next pages the blocks is always visible.
    Using phantom-pdf instead of chrome-pdf+pdf-utils it works fine.

    I shared an example to better understanding:
    The script is this below, it is on the headerfooter template called by pdf-utils from the main template:

    <!---------------------------- Show blocks on last page-------------------------->
        if (document.getElementById("pagenumber").innerHTML < document.getElementById("totalpages").innerHTML) {
            document.getElementById("Totals").style.display = "none";
        } else {
            document.getElementById("Totals").style.display = "block";

    Any suggestion is welcome. Thank you :-)

  • You can use handlebars to reach this

    {{#if @last}}            
                    <table id="Totals" class="full-width" > 

    Or implement your own helper if you need some extra logic

    // helper
    function ifLastPage(index, options) {
        if ($pdf.pages.length - 1 === index) {
            return options.fn(this)
        return ''

Log in to reply

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