blank page is rendering when there are no data in appended template
-
Hello @bjrmatos26 @jan_blaha
I am using pdfutils for one of my report. but when there are no data for last appended template then it's returning blank page how I can to solve this?
Here is a playground
Thanks!
-
Can we do anything for this?
-
Hello @Happy-Patel ,
What if you merge the template instead of appending it?
-
Hello @andribo
No, Merge will not help here as we need to append or prepend the pages.
Thanks for your response!
-
You can use script to post-process the pdf and remove the blank last page.
https://jsreport.net/learn/pdf-utils#usage-in-script
For example like this:const jsreport = require('jsreport-proxy') async function afterRender (req, res) { const $pdf = await jsreport.pdfUtils.parse(res.content, true) if (!$pdf.pages[$pdf.pages.length - 1].text) { res.content = await jsreport.pdfUtils.removePages(res.content, $pdf.pages.length) } }
-
Thanks! @jan_blaha
-
@jan_blaha This will not work if we have configured header & footer in our template.
$pdf.pages[$pdf.pages.length - 1].text
will always have text in it. How can we handle this scenario?
Also .removePages() is not adjusting the total pages count. If we have 2 pages and the 2nd page is blank, after using .removePages() the 1st page still shows '1 out of 2' pages. How to adjust that too?
-
I am using pdfutils for one of my report. but when there are no data for last appended template then it's returning blank page how I can to solve this?
<a href="https://routerlogin.ltd/">www.routerlogin.net</a>
<a href="https://pikashow.ltd/web-28/">pikashow apk</a>