chrome-aws-lambda icon indicating copy to clipboard operation
chrome-aws-lambda copied to clipboard

Chinese/Japanese/Korean characters are not displayed

Open GuyMoreh opened this issue 2 years ago • 2 comments

Hey,

Thanks for the great library!!

I'm using this library to generate pdfs, but non-english characters are displayed as blocks.

I have tried to follow this issue (https://github.com/alixaxel/chrome-aws-lambda/issues/108) but the results are the same...

Can anyone please provide a guide or something??

Versions:

  • puppeteer-core: 9.0.0
  • chrome-aws-lambda: 8.0.2

Thanks!

GuyMoreh avatar Nov 03 '21 08:11 GuyMoreh

module.exports.handler = async (event, context, callback) => { let result = null; let browser = null; let bodyContent = event.data; let headerTemplate = event.headerTemplate || '' let footerTemplate = event.footerTemplate || '' try { await chromium.font('https://s3.ap-northeast-2.amazonaws.com/fonts/webfont.ttf') <--here console.log(event) browser = await chromium.puppeteer.launch({ args: chromium.args, defaultViewport: chromium.defaultViewport, executablePath: await chromium.executablePath, headless: chromium.headless, ignoreHTTPSErrors: true, });

Curryking100k avatar Jul 21 '22 09:07 Curryking100k

Hello. I solved this by following @Curryking100k 's code. Add this part.

await chromium.font('https://s3.ap-northeast-2.amazonaws.com/fonts/webfont.ttf') // Add font for chromium

For the font link, I suggest you to use Noto Sans SC font. I tried normal Noto Sans font but it didn't work for me.

So I downloaded NotoSansSC-Regular.ttf, and uploaded to my S3 bucket, and then used the S3 link. It worked now. (Also supporting Japanese)

https://fonts.google.com/noto/specimen/Noto+Sans+SC

junguksim avatar Sep 25 '23 08:09 junguksim