- Code: Select all
List<Object> paragraphs = getAllElementFromObject(template.getMainDocumentPart(),P.class);
for(Object objP:paragraphs) {
P para = (P) objP;
/***/
List<Object> texts = getAllElementFromObject(para,Text.class);
List<Object> brs = getAllElementFromObject(para,Br.class);
if(brs.size()==1 && checkPageBreak((Br)brs.get(0)) && texts.size()== 0)
remove(template.getMainDocumentPart().getContent(), para);
}
But this removing use-full page break as well. So is there any way where I can check the page content height dynamically? Or track the blank page so I can remove that?