<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Show blocks only on the last page using pdf utils]]></title><description><![CDATA[<p>I need to show an html block only on the last page of the report.<br />
Using a script I'm able to hide the block only on the first page, on the next pages the blocks is always visible.<br />
Using phantom-pdf instead of chrome-pdf+pdf-utils it works fine.</p>
<p>I shared an example to better understanding: <a href="https://playground.jsreport.net/w/sguidotto/3eDStYM6" rel="nofollow">https://playground.jsreport.net/w/sguidotto/3eDStYM6</a><br />
The script is this below, it is on the headerfooter template called by pdf-utils from the main template:</p>
<pre><code>&lt;!---------------------------- Show blocks on last page--------------------------&gt;
&lt;script&gt;
    if (document.getElementById(&quot;pagenumber&quot;).innerHTML &lt; document.getElementById(&quot;totalpages&quot;).innerHTML) {
        document.getElementById(&quot;Totals&quot;).style.display = &quot;none&quot;;
    } else {
        document.getElementById(&quot;Totals&quot;).style.display = &quot;block&quot;;
    }
&lt;/script&gt;
</code></pre>
<p>Any suggestion is welcome. Thank you :-)</p>
]]></description><link>https://forum.jsreport.net/topic/2677/show-blocks-only-on-the-last-page-using-pdf-utils</link><generator>RSS for Node</generator><lastBuildDate>Sun, 19 Apr 2026 08:46:34 GMT</lastBuildDate><atom:link href="https://forum.jsreport.net/topic/2677.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 11 Jan 2023 10:16:29 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Show blocks only on the last page using pdf utils on Invalid Date]]></title><description><![CDATA[<p>I need to show an html block only on the last page of the report.<br />
Using a script I'm able to hide the block only on the first page, on the next pages the blocks is always visible.<br />
Using phantom-pdf instead of chrome-pdf+pdf-utils it works fine.</p>
<p>I shared an example to better understanding: <a href="https://playground.jsreport.net/w/sguidotto/3eDStYM6" rel="nofollow">https://playground.jsreport.net/w/sguidotto/3eDStYM6</a><br />
The script is this below, it is on the headerfooter template called by pdf-utils from the main template:</p>
<pre><code>&lt;!---------------------------- Show blocks on last page--------------------------&gt;
&lt;script&gt;
    if (document.getElementById(&quot;pagenumber&quot;).innerHTML &lt; document.getElementById(&quot;totalpages&quot;).innerHTML) {
        document.getElementById(&quot;Totals&quot;).style.display = &quot;none&quot;;
    } else {
        document.getElementById(&quot;Totals&quot;).style.display = &quot;block&quot;;
    }
&lt;/script&gt;
</code></pre>
<p>Any suggestion is welcome. Thank you :-)</p>
]]></description><link>https://forum.jsreport.net/post/11592</link><guid isPermaLink="true">https://forum.jsreport.net/post/11592</guid><dc:creator><![CDATA[sguidotto]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Show blocks only on the last page using pdf utils on Wed, 11 Jan 2023 11:45:47 GMT]]></title><description><![CDATA[<p>You can use handlebars to reach this</p>
<pre><code class="language-html">{{#if @last}}            
                &lt;table id=&quot;Totals&quot; class=&quot;full-width&quot; &gt; 
{{/if}}
</code></pre>
<p>Or implement your own helper if you need some extra logic</p>
<pre><code>// helper
function ifLastPage(index, options) {
    if (options.data.root.$pdf.pages.length - 1 === index) {
        return options.fn(this)
    }
    return ''
}
</code></pre>
<p><a href="https://playground.jsreport.net/w/anon/sdmLVf74" rel="nofollow">https://playground.jsreport.net/w/anon/sdmLVf74</a></p>
]]></description><link>https://forum.jsreport.net/post/11593</link><guid isPermaLink="true">https://forum.jsreport.net/post/11593</guid><dc:creator><![CDATA[jan_blaha]]></dc:creator><pubDate>Wed, 11 Jan 2023 11:45:47 GMT</pubDate></item></channel></rss>