i want to add Roboto font in my pdf which is attached below kindly help me set this font to the pdf
I found an edge case where webfonts don't seem to be loaded for PDF rendering, unless you trigger a screenshot first:
var puppeteer = require('puppeteer')
var document = `
<!DOCTYPE html>
<html>
<head>
<style>
@import url(https://fonts.googleapis.com/css?family=Signika);
body {
font-family: 'Signika', sans-serif;
}
</style>
</head>
<body>
<h1>Hello world!</h1>
</body>
</html>
`
puppeteer.launch().then(async browser => {
let page = await browser.newPage()
await page.setContent(document, { waitUntil: 'networkidle2' }) // <= here you should pass the second argument
await page.pdf({
path: 'print.pdf',
format: 'A4'
})
browser.close()
})
Refrence -