How to print the German characters ?

103 views
Skip to first unread message

Stefano Mora

unread,
Dec 13, 2017, 3:44:39 AM12/13/17
to libHaru
Hi all,
very nice job!!!

How can I print texts on a PDF document and using German (or accented, in general) characters?

Do I need a Unicode version of the lib?
Or whatever?

Thanks!

Pierre Clouthier

unread,
Dec 18, 2017, 4:01:14 PM12/18/17
to libHaru
I believe you can do Western European diacritics with plain ANSI (I haven't tried it).

To do Unicode, do this when you start the document:

 HPDF_Doc pdf = HPDF_New();
 HPDF_UseUTFEncodings
(pdf);
 HPDF_SetCurrentEncoder
(pdf, "UTF-8");

Then when you create the font:

 const char *ret = HPDF_LoadTTFontFromFile (pdf, faceName, HPDF_TRUE); // embedding  Need 'HPDF_TRUE' for UTF-8 to work
 HPDF_GetFont
(pdf, ret, "UTF-8");

Convert your UCS-2 (wchar_t) to UTF8;

Reply all
Reply to author
Forward
0 new messages