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!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - Adding unicode text
  FAQ FAQ  Forum Search   Register Register  Login Login

Adding unicode text

 Post Reply Post Reply
Author
Message
kkesslau View Drop Down
Beginner
Beginner


Joined: 10 Dec 18
Location: Germany
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote kkesslau Quote  Post ReplyReply Direct Link To This Post Topic: Adding unicode text
    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

Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3524
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post Posted: 10 Dec 18 at 5:55PM
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

Back to Top
tfrost View Drop Down
Senior Member
Senior Member


Joined: 06 Sep 10
Location: UK
Status: Offline
Points: 437
Post Options Post Options   Thanks (0) Thanks(0)   Quote tfrost Quote  Post ReplyReply Direct Link To This Post Posted: 10 Dec 18 at 6:02PM
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!

Back to Top
kkesslau View Drop Down
Beginner
Beginner


Joined: 10 Dec 18
Location: Germany
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote kkesslau Quote  Post ReplyReply Direct Link To This Post Posted: 11 Dec 18 at 9:01AM
First thanks for your replies Smile

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):

Hello World! (english)
مرحبا بالعالم! (arabic)
Γεια σου κόσμο! (greek)
Hello дүйнөнү! (kirghiz)
Pozdrav svijetu! (croatian)
Witaj, świecie! (polish)
Привет мир! (russian)
Dobrý deň svet! (slovakin)
Dobrý den svět! (czech)
שלום עולם! (hebrew)
ěěěěĚĚĚĚššššŠŠŠŠččččČČČČřřřřŘŘŘŘžžžžŽŽŽŽýýýýÝÝÝÝááááÁÁÁÁííííÍÍÍÍééééÉÉÉÉÉúúúúÚÚÚÚůůůůŮŮŮŮ

The last one was the text a customer send to us which showed us the missing characters. It is in czech (i think).
Our software is only available on Windows, so I pass as the font-parameter in AddTrueTypeFont just 'Arial' or 'Verdana' for example. Our software displays all texts correct because of our use of FreeType. We are just working with the fonts found in the Windows/Fonts-folder. Also in Microsoft Word all texts are displayed correctly.

But when I create a PDF from our Software with AddTrueTypeFont and pass these test-strings (in Delphi strings are unicode-strings), some of them are not displayed. As a font I used 'Arial'.
The following links are the output from AddTrueTypeFont and AddUnicodeFont:
https://ibb.co/sQTLMdN
https://ibb.co/cvqp5Gk

Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3524
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post Posted: 11 Dec 18 at 9:21AM
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

Back to Top
tfrost View Drop Down
Senior Member
Senior Member


Joined: 06 Sep 10
Location: UK
Status: Offline
Points: 437
Post Options Post Options   Thanks (0) Thanks(0)   Quote tfrost Quote  Post ReplyReply Direct Link To This Post Posted: 11 Dec 18 at 9:49AM
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.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store