Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!
![]() |
Adding unicode text |
Post Reply ![]() |
Author | |
kkesslau ![]() Beginner ![]() Joined: 10 Dec 18 Location: Germany Status: Offline Points: 3 |
![]() ![]() ![]() ![]() ![]() Posted: 10 Dec 18 at 2:04PM |
Hi, i wanted to ask if there is a better way to add/use unicode text then what is presented here: http://www.quickpdf.org/forum/drawing-unicode-text_topic2090.html I'm working with Delphi 10.2.3 and the DebenuPDFLibrary1411-Library. Currently i'm using the AddUnicodeFont-Method, but it seems that this method is not fully functional or tested, because after calling DrawText there are temporary-ttf files in the AppData/Local/Temp-folder (on Windows). If i create a PDF with a lot of texts, then for every text there is such a file created. And this happends everytime (i have a workaround to manually detect and delete this files after the PDF is saved, there are named like "QuickPDFTempFontXXXXXXXXX.ttf"). Example code: text := 'Hello World'; fontId := PdfLibrary.AddUnicodeFont(aFont, 0, 0); //aFont is for example 'Arial' PdfLibrary.SelectFont(fontId); PdfLibrary.DrawText(startP.X, startP.Y, text); I did some testing with the AddTrueTypeFont-method with explicit setting of the codepage, but this in my use-case the wrong method because i don't want to have to check everytime in which location the user is corrently working to manually set the codepage. If anybody can point me in the right direction to handle unicode texts would help me a lot. Thanks in advance, Kevin |
|
![]() |
|
Ingo ![]() Moderator Group ![]() ![]() Joined: 29 Oct 05 Status: Offline Points: 3529 |
![]() ![]() ![]() ![]() ![]() |
Hi Kevin,
in my opinion this won't matter you. You put in "Hello World" with european characters. If anybody will read it in India he'll see "Hello World". If an indian guy will create a pdf perhaps it will be urdu and you'll see "Hello World" in Urdu language. The only point you should have an eye on is if you're working with the dll-version of QuickPDF using an old ide like vb6 or vba. In this case you have to convert all strings to and from unicode - that's all. Cheers and welcome here, Ingo |
|
Cheers,
Ingo |
|
![]() |
|
tfrost ![]() Senior Member ![]() Joined: 06 Sep 10 Location: UK Status: Offline Points: 437 |
![]() ![]() ![]() ![]() ![]() |
I have not used this function a lot, but from the way I read it the code page is optional for AddTrueTypeFont, and I have never set one. If you pass a Unicode wide string to the 'draw' function in use with the font, the Unicode characters you pass will all be displayed if they have glyphs in the font.
Once you have the characters you want to place on the PDF in a Unicode string, you only need to select a suitable TrueType font to display them. You may of course need to use different Unicode fonts depending on what languages your user needs, especially Asian ones, but you still do not need to specify a code page for the font. AddUnicodeFont is shown as 'experimental' and so I would probably not consider using it, but it seems that (by implication) the standard function does not support Unicode above plane 0. I have just verified this by trying to display a smiley (U1F600) using a Unicode font loaded with AddTrueTypeFont which I know contains this character. So unless you need characters like Linear B or Emoji you should be fine with using AddTrueTypeFont - I suggest you try it and ask back here in case another user knows more about all this!
|
|
![]() |
|
kkesslau ![]() Beginner ![]() Joined: 10 Dec 18 Location: Germany Status: Offline Points: 3 |
![]() ![]() ![]() ![]() ![]() |
First thanks for your replies ![]() I did again some testing with the AddTrueTypeFont-method but it doesn't display all the characters in my test texts. Here there are, just Hello World in different languages, but all languages are supported by our software (we make a timberwood-cad-construction software):
The last one was the text a customer send to us which showed us the missing characters. It is in czech (i think). |
|
![]() |
|
Ingo ![]() Moderator Group ![]() ![]() Joined: 29 Oct 05 Status: Offline Points: 3529 |
![]() ![]() ![]() ![]() ![]() |
Hi Kevin,
instead of using the normal Arial you should use "Arial Unicode MS". You need the unicode variants of the common truetype fonts. Verdana doesn't support all unicode characters. Helvetica doesn't support unicode but there are "helvetica-like" fonts for unicode... You'll find many online ressources regarding this subject. |
|
Cheers,
Ingo |
|
![]() |
|
tfrost ![]() Senior Member ![]() Joined: 06 Sep 10 Location: UK Status: Offline Points: 437 |
![]() ![]() ![]() ![]() ![]() |
You should be aware that Windows, so also Microsoft Word, takes a specific font request merely as a preference. It is capable of quietly substituting your requested font for another one, if it does not have the one you ask for or if it will not display the characters you want to show. This can be quite annoying at times, though it is good for most users. But it is generally helpful that QPDF respects your choice, even if you have, as Ingo points out, asked for a font which does not support Unicode well.
|
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store