New issue
Advanced search Search tips

Issue 916816 link

Starred by 2 users

Issue metadata

Status: WontFix
Owner: ----
Closed: Dec 21
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 3
Type: Bug



Sign in to add a comment

printToPDF - Japanese text is output in pdf with Chinese font

Reported by kingsley...@gmail.com, Dec 20

Issue description

Chrome Version       : 71.0.3578.98
OS Version: 10.0
URLs (if applicable) : not applicable
Other browsers tested: not applicable

note: directed here from https://github.com/ChromeDevTools/devtools-protocol/issues/136

What steps will reproduce the problem?
1. Install puppeteer (nodejs) version 1.11.0
2. Use puppeteer to convert an html file including the Japanese character "直" to pdf using page.goto()/page.pdf() 
(eg: https://gist.github.com/adisetiawan/29ba2bab10ed85706f8b1d1a8eceb825)

What is the expected result?
The Japanese character "直" is displayed with the standard Japanese font as it is when the html page is simply displayed in the Chrome browser.


What happens instead of that?

The "直" character in the pdf file is displayed with a Chinese font (see attached chinese font.png)


Please provide any additional information below. Attach a screenshot if
possible.

Here is my function using puppeteer in electron to convert test.htm into test.pdf and test.png (the same problem occurs with page.screenshot()):


const browser = await puppeteer.launch();
const page = await browser.newPage();
var mypath = require('path').join(require('os').homedir(), 'Desktop');  
var myfilepath = mypath + "\\test.pdf"
const options = {
  path: myfilepath,
  format: 'A4',
};
await page.goto(mypath + "\\test.htm", {waitUntil: 'networkidle2'});
await page.screenshot({path:mypath + "\\test.png"});
await page.pdf(options);
await browser.close();

I have attached the input (test.htm) and the outputs (test.png and test.pdf)

I hope that this helps you to fix the bug (if it is one) and I apologize for wasting your time if the problem is my fault.


Best Regards


UserAgentString: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36



 
chinese font.png
627 bytes View Download
test.pdf
197 KB Download
test.png
4.0 KB View Download
test.htm
46 bytes View Download
Labels: Needs-Triage-M71
The version of Chromium that is bundled with puppeteer v1.11.0 is 72.0.3617.0(Developer Build) (64bit)
Components: Internals>Printing
Labels: Triaged-ET TE-NeedsTriageHelp
kingsleyarchibald@ Thanks for the issue.

As this issue should be tested on puppeteer, this is out of scope of triaging at TE end.
Hence adding 'TE-NeedsTriageHelp' and adding appropriate component to look into the issue and help in further triaging.

Thanks..
thank you Susan. Should I continue to monitor this issue detail page to check the progress of this?
Just to double check, is Puppeteer really required to reproduce this bug? Or can one just open test.htm in Chromium, print, and do Save As PDF to generate the same PDF?
Components: -Internals>Printing Blink>Fonts
In test.pdf, the first two characters are rendered with the SimSun font. On Windows, if I load test.htm, they are also rendered with SimSun on screen. So to take a step back, we need to work out why they are rendered with the Chinese font on the screen. I'm not enough of a font expert to say whether that behavior is intentional or not.
Status: WontFix (was: Unconfirmed)
It looks like the language information is lost when converting to a PDF with puppeteer. One would either have to configure it to set the langauge for chrome correctly or change the content to explicitly define the language.

See https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang for ways to define the language.
Thank you so much for the help on this! Setting the language explicitly in the content solved my problem

Sign in to add a comment