过去 7 天内的血糖平均 : 111.37 mg/dL
this renders properly everywhere, including on the graph titles and axis and such, but the PDF control only allows for 5 fonts to be passed to the DrawString as the PdfFont parameter - I tried all 5 and the above string renders in the PDF output as:
7 : 111.37 mg/dL
For other languages like German, French, Spanish etc... it renders fine, of course - just graphical languages that require special fonts - Word uses "Microsoft JhengHei" for this, it can also use "MS Gothic" and the like.
Just checking if there's something simple I'm missing or if the PDF component does not support rendering strings for all languages.
thanks
Stream fontStream = typeof(App).GetTypeInfo().Assembly.GetManifestResourceStream("jhenghei.ttf"); PdfTrueTypeFont font = new PdfTrueTypeFont(fontStream, 12);
page.Graphics.DrawString("过去 7 天内的血糖平均", font, PdfBrushes.Black, new PointF(10, 10));
|
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Add a new page to the PDF document.
PdfPage page = document.Pages.Add();
//Create a textbox field and add the properties.
PdfTextBoxField textBoxField = new PdfTextBoxField(page, "CompanyName");
Stream fontStream = typeof(App).GetTypeInfo().Assembly.GetManifestResourceStream("jhenghei.ttf");
PdfTrueTypeFont font = new PdfTrueTypeFont(fontStream, 12);
//Set the font to the form field.
textBoxField.Font = font;
textBoxField.Text = "Syncfusion";
textBoxField.Bounds = new RectangleF(0, 0, 100, 20);
textBoxField.ToolTip = "First Name";
//Add the form field to the document.
document.Form.Fields.Add(textBoxField);
MemoryStream stream = new MemoryStream();
document.Save(stream); |
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Add a new page to the PDF document.
PdfPage page = document.Pages.Add();
//Create PDF graphics for the page.
PdfGraphics graphics = page.Graphics;
//Load the open type font.
Stream fontStream = typeof(MainPage).GetTypeInfo().Assembly.GetManifestResourceStream("Sample.Assets.NotoSerifCJKjp-Regular.otf");
PdfTrueTypeFont font = new PdfTrueTypeFont(fontStream, 14);
//Draw the text.
graphics.DrawString("你好,世界", font, PdfBrushes.Black, new PointF(0, 0));
graphics.DrawString("こんにちは世界", font, PdfBrushes.Black, new PointF(0, 50));
//Save the document to the stream
MemoryStream stream = new MemoryStream();
document.Save(stream);
//Close the document
document.Close(true); |