RubyPDF Blog .NET,English,iTextSharp(iText#),PDF How to let SharpDevelop Reports support CJK encoding PDF export

How to let SharpDevelop Reports support CJK encoding PDF export

Glad to know iTextSharp is used in SharpDevelop Reports, because iTextSharp supports CJK(maybe I should say it supports all encodings).

I downloaded SharpDevelopReports_2.2.0.263_Source and had a test, it does not support Chinese Characters, so I reviewed the source codes, I found the following lines,

if (this.StyleDecorator.Font.Unit == GraphicsUnit.Point) {

font = FontFactory.GetFont(this.StyleDecorator.Font.FontFamily.Name,
this.StyleDecorator.Font.Size,
(int)this.StyleDecorator.Font.Style);
} else {

font = FontFactory.GetFont(this.StyleDecorator.Font.FontFamily.Name,
new UnitConverter(this.StyleDecorator.Font.Size,XGraphicsUnit.Pixel).Point,
(int)this.StyleDecorator.Font.Style);
}

by default, it only supports “CP1250”, it can not show Chinese Characters correctly. I changed the codes to
if (this.StyleDecorator.Font.Unit == GraphicsUnit.Point) {

font = FontFactory.GetFont(this.StyleDecorator.Font.FontFamily.Name, BaseFont.IDENTITY_H,
this.StyleDecorator.Font.Size,
(int)this.StyleDecorator.Font.Style);
} else {

font = FontFactory.GetFont(this.StyleDecorator.Font.FontFamily.Name,BaseFont.IDENTITY_H,
new UnitConverter(this.StyleDecorator.Font.Size,XGraphicsUnit.Pixel).Point,
(int)this.StyleDecorator.Font.Style);
}

let it uses “IDENTITY_H”, and it can show Chinese now, of course it is not a good way, and I found JasperReports also stores pdfEncoding in report files , here is an example,

<font fontName=”Arial” size=”14″ pdfFontName=”ARIAL.TTF” pdfEncoding=”Identity-H” isPdfEmbedded=”true”/>


so how about sdr? btw, how about let SharpDevelope Reports supports JasperReports format? JasperReports format is very popular and mature now.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.