react-to-print icon indicating copy to clipboard operation
react-to-print copied to clipboard

Document title with Cyrillic characters encoding problem

Open danikane opened this issue 2 years ago • 3 comments

Hi, I'm not sure this has been reported yet, but basically the title is self-explanatory. Cyrillic characters in the document title become something else:

image image

  const handlePrint = useReactToPrint({
    content: () => componentRef.current,
    documentTitle: 'Справка',
    onAfterPrint: () => console.log('Printed PDF successfully!'),
  });

I suspected this would be a problem for other languages/character sets, so I also tested with some Chinese characters as well so... suspicion confirmed :)

image image

  const handlePrint = useReactToPrint({
    content: () => componentRef.current,
    documentTitle: '諺語',
    onAfterPrint: () => console.log('Printed PDF successfully!'),
  });

NodeJS v20.3.0 [email protected] [email protected] Google Chrome

Let me know if there's anything I can do to help. Thanks!

danikane avatar Dec 11 '23 18:12 danikane

Hello. Thanks for the report. I'm not able to replicate this. I ran the test locally on:

MacOS: 13.6.1 Chrome: 119 Node: 20.10.0 React: 18.2.0 reacto-to-print: 20.14.15

Is there any other debug data you are able to provide? Are you using special fonts maybe?

Screenshot 2023-12-11 at 12 58 28 PM

MatthewHerbst avatar Dec 11 '23 21:12 MatthewHerbst

Hi, thanks for the reply! I was thinking about supplying additional fonts as properties so I'll definitely do that. There are some project-specific fonts that are in place, if they are a likely culprit how should I proceed? Thanks again!

daniel-kehlibarov avatar Dec 11 '23 21:12 daniel-kehlibarov

Can you try removing them to check if they are the issue? If they are, then what you should probably do is ensure they are not used in the printing view. That way the PDF will only use standard fonts that the computer will have. Alternatively, if you have access to all the computers the files will be viewed on, just install those additional fonts onto those computers

MatthewHerbst avatar Dec 11 '23 21:12 MatthewHerbst