Skip to main content

plotting - Exporting plots with Cyrillic text elements to pdf


I'm trying to export a plot with some added notes which happen to be in Russian.



Using Mathematica 8.04 and WinXP I evaluate


Export["smt.pdf", "Текст на русском", CharacterEncoding -> "WindowsCyrillic"]

Which gives nonsense as output. Is there a way to solve this?



Answer



It seems that the problem can be solved by setting explicit value of the CharacterEncoding global FE option (checked with MMa 8.0.4 and 9.0.0):


SetOptions[$FrontEnd, CharacterEncoding -> "UTF8"];
Export["test.pdf", "кириллический текст"]

An equivalent way (without changing the global FE settings):



Export["test.pdf", 
Style["кириллический текст", CharacterEncoding -> "UTF8"]]

Instead of "UTF8" one may set "UTF-8" or "ASCII" with the same effect. The drawback of this approach is that all non-English letters are outlined.




Update


Starting from version 10 (checked with versions 10.4.1 and 11.1.1) Cyrillic text is exported correctly with default setting without converting glyphs into outlines:


Export["test.pdf", "кириллический текст"] // SystemOpen

Here is how exported file looks when opened by Adobe Acrobat 11 (I intentionally selected the first word to show that it isn't outlined):



screenshot


Moreover, text can be copied from Acrobat and correctly pasted into Notepad.


But importing such PDF as "Plaintext" still fails:


Import["test.pdf", "Plaintext"]
% // ToCharacterCode


output


 {1, 2, 3, 2, 4, 4, 2, 5, 6, 7, 1, 2, 8, 32, 9, 6, 1, 7, 9}


P.S. In versions 10 and 11 CharacterEncoding is not recognized as a valid FrontEnd option.


Comments