Itext 2.7.1不支持word-wrap:break-word屬性。以下是該鏈接。
http://demo.itextsupport.com/xmlworker/itextdoc/flatsite.html
所以我根據無表的列,並採取圍繞60-65.Following最大字母的假設是,該代碼手動打破的話。
public String getBrokenWordsForPdfGeneration(String longString, int cutIndex){
StringBuffer mainStringBuffer = new StringBuffer(longString);
String returnString = "";
while(mainStringBuffer != null && mainString.length()>0 &&
mainString.subString(0,mainString.length()>cutIndex?cutIndex:mainString.length()) != null){
if(mainStrig.subString(0,mainString.length()>cutIndex:mainString.length()).trim().contains(" ")){
returnString += mainStrig.subString(0,mainString.length()>cutIndex:mainString.length()).trim();
mainStringBuffer.delete(0,mainString.length()>cutIndex:mainString.length());
}else{
returnString += mainStrig.subString(0,mainString.length()>cutIndex:mainString.length()).trim()+ " ";
mainStringBuffer.delete(0,mainString.length()>cutIndex:mainString.length());
}
}
return returnString;
}
來源
2012-08-02 06:33:44
PVR
break-word是一個css3屬性。 iText在從html轉換時是否完全支持css3,很難說文檔已關閉 – Woody 2012-08-01 08:45:33
Thanks @Woody,由於您的評論,我確實知道IText不支持分詞。 – PVR 2012-08-02 06:13:46