Itext 2.7.1 does not support the word-wrap: break-word property. Below is a link for this.
http://demo.itextsupport.com/xmlworker/itextdoc/flatsite.html
So, I manually broke the words into columns of the table and taking the maximum number of letters around 60-65. The following code for this.
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; }
source share