0

I have an electron app and want to get a pdf. I tried

win.webContents.printToPDF(...)

But here I don't have headerTemplate or footerTemplate parameters available. I add a remote-debugging-port and connect to that with puppeteer. There I can call

Page.printToPDF(footerTemplate='<span>CUSTOM FOOTER</span>', ...)

with customized header and footer. (https://chromedevtools.github.io/devtools-protocol/tot/Page/#method-printToPDF) But Page.printToPDF is only available if chrome is started headless (--headless). Now I am getting an Error

calling method: Page.printToPDF error: 'Page.printToPDF' wasn't found

So how can I open a headless chromium Instance? I don't want to ship another chrome, just for the headless option. Or how can I get printToPDF working, even if it's not headless?

0 Answers0