AlivePDF
AlivePDF copied to clipboard
Grid headers appear twice & some Chinese characters become irrecognizable
What steps will reproduce the problem?
1. using code following:
private var dp:ArrayCollection=new ArrayCollection();
dp.addItem( { 姓名 : "张三", 邮箱 : "[email protected]",
城市:"北京"});
dp.addItem( { 姓名 : "李四", 邮箱 : "[email protected]", 城市 : "上海" } );
dp.addItem( { 姓名 : "XYZ", 邮箱 : "[email protected]", 城市 : "ABC" } );
var p:PDF = new UnicodePDF(Orientation.PORTRAIT,Unit.MM,false);
p.addPage();
p.setFont( new ArialUnicodeMS(CidInfo.CHINESE_SIMPLIFIED) );
p.textStyle(new RGBColor(0x000000));
var columns:Array=[];
var gridColumnName:GridColumn = new GridColumn("姓名", "姓名", 45,
Align.LEFT, Align.LEFT);
columns.push(gridColumnName);
var gridColumnEmail:GridColumn = new GridColumn("邮箱", "邮箱", 40,
Align.LEFT, Align.LEFT);
columns.push(gridColumnEmail);
var gridColumnCity:GridColumn = new GridColumn("城市", "城市", 30,
Align.LEFT, Align.LEFT);
columns.push(gridColumnCity);
var grid:Grid = new Grid( dp.toArray(), 30, 15, new RGBColor(0xcccccc),new
RGBColor(0xcccccc),true,new RGBColor(0x887711),new
RGBColor(0x666666),1,5,5,Joint.ROUND,columns);
p.addGrid( grid );
var f:FileStream = new FileStream();
file = File.desktopDirectory.resolvePath("test.pdf");
f.open( file, FileMode.WRITE);
var bytes:ByteArray = p.save( Method.LOCAL );
f.writeBytes(bytes);
f.close();
2. The outcome is shown in the file attach.
What is the expected output? What do you see instead?
The characters should be recognizable and there the headers should be shown
only once.
What version of the product are you using? On what operating system?
Debian testing, get it via svn while using 1.5.0RC get no recognizable Chinese
characters.
Please provide any additional information below.
Original issue reported on code.google.com by [email protected] on 17 Jan 2011 at 8:20
Attachments:
I solved them all.
1. Comment the 3 lines below in function addGrid() of PDF.as:
setXY (x +currentGrid.x, y+getY() );
addRow( columnNames,'', rect);
endFill();
2. Change function excapeIt() from PDF.as as:
protected function escapeIt(content:String):String
{
content = findAndReplace('\\','\\\\',content);
content = findAndReplace('\n', "\\n",content);
content = findAndReplace('\r', "\\r",content);
content = findAndReplace('\t', "\\t",content);
content = findAndReplace('\b', "\\b",content);
content = findAndReplace('\f', "\\f",content);
//return findAndReplace(')','\\)',findAndReplace('(','\\(',findAndReplace('\\','\\\\',content)));
return findAndReplace(')','\\)',findAndReplace('(','\\(',content));
}
Original comment by [email protected] on 21 Jan 2011 at 3:31
Part 1 of the issue (duplicate header) has been fixed.
Original comment by [email protected] on 28 Feb 2015 at 12:21