Rendering Greek characters

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF CoreSuite for .NET (v11)  /  Re: Rendering Greek characters

DynamicPDF CoreSuite for .NET (v11) Forum

 Feb 26 2022 2:51 AM
Hi,
I'm using CoreSuite.NET version 11.26 in a .NET core 3.1 application. I'm trying to display Greek characters on Label objects. When I tried to use the predefined Courier font, Greek characters do not show up on the rendered document. I see there is support for different encodings (https://www.dynamicpdf.com/docs/dotnet/dynamic-pdf-fonts-and-text#TextEncoding), but I don't see an Encoder for code page 1253 (which defines Greek characters). Am I missing something? Is there a way to use Greek encoding?

Furthermore, I tried to use the Font.LoadSystemFont method (https://www.dynamicpdf.com/docs/dotnet/cete.dynamicpdf.font.loadsystemfont) in order to use a system-defined font that supports Greek, but it seems that this method is not available in the version of the nuget package that targets the .NET Core 3.1 framework. I see that it is available in the version that targets .NET 5.0 and later. Is there some other way to achieve the same functionality in .NET core 3.1?

Thanks in advance.
 Feb 28 2022 1:55 PM
Posted by a ceTe Software moderator
Hi,

You can use the corresponding Unicode values to add Greek characters to PDF.  DynamicPDF Core Suite for .NET works well in a .NET Core 3.1 applications.

You can load any OTF or TTF font using OpenTypeFont object and set this to page elements through which you are adding text.

You will need to use a font that supports Greek language characters.

Here is a code sample:

           Document document = new Document();
            Page page = new Page();
            document.Pages.Add(page);
            string fontPath = @"arialbd.ttf";
            OpenTypeFont font = new OpenTypeFont(fontPath);
            //Unicode value to add Greek character
            TextArea area = new TextArea("\u03B1", 0, 100, 200, 12, font, 12);
            page.Elements.Add(area);
            document.Draw(@"C:\Temp\fontOutput.pdf");

Thanks,
ceTe Software Support Team

All times are US Eastern Standard time. The time now is 8:20 AM.