diff --git a/fine-itext/src/com/fr/third/v2/lowagie/text/html/simpleparser/HTMLWorker.java b/fine-itext/src/com/fr/third/v2/lowagie/text/html/simpleparser/HTMLWorker.java index e8f3f1406..a3558dab3 100644 --- a/fine-itext/src/com/fr/third/v2/lowagie/text/html/simpleparser/HTMLWorker.java +++ b/fine-itext/src/com/fr/third/v2/lowagie/text/html/simpleparser/HTMLWorker.java @@ -171,6 +171,7 @@ public class HTMLWorker implements SimpleXMLDocHandler, DocListener { worker.setInterfaceProps(interfaceProps); worker.objectList = new ArrayList(); worker.parse(reader); + return worker.objectList; } @@ -178,7 +179,7 @@ public class HTMLWorker implements SimpleXMLDocHandler, DocListener { try { for (int k = 0; k < stack.size(); ++k) document.add((Element) stack.elementAt(k)); - if (currentParagraph != null) + if (needAddLastParagraph()) document.add(currentParagraph); currentParagraph = null; } catch (Exception e) { @@ -186,6 +187,18 @@ public class HTMLWorker implements SimpleXMLDocHandler, DocListener { } } + private boolean needAddLastParagraph() { + if (currentParagraph == null) { + return false; + } + ArrayList list = currentParagraph.getChunks(); + if (!(list.size() == 1 && list.get(0) instanceof Chunk)) { + return true; + } + Chunk c = (Chunk) list.get(0); + return c.getImage() != null || c.getContent().trim().length() != 0; + } + public void startDocument() { HashMap h = new HashMap(); style.applyStyle("body", h);