We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Can i use Cyrillic charset (1251)?

Hello!

How i can change font charset in PDF document (for example) ?

What i can do with my code to see russian chars?

My sample:

PdfDocument document = new PdfDocument();
            document.PageSettings.Margins.All = 5;
            PdfPage page = document.Pages.Add();
            PdfGrid pdfGrid = new PdfGrid();
            pdfGrid.Columns.Add(4);
          
                var row = pdfGrid.Rows.Add();
                row.Cells[0].Value = "Наименование";
                row.Cells[1].Value = "Кол-во";
                row.Cells[2].Value = "Цена";
                row.Cells[3].Value = "Стоимость";
          
            pdfGrid.Draw(page, 0.0f, 0.0f);
            document.Save(stream);



6 Replies

PH Praveenkumar H Syncfusion Team November 25, 2014 01:07 PM UTC

Hi Ivan,

Thank you for using syncfusion products,

Currently we are not supporting the Unicode characters in Syncfusion xamarin PDF, we have logged the feature request internally, and we will update you once the feature has been implemented.

Please let us know if you need further assistance.

With Regards,

Praveen



PH Praveenkumar H Syncfusion Team November 26, 2014 12:24 PM UTC

Hi Ivan,

A quick notes on previous update, the feature for supporting the Unicode characters in xamarin platform will be available in our next Syncfusion xamarin refresh release.

Please let us know if you need further assistance.

With Regards,

Praveen



BG Benito Gomez August 7, 2015 12:34 PM UTC

Hi, is that feature actually available?

I'm generating the pdf from PCL Portable Library on Xamrin.iOS, but seems to be the same problem, i can't write cyrillic characters.

Thanks in advance.


PH Praveenkumar H Syncfusion Team August 10, 2015 12:29 PM UTC

Hi Ivan,

Thank you for your update,

We have added the Unicode character support in PDF portable library, please use the below code to load font and draw the Unicode text.

Stream fontStream = typeof(MainActivity).GetTypeInfo().Assembly.GetManifestResourceStream("PDFFormTesting.Assets.ArialUnicodeMS.ttf");

//loading true type font

PdfTrueTypeFont font = new PdfTrueTypeFont(fontStream, 24);

PdfDocument doc = new PdfDocument();

PdfPage page = doc.Pages.Add();

//drawing string
page.Graphics.DrawString("Наименование", font, PdfBrushes.Red, 0, 0);

Please try the above code snippet and let us know your result.

With Regards,
Praveen



EM Emil September 8, 2018 10:10 PM UTC

i am also looking for Cyrillic alphabet in pdf but  when search for ArialUnicodeMS.ttf on google, there is 14mb file size. this almost impossible to use in an mobile application :( 


KC Karthikeyan Chandrasekar Syncfusion Team September 10, 2018 12:13 PM UTC

Hi Emil, 
Yes, you have to place the TTF file in the application to get it included in the PDF document. However, we have an optional workaround to get the TTF directly from the device at runtime using open source third party library SkiaSharp. Please refer the below code example for further details. 

             
            //Create new PDF document. 
            PdfDocument doc = new PdfDocument();           
 
            //Add page to the PDF document. 
            PdfPage page = doc.Pages.Add();             
 
            //Get font from device using Skia Sharp. 
            Stream fontStream = GetFontStream("Arial Unicode Ms"); 
 
            //Create new PdfTrueTypeFont instance. 
            PdfTrueTypeFont font = new PdfTrueTypeFont(fontStream, 12); 
 
            //Draw text. 
            page.Graphics.DrawString("Наименование", font, PdfBrushes.Black, PointF.Empty); 
 
            MemoryStream stream = new MemoryStream(); 
 
            //Save the PDF document 
            doc.Save(stream); 
 
            //Close the PDF document 
            doc.Close(true); 
 

 
private Stream GetFontStream(string fontName) 
        { 
            SKTypeface typeface = SKTypeface.FromFamilyName(fontName, SKTypefaceStyle.Normal); 
            SKStreamAsset stream = typeface.OpenStream(); 
            if (stream != null && stream.Length > 0) 
            { 
                byte[] fontData = new byte[stream.Length - 1]; 
                stream.Read(fontData, stream.Length); 
                stream.Dispose(); 
                return new MemoryStream(fontData); 
            } 
            else 
                return null; 
        } 
 
Regards, 
Karthikeyan 


Loader.
Live Chat Icon For mobile
Up arrow icon