From c53e086518c2c4ea2b7651d61d14e45f4da63fef Mon Sep 17 00:00:00 2001 From: "CITE\\spapacharalampous" Date: Fri, 19 Jul 2024 17:37:54 +0300 Subject: [PATCH] fix on pdf export: trim empty spaces --- .../service/wordfiletransformer/word/HtmlToWorldBuilder.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/src/main/java/org/opencdmp/filetransformer/docx/service/wordfiletransformer/word/HtmlToWorldBuilder.java b/core/src/main/java/org/opencdmp/filetransformer/docx/service/wordfiletransformer/word/HtmlToWorldBuilder.java index c77f851..ab4d917 100644 --- a/core/src/main/java/org/opencdmp/filetransformer/docx/service/wordfiletransformer/word/HtmlToWorldBuilder.java +++ b/core/src/main/java/org/opencdmp/filetransformer/docx/service/wordfiletransformer/word/HtmlToWorldBuilder.java @@ -2,6 +2,7 @@ package org.opencdmp.filetransformer.docx.service.wordfiletransformer.word; import org.apache.poi.xwpf.usermodel.*; import org.apache.xmlbeans.XmlCursor; +import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Node; import org.jsoup.nodes.TextNode; @@ -61,6 +62,10 @@ public class HtmlToWorldBuilder implements NodeVisitor { @Override public void head(Node node, int i) { + + String htmlToPlainText = Jsoup.parse(node.outerHtml()).text(); + if (htmlToPlainText.trim().isEmpty()) return; + String name = node.nodeName(); if (name.equals("#text")) { String text = ((TextNode)node).text();