Arabic font is not rendered properly inside puppeteer
See original GitHub issueI am trying to take a screenshot of my website inside puppeteer, but the font is not printed properly, I am using a custom font. I checked from the log, the request to get the font is successfully done.
I have tried to wait until the document’s font is ready, but still not working, the font still not applied
await page.evaluateHandle('document.fonts.ready');
I am using puppeteer built-in chromium-browser. Also, I am using docker-compose, and I am giving sys_admin to cap_addattribute to this service.
Here is my docker file
FROM node:10.7.0-alpine AS base
ENV CHROME_BIN="/usr/bin/chromium-browser" \
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD="true"
RUN set -x \
&& apk update \
&& apk upgrade \
&& apk add --no-cache \
udev \
ttf-freefont \
chromium \
&& npm install puppeteer@1.10.0
RUN mkdir -p /app
WORKDIR /app
COPY ./ /app/
ENTRYPOINT ["npm"]
CMD ["start"]
and here is my code
await page.goto(
`${frontend}/index(print:index/print/${query})`,
{
waitUntil: "networkidle0",
timeout: 300000
}
);
await page.evaluateHandle('document.fonts.ready');
await page.emulateMedia("print");
await page.waitForSelector(".data-complete", { timeout: 100000 });
await page.pdf({
path: "reporter/report.pdf",
format: "A4"
});
console.log("Reports generation done");
await browser.close();
This is how it looks like inside docker
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
How to fix puppeteer font issues - browserless docs
The first thing to try out is to applying a --font-render-hinting flag. This value, which defaults to "full", sets a font render hinting...
Read more >Downloading fonts is not supported in dockerized puppetter
I post an issue on puppetter github account, and they said, it's probably chromium doesn't provide full support for all Arabic font, ...
Read more >vendor/puppeteer/docs/troubleshooting.md - Deno
This means that the browser was downloaded but failed to be extracted correctly. The most common cause is a bug in Node.js v14.0.0...
Read more >403915 - Chrome chooses Japanese font under Chinese locale
Chrome should choose a Chinese font to render the text. ... Chinese font explicitly, Chrome fallbacks to Korean font (note: not Japanese font...
Read more >Generating Pdf documents in React Using React-pdf
I was working on a project recently and I got a unique(for me) requirement that needed me to generate pdf file from an...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Small update as addition to @semoal
For Arabic use only, you can install only those two packages
fonts-kacst fonts-freefont-ttf
. So script will beThanks for the support everyone.
Probably you need to install some custom fonts on your docker file.
on this line, search arabic font compatibility package for alpine
On node 10 for example: