puppeteer: Can't take screenshot with emoji on Firebase Cloud Functions
Steps to reproduce
Tell us about your environment:
- Puppeteer version: 1.12.2
- Platform / OS version: Firebase
- URLs (if applicable):
- Node.js version: 8
What steps will reproduce the problem? ` import * as functions from ‘firebase-functions’; import * as admin from ‘firebase-admin’; admin.initializeApp(); const storage = admin.storage(); const puppeteer = require(‘puppeteer’);
function screenshot() {
(async () => {
const browser = await puppeteer.launch({ headless: true, args: ['--no-sandbox', '--disable-setuid-sandbox'] });
const page = await browser.newPage();
await page.goto("https://getemoji.com/"); //go to emoji page
await page.screenshot({
path: '/tmp/screenshot.png',
omitBackground: true,
})
.then(() => {
// upload screenshot to firebase storage
storage.bucket('bucketName').upload('/tmp/screenshot.png')
.then(() => {
console.log("success");
})
.catch(error => {
console.log(error);
});
})
.catch(e => {
console.log(e);
});
})();
}
`
- create HTTP Cloud Function
- call the screenshot function inside of the HTTP function
What is the expected result? screenshot.png is uploaded to storage, and can see emoji clearly in the image
What happens instead? screenshot.png is uploaded to storage, but can’t see emoji in the image.
here is the result screenshot of “https://getemoji.com/”:
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 10
- Comments: 16 (3 by maintainers)
I had the same issue Puppeteer/headless Chrome rendering emojis as □□□□
For those that are looking for a workaround, here is what worked for me, copy the font file in the local fonts folder:
Hope this helps if anybody has the same issue
How would you avoid using the chromium import from
aws-lambda
in case of google cloud functions?@VincentCtr sounds interesting 👍
what’s
chromium
? an import? a local variable?Hi Guys,
Fixed it using this small line of code. Hope it will help.
await chromium.font('https://raw.githack.com/googlei18n/noto-emoji/master/fonts/NotoColorEmoji.ttf');
@steren surprisingly, I don’t have permissions to create new issue.
But the font identifies itself as “Noto Emoji” for me on Linux. I’d guess installing both https://github.com/googlei18n/noto-emoji and https://github.com/googlei18n/noto-fonts should cover all the needs.