When I add Unicode strings (such as Chinese characters) using the IText.AddContent() method to a report, it displays as blanks. Does the Documents engine supports Unicode? If so, could you show me how to do this properly?
Thanks,
Herbert
Hi Herbert,
I just tested this out and it works fine for me. Here's the code I used:
Report report = new Report(); ISection section = report.AddSection(); IText text = section.AddText(); text.Style.Font = new Font("Arial", 12); text.AddContent("Arial"); text = section.AddText(); text.Style.Font = new Font("Arial Unicode MS", 12); text.AddContent("Arial Unicode MS"); text = section.AddText(); text.Style.Font = new Font("MingLiu", 12); text.AddContent("兩小時預警"); string fileName = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Application.ExecutablePath), "x.pdf"); report.Publish(fileName, FileFormat.PDF); Process.Start(fileName);
I have already set the style of the IText interface to use a Chinese font but it still generated blanks in PDF. If I generate an XPS, then it displays properly.
Here is the code (C++/CLI) that adds the Client cell to the table:
Documents::Graphics::Font ^ChFont = gcnew Documents::Graphics::Font(L"MingLiu",12,Documents::Graphics::FontStyle::Regular); Documents::Report::Text::Style ^ChStyle = gcnew Documents::Report::Text::Style(ChFont,Documents::Graphics::Brushes::Black); Cell = Row->AddCell(); Cell->Width = gcnew Documents::Report::RelativeWidth(20); Cell->Borders = gcnew Documents::Report::Borders(Documents::Graphics::Pens::Black); Cell->Paddings->All = 2; Txt = Cell->AddText(); Txt->Style = ChStyle; Txt->AddContent(L"兩小時預警");
MingLiu is a Chinese font from Windows. I have attached the generated PDF file. Note that the Client cell is blank.
Regards,
The same question is discussed here: UltraGridDocumentExporter 2-byte word data problem - Infragistics Community