Modify an existing webpage before rendering with chrome-pdf
-
Is it possible to alter an existing webpage before rendering with chrome-pdf recipe? For example, if you wanted to hide the navbar of the jsreport homepage using the below script:
playground: https://playground.jsreport.net/w/reidsentry/XY6lykpe
function beforeRender(req, res) {
req.template.chrome = {
"url": "https://jsreport.net"
};
req.template.content +=<script> document.querySelector('.navigation-bar').style.display = 'none'; </script>
;
}I imagine this doesn't work because the content isn't used the same when a url is set, but I don't know.
-
You would need to download the page using the script by hand, and then modify its content.
https://playground.jsreport.net/w/anon/VOl8aI8v
-
Thank you very much, this is exactly what I was looking for.