Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I am using Mathematica 9.0.0.0 under German Windows 32bit. I am on trying to export and import German text to PDF and re-import it. It seems that there is a confusion about the character encoding. It obviously differs between Export and Import. However, nothing related to the encoding is described in the PDF documentation, nor does specifying CharacterEncoding in PDF import and export seem to make any difference.

ImportString[ExportString[
  "This is a string. Aber was ist mit äöü, ß und ÄÖÜ? Also x\.b2 und \y\.b3 measured in µm",
  "PDF"]]

I wonder if there is a work-around which doesn't require a complete re-mapping. PDF export is slow, and doing it character by character will probably take hours.

share|improve this question
2  
I got most of it to work now. The String itself has to be coded using UTF-8 as in CharacterEncoding -> "UTF-8" inside the Style function. The \.b2 and \.b3 don't work yet. Maybe one day someone will find out how to make these work, too. –  Juergen Bosse Apr 1 '13 at 10:59
2  
Ok, the FontFamily matters, too: This finally works! Style["This is a string. Aber was ist mit äöü, ß und ÄÖÜ? Also x\.b2 \ und y\.b3 measured in \[Micro]m", FontFamily -> "Arial", CharacterEncoding -> "ASCII"] –  Juergen Bosse Apr 1 '13 at 11:20
    
If you have a solution please post it as a self-answer, so that it may be properly preserved, so that the question appears answered, and so that it may be voted on etc. –  Mr.Wizard Apr 1 '13 at 11:38
1  
Hi Mr. Wizard, I would do that (self-answer) if it would let me... I need some reputation here. –  Juergen Bosse Apr 1 '13 at 14:10
    
@JuergenBosse Can you do it now with 11 rep? –  halirutan Apr 1 '13 at 16:31
show 1 more comment

1 Answer 1

So PDF Import accepts a CharacterEncoding option, but it seems to ignore it. Exporting in UTF-8 or in ASCII gives the best results, with the former supporting the Euro symbol € and the latter supporting the ² and ³ symbols. Life is all about choice I guess.

The String itself has to be encoded using Style, and the FontFamily matters, too:

ImportString[
  ExportString[
    Style["This is a string. Aber was ist mit äöü, ß und ÄÖÜ? Also x\.b2 und y\.b3 measured in \[Micro]m",
    FontFamily -> "Arial", CharacterEncoding -> "ASCII"],
  "PDF"]
]

Note that, on import, you can give the option "TextMode" -> "Outlines" which results in FilledCurve entities being used instead of text entities. This is then highly portable and probably the safest way to ensure the correct appearance across systems at the expense of memory of course.

I have also been able to convert the filled curves to 3D outlines. This looks pretty cool and probably qualifies as a "neat example". I will post this separately and provide a link here.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.