Missing footer when pdf height is set to less than 14.6 cm



  • I am using the native header and footer functionality of chrome-pdf recipe. I tried to create a pdf of size 24.13cm x 13.97cm and noticed that the footer is missing. I reverted back to A4 and the footer is back again. After some tinkering, I noticed that the footer only appears when height is set to 14.6cm or more.

    Here is the link to the playground

    To reproduce the missing footer problem, simply change the pdf height value in the playground to 14.5cm .

    Here is the list of what I have tried so far but doesn't work:

    • Changing the PDF width to 30cm, 24.13cm, and 15cm
    • Setting landscape to true/false
    • Setting the pdf bottom margin to 3cm, 1cm, and 0.5cm

    UPDATE: I tried to generate pdf using puppeteer directly and the footer appears when using my intended pdf height of 13.97cm. It uses puppeteer v21.10.0. Here is the nodejs code.

    const chromeOptions = {
    	displayHeaderFooter: true,
    	headerTemplate: header,
    	footerTemplate: footer,
    	width: '24.13cm',
    	height: '13.97cm',
    	margin: {
    		top: '3cm',
    		bottom: '1.5cm',
    		left: '0.5cm',
    		right: '0.5cm',
    	},
    };
    
    const browser = await puppeteer.launch({ headless: 'new' });
    const tab = await browser.newPage();
    await tab.setContent(template);
    const buff = await tab.pdf(chromeOptions);
    
    await writeFile('./inv.pdf', buff);
    


  • Thank you, it is some sort of bug in puppeteer/chrome. We will update puppeteer with the next jsreport release.

    At this moment you can also just add the latest puppeteer dep to the app package.json, run npm i, restart jsreport and it should work.

    {
      "name": "jsreport-server",
      "main": "server.js",
      "scripts": {
        "start": "node server",
        "jsreport": "jsreport"
      },
      "jsreport": {
        "entryPoint": "server.js"
      },
      "dependencies": {
        "jsreport": "^4.2.0",
        "puppeteer": "21.10.0"
      }
    }
    

Log in to reply
 

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