diff --git a/src/main/java/writer2latex/xhtml/DocumentSeparator.java b/src/main/java/writer2latex/xhtml/DocumentSeparator.java
index 4938817..02553ce 100644
--- a/src/main/java/writer2latex/xhtml/DocumentSeparator.java
+++ b/src/main/java/writer2latex/xhtml/DocumentSeparator.java
@@ -22,6 +22,7 @@ public class DocumentSeparator {
private int splitLevel = 0;
private boolean splitByPages = false;
private int lastSplitPageNum = 1;
+ private Integer pageNumber = null;
private static LinkedList headerStack = new LinkedList();
private static boolean pageOpened = false;
@@ -149,24 +150,36 @@ public class DocumentSeparator {
return hnode;
}
- private Node openPageDiv(Node node,int pageNum){
+ private Node openPageDiv(Node node,int curPageNum){
if (node == null){
System.out.println("Error: node is null on openPageDiv");
return node;
}
if (prevPageNode != null && splitByPages) {
- arrangePageDivs(node,pageNum);
+ arrangePageDivs(node,curPageNum);
}
+ breakPage(node,curPageNum);
Document doc = node.getOwnerDocument();
Element openBlock = (Element) doc.createElement(DIV);
openBlock.setAttribute("class", "pageNum");
- openBlock.setAttribute("page", Integer.toString(pageNum));
+ openBlock.setAttribute("page", Integer.toString(curPageNum));
// insert open section comment before header node
node.appendChild((Node)openBlock);
node = openBlock;
return openBlock;
}
+ private void breakPage(Node node, int curPageNum) {
+ if (pageNumber != null && pageNumber != curPageNum) {
+
+ Document doc = node.getOwnerDocument();
+ Element pageBreak = (Element) doc.createElement(DIV);
+ pageBreak.setAttribute("class", "pageBreak");
+ node.appendChild(pageBreak);
+ }
+ pageNumber = curPageNum;
+ }
+
private void arrangePageDivs(Node node, int pageNum) {
Document newdoc = node.getOwnerDocument();
Document olddoc = prevPageNode.getOwnerDocument();