fix on pdf export: trim empty spaces

This commit is contained in:
CITE\spapacharalampous 2024-07-19 17:37:54 +03:00
parent 9e5029e1ab
commit c53e086518
1 changed files with 5 additions and 0 deletions

View File

@ -2,6 +2,7 @@ package org.opencdmp.filetransformer.docx.service.wordfiletransformer.word;
import org.apache.poi.xwpf.usermodel.*; import org.apache.poi.xwpf.usermodel.*;
import org.apache.xmlbeans.XmlCursor; import org.apache.xmlbeans.XmlCursor;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document; import org.jsoup.nodes.Document;
import org.jsoup.nodes.Node; import org.jsoup.nodes.Node;
import org.jsoup.nodes.TextNode; import org.jsoup.nodes.TextNode;
@ -61,6 +62,10 @@ public class HtmlToWorldBuilder implements NodeVisitor {
@Override @Override
public void head(Node node, int i) { public void head(Node node, int i) {
String htmlToPlainText = Jsoup.parse(node.outerHtml()).text();
if (htmlToPlainText.trim().isEmpty()) return;
String name = node.nodeName(); String name = node.nodeName();
if (name.equals("#text")) { if (name.equals("#text")) {
String text = ((TextNode)node).text(); String text = ((TextNode)node).text();