How to print Japanese characters using FixedContentEditor

1 Answer 107 Views
PdfProcessing
Aishwarya
Top achievements
Rank 1
Aishwarya asked on 27 Sep 2022, 08:08 AM

Hi,

I am looking for writing Japanese characters using FixedContentEditor. Can u please suggest the code. 

 

Thanks in advance.

Aishwarya

1 Answer, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 27 Sep 2022, 10:29 AM

Hello Aishwarya,

You have several options:

If you are creating a cross-platform app, using PdfProcessing .Net Standard assemblies you can choose from:

  1. Registering a font using the FontsRepository class and then setting this font to the desired text to be drawn by using the FixedContentEditor`s TextProperties:
    RadFixedDocument document = new();
    RadFixedPage firstPage = document.Pages.AddPage();
    FixedContentEditor editor = new(firstPage);
    editor.Position.Translate(20, 20);
    FontFamily qianTuXiaoTuTiFontFamlily = new FontFamily("QianTuXiaoTuTi"); byte[] data = File.ReadAllBytes("QianTuXiaoTuTi-2.ttf"); FontsRepository.RegisterFont(qianTuXiaoTuTiFontFamlily, FontStyles.Normal, FontWeights.Normal, data); FontsRepository.TryCreateFont(qianTuXiaoTuTiFontFamlily, out FontBase qianTuXiaoTuTiFont); editor.TextProperties.Font = qianTuXiaoTuTiFont; editor.DrawText("こんにちは世界!");
  2. There is an option to draw the text inside a Block as well: RadPdfProcessing manually register font.
  3. Another option is to pass the needed fonts using the FixedExtensibilityManager`s FontsProvider property. Detailed information can be found in the Cross Platform Support Fonts article. An example can be found in our GitHub repository: GenerateDocument.

If you are creating a .Net Framework app you can use PdfProcessing .Net Framework binaries and the needed fonts will be loaded out of the box from the OS (if they are installed):

RadFixedDocument document = new RadFixedDocument();
RadFixedPage firstPage = document.Pages.AddPage();
FixedContentEditor editor = new FixedContentEditor(firstPage);
editor.Position.Translate(20, 20);
editor.DrawText("こんにちは世界!");

I hope this helps. Do not hesitate to contact us if any additional questions arise.

Regards,
Martin
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
PdfProcessing
Asked by
Aishwarya
Top achievements
Rank 1
Answers by
Martin
Telerik team
Share this question
or