added space in case empty paragraph with SPB at page slicing

This commit is contained in:
Georgy Litvinov 2016-08-31 10:14:49 +03:00 committed by Georgy Litvinov
parent 8db0060460
commit f482e1a054

View file

@ -513,11 +513,11 @@ public class PageSplitter {
//SPB FOUND
if (checkSoftPageBreak(paraChildNode, false)){
if (nodeName.equals(XMLString.TEXT_SOFT_PAGE_BREAK)){
// remove inner soft page break node
paraNode.removeChild(paraChildNode);
//Next node in paragraph. If it is text node go further
Node paraNextNode = paraChildNodes.item(i);
Node paraNextNode = paraChildNodes.item(i+1);
Node paraPrevNode = paraFirstPart.getLastChild();
String nextText = null;
String prevText = null;
@ -550,6 +550,15 @@ public class PageSplitter {
}
}
}
// In case paragraph is empty add space to prevent it's removing
if (paraNextNode == null && paraPrevNode == null){
Document doc = paraNode.getOwnerDocument();
Node space = doc.createTextNode(" ");
paraNode.insertBefore(space, paraChildNode);
}
// remove inner soft page break node
paraNode.removeChild(paraChildNode);
/* Check if next node in para is text and first char is a letter
* Check if last node in paraFirstPart is text and last char is a letter