public static void adjustStyle(Element element){
if(element!=null&&element.tagName().equalsIgnoreCase("table")){
Elements trs = element.select("tr");
for(int tri=0;tri<trs.size();tri++){
Element tr = trs.get(tri);
int trHeight = -1;
if(tr.hasAttr("height")){
String trHeightS = tr.attr("height");
try{
trHeight = Integer.parseInt(trHeightS);
}catch(NumberFormatException e){
e.printStackTrace();
}
}
Elements tds = tr.children();
int tdHeight = -1;
for(int tdi=0;tdi<tds.size();tdi++){
Element td = tds.get(tdi);
if(td.hasAttr("height")){
String tdHeightS = td.attr("height");
try{
tdHeight = Integer.parseInt(tdHeightS);
}catch(NumberFormatException e){
e.printStackTrace();
}
}
if(tdHeight>trHeight){
trHeight = tdHeight;
}
/**!
* 处理生成的HTML的颜色的问题
*/
Elements fonts = td.select("font");
if(fonts.size()==0){
css(td,"font-size","1.64em");
}
for(int fonti=0;fonti<fonts.size();fonti++){
Element font = fonts.get(fonti);
if(font.hasAttr("size")){
String fontsizeS = font.attr("size");
try{
int fontsize = Integer.parseInt(fontsizeS);
switch(fontsize){
case 1: css(td,"font-size","1.26em");
break;
case 2: css(td,"font-size","1.64em");
break;
case 3: css(td,"font-size","2.0em");
break;
case 4: css(td,"font-size","2.26em");
break;
case 5: css(td,"font-size","3.0em");
break;
case 6: css(td,"font-size","4em");
break;
case 7: css(td,"font-size","6em");
break;
default: css(td,"font-size","1.26em");
}
}catch(NumberFormatException e){
e.printStackTrace();
}
}else{
css(td,"font-size","1.64em");
}
if(font.hasAttr("color")){
css(td, "color", font.attr("color"));
}
if(font.hasAttr("face")){
css(td,"font-family",font.attr("face"));
}
}
/**!
* 处理字体在单元格中的位置问题
*/