Hi
I try to export the content of an ultrawingrid in PDF using this code :
private static void Export(UltraGrid grid, Stream target, GridExportFileFormat format)
{
using (var exporter = new UltraGridDocumentExporter())
exporter.Export(grid, target, format);
}
This works fine in the English version of the software, but not in the Chinese one.
I get an exception : Object reference not set to an instance of an object.
The stack trace is the following:
at Infragistics.Documents.Reports.TTF.Font.Subset(Boolean regular)
at Infragistics.Documents.Reports.PDF.Font.EmbedData()
at Infragistics.Documents.Reports.PDF.PdfDocument.Generate(Stream stream)
at Infragistics.Documents.Reports.Report.Report.Publish(Stream stream, FileFormat format)
at Infragistics.Win.UltraWinGrid.DocumentExport.UltraGridDocumentExporter.EndExportInternal(UltraGridExporterHelper ultraGridExporterHelper, Boolean canceled) at Infragistics.Win.UltraWinGrid.DocumentExport.UltraGridExporterHelper.Infragistics.Win.UltraWinGrid.IUltraGridExporter.EndExport(Boolean canceled) at Infragistics.Win.UltraWinGrid.UltraGrid.Export(IUltraGridExporter exporter) at Infragistics.Win.UltraWinGrid.DocumentExport.UltraGridDocumentExporter.Export(UltraGrid grid, ISection section) at Infragistics.Win.UltraWinGrid.DocumentExport.UltraGridDocumentExporter.Export(UltraGrid grid, Report report) at Infragistics.Win.UltraWinGrid.DocumentExport.UltraGridDocumentExporter.Export(UltraGrid grid, Stream stream, GridExportFileFormat fileFormat)
I guess it's because the Chinese version uses Simsun font, instead of Arial in the English version.
But I need to use Simsun in Chinese, it is not possible as Arial is not well readable in Chinese.
How could I do the PDF export ?
Thanks for your help.
Hi,
I tried an old sample I had and just changed the font to SimSun and it worked fine. This was of course using our new version where I changed the font embed algorithm to provide better support for languages like this... What version are you using? Can you post a sample and then I can take a look at what is happening for you.
Iuse V11.1, and I switched my PC to Chinese language.
I try to make a small sample that reproduce the problem.
Regards.
Ah, I made some changes in 12.2 or 13.1 for the font embed algorithm. I don't recall anyone getting exceptions before then just the font would not render in the pdf; so that concerns me and I'd like to take a look at what you have when you get a chance. Thanks for following up!
I managed to reproduce the problem in a small prototype. The key is to put Chinese characters in your grid.
I attached you the sample code and binaries in a zip format.
Just launch the exe and click on PDF export to reproduce the problem. No need to switch your PC to Chinese.
Thanks.
Hi Matthew,
My bad, your Display Language does need to be set to chinese for that bug to happen. I tried with Microsoft JhengHei and it works, so the issue must be relative to SimSun.
Regards
Looking at the project you are using Infragistics2.Shared.v11.1, Version=11.1.20111.1003. I ran the sample with that version and I got an exception but that was because of the location of the pdf as shown below:
exporter.Export(ultraGrid1,"D:\\ultragridExport.pdf", GridExportFileFormat.PDF);
To
exporter.Export(ultraGrid1,"C:\\ultragridExport.pdf", GridExportFileFormat.PDF);
Since I do not have a mapped D: drive. Once I changed that line, the grid exported fine and I attached the pdf I got when I did the export.
I noticed on my machine I have the SimSun Regular and SimSun-ExtB Regular fonts installed. Do you have those fonts installed on the machine you are doing the export? Does the attached pdf render the Chinese characters for you? What if you use Microsoft JhengHei for the font instead? Does that work?