Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Sun Nov 02, 2014 3:51 pm

Hello, I use free Spire.pdf. I have problem to write string in ISO-8859-2 encoding. For example the string "ěčř" writen on PdfPageBase page wit method page.Canvas.DrawString(TextToPrint, trueTypeFont, brush, X, Y); will result in "ìèø". But meny other letters (š,ý,á) are written correctly.

Can you please help me how to set pdf document?

rostas
 
Posts: 2
Joined: Sat Nov 01, 2014 1:40 pm

Mon Nov 03, 2014 2:34 am

Hello,

Thanks for your inquiry.
Sorry for late reply as weekend.
Please try the following codes.
Code: Select all
PdfDocument pdfdoc = new PdfDocument();
PdfPageBase page = pdfdoc.Pages.Add();
string text = "ěčř";
System.Drawing.Font font = new System.Drawing.Font("Arial", 14f);
PdfTrueTypeFont trueTypeFont = new PdfTrueTypeFont(font,true);
PdfBrush brush=PdfBrushes.Black;
page.Canvas.DrawString(text, trueTypeFont, brush, 0, 0);
pdfdoc.SaveToFile("DrawEncodingText.pdf", FileFormat.PDF);

If there are any questions, welcome to get it back to us.
Sincerely,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Tue Nov 04, 2014 7:15 am

Greate, it works. I had also problem with Greek letter Eta: η (which was ?). Now all of them are shown correctly. So the true in new PdfTrueTypeFont(font, true); was the secret:-).

Thank you very much.

rostas
 
Posts: 2
Joined: Sat Nov 01, 2014 1:40 pm

Tue Nov 04, 2014 7:30 am

Hello,

Thanks for your feedback. If there are any question, welcome to get it back to us.

Sincerely,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Return to Spire.Doc