How to Hide page appended with pdfutils when data is null on that page
-
Hello @jan_blaha @bjrmatos
Hope you are doing well!I have a scenario where I need one cover page, summary page, Title page and the other pages. so among them cover page and title page will not have page margin on that and other pages will have page margin so I am using pdfutils to achieve that.
How I can hide the 2nd page (summary page) when there are no data inside that page. because I am using pdfutils not able to hide that page.
https://playground.jsreport.net/w/happypatel20/BJMTJJGG
Is there any way to do the same?
Thanks!
-
You can use jsreport script to dynamically invoke pdf utils features in code.
https://jsreport.net/learn/pdf-utils#usage-in-scriptYou can be interested primarily in
jsreport.pdfUtils.removePages
https://jsreport.net/learn/pdf-utils#-removepages-sourcepdfbuf-pagenumbers-You can use it like this
const jsreport = require('jsreport-proxy') async function afterRender (req, res) { if (!req.data.summaryText) { res.content = await jsreport.pdfUtils.removePages(res.content, 2) } }
Updated playground here
https://playground.jsreport.net/w/anon/06uwGNc8
-
Thanks! @admin