- Home
- Forum
- Xamarin.Forms
- Can i use Cyrillic charset (1251)?
Can i use Cyrillic charset (1251)?
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);
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
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
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
|
//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;
}
|
- 6 Replies
- 5 Participants
-
IV Ivan
- Nov 24, 2014 08:24 PM UTC
- Sep 10, 2018 12:13 PM UTC