Cyrillic Letters in FormattedTextAreaStyle

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF CoreSuite for .NET (v9)  /  Cyrillic Letters in FormattedTextAreaStyle

DynamicPDF CoreSuite for .NET (v9) Forum

Hello, i wanted to create protocols in russian and bulgarian languages for my company, but i'm having problems getting cyrillic letters to show in my PDFs.

I searched the forum and found this (can't get it to work tho):

Font centralEuropeHelveticaFont = new Helvetica(Encoder.getCentralEurope());

I'm using VB.net, translating from C# is not the issue.

In a few cases i use plain labels like this:

currentPage.Elements.Add(New Label(textMain, PD.LeftMargin, currentY + 12.0F, PD.Width - PD.RightMargin * 3, 12.0F, Global.ceTe.DynamicPDF.Font.HelveticaBold, 12.0F, Global.ceTe.DynamicPDF.TextAlign.Center))

Mostly i now use FormattedTextAreas and defined styles:

Dim style7 As FormattedTextAreaStyle = New FormattedTextAreaStyle(Global.ceTe.DynamicPDF.FontFamily.Helvetica, 7.0F, False)
Dim style8 As FormattedTextAreaStyle = New FormattedTextAreaStyle(Global.ceTe.DynamicPDF.FontFamily.Helvetica, 8.0F, False)
Dim style9 As FormattedTextAreaStyle = New FormattedTextAreaStyle(Global.ceTe.DynamicPDF.FontFamily.Helvetica, 9.0F, False)
Dim style10 As FormattedTextAreaStyle = New FormattedTextAreaStyle(Global.ceTe.DynamicPDF.FontFamily.Helvetica, 10.0F, False)

How do i get cyrillic support for both cases, please?

With best regards

Maren
Posted by a ceTe Software moderator - Commonly asked question
Hello Maren,
 
Yes, you can create a font family from the 4 font styles using that encoding and use them in the FormattedTextAreaStyle. Below is the code sample.
 
        Font centralEuropeHelveticaRegularFont = new Helvetica(ceTe.DynamicPDF.Text.Encoder.CentralEurope);
        Font centralEuropeHelveticaBoldFont = new HelveticaBold(ceTe.DynamicPDF.Text.Encoder.CentralEurope);
        Font centralEuropeHelveticaItalicFont = new HelveticaOblique(ceTe.DynamicPDF.Text.Encoder.CentralEurope);
        Font centralEuropeHelveticaBoldItalicFont = new HelveticaBoldOblique(ceTe.DynamicPDF.Text.Encoder.CentralEurope);
        FontFamily fontFamily = new FontFamily("familyName", centralEuropeHelveticaRegularFont, centralEuropeHelveticaBoldFont, centralEuropeHelveticaItalicFont, centralEuropeHelveticaBoldItalicFont);
        FormattedTextAreaStyle style1 = new FormattedTextAreaStyle(fontFamily, 12, true);
 
Thanks,
ceTe Software Support Team
Hello,

thanks for the quick reply.

I created the fonts as you suggested, still the cyrillic letters aren't showing in the PDF. Here's the part of the code:

Dim centralEuropeHelveticaRegularFont As Global.ceTe.DynamicPDF.Font = New Helvetica(Global.ceTe.DynamicPDF.Text.Encoder.CentralEurope)
        Dim centralEuropeHelveticaBoldFont As Global.ceTe.DynamicPDF.Font = New HelveticaBold(Global.ceTe.DynamicPDF.Text.Encoder.CentralEurope)
        Dim centralEuropeHelveticaItalicFont As Global.ceTe.DynamicPDF.Font = New HelveticaOblique(Global.ceTe.DynamicPDF.Text.Encoder.CentralEurope)
        Dim centralEuropeHelveticaBoldItalicFont As Global.ceTe.DynamicPDF.Font = New HelveticaBoldOblique(Global.ceTe.DynamicPDF.Text.Encoder.CentralEurope)
        Dim fontFamily As Global.ceTe.DynamicPDF.FontFamily = New Global.ceTe.DynamicPDF.FontFamily("fontFamily", centralEuropeHelveticaRegularFont, centralEuropeHelveticaBoldFont, centralEuropeHelveticaItalicFont, centralEuropeHelveticaBoldItalicFont)

        Dim style7 As FormattedTextAreaStyle = New FormattedTextAreaStyle(fontFamily, 7.0F, True)
        Dim style8 As FormattedTextAreaStyle = New FormattedTextAreaStyle(fontFamily, 8.0F, True)
        Dim style9 As FormattedTextAreaStyle = New FormattedTextAreaStyle(fontFamily, 9.0F, True)
        Dim style10 As FormattedTextAreaStyle = New FormattedTextAreaStyle(fontFamily, 10.0F, True)

Dim textMain As String = "Магнитен прах протокол от изпитването"

currentPage.Elements.Add(New Label(textMain, PD.LeftMargin, currentY + 12.0F, PD.Width - PD.RightMargin * 3, 12.0F, centralEuropeHelveticaBoldFont, 12.0F, Global.ceTe.DynamicPDF.TextAlign.Center))

I hope you can help me out there.

With best regards

Maren
Addendum:

If i try to use the Unicode Encoder, i get the following error message:

Unable to cast object of type 'zz93.ad7' to type 'ceTe.DynamicPDF.Text.SingleByteEncoder'.

Dim centralEuropeHelveticaRegularFont As Global.ceTe.DynamicPDF.Font = New Helvetica(Global.ceTe.DynamicPDF.Text.Encoder.Unicode)
Posted by a ceTe Software moderator
Hi Maren,

It looks like you won't be able to use the build in Helvetica font. Try using an OpenType font with the characters you need:

        OpenTypeFont fontRegular = new OpenTypeFont(@"Font file path");
        OpenTypeFont fontBold = new OpenTypeFont(@"Font file path");
        OpenTypeFont fontItalic = new OpenTypeFont(@"Font file path");
        OpenTypeFont fontBoldItalic = new OpenTypeFont(@"Font file path");
        FontFamily fontFamily = new FontFamily("Verdafont", fontRegular, fontBold, fontItalic, fontBoldItalic);
        FormattedTextAreaStyle style1 = new FormattedTextAreaStyle(fontFamily, 12, true);
 
Thanks,
ceTe Software Support Team

All times are US Eastern Standard time. The time now is 2:02 AM.