admin管理员组文章数量:1312763
When using HTML string having line breaks(br
tags) and using mainDocumentPart.convertAltChunks()
method of docx4j (v 8.3.11), empty lines/line breaks are more than the number of br
tags which should not be the case.
HTML content:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
".dtd">
<html
xmlns=";>
<head>
<title></title>
</head>
<body>
<h1
class="Heading1"
style="font-weight: normal; line-height: 1.1; margin-top: 0.2em; margin-bottom: 0.2em;; background-color: transparent; color: rgb(64, 64, 64); font-family: Calibri; font-size: 24pt">Lorem
Ipsum</h1>
<br
class="dre-paragraph"
style="line-height: 1.3; margin-top: 0.1em; margin-bottom: 0.1em; background-color: transparent; color: rgb(64, 64, 64); font-family: Calibri; font-size: 11pt" />
<h2
class="Heading2"
style="font-weight: normal; line-height: 1.1; margin-top: 0.2em; margin-bottom: 0.2em;; margin-left: 30px; background-color: transparent; color: rgb(64, 64, 64); font-family: Calibri; font-size: 19.5pt">Lorem
Ipsum</h2>
<hr
style="border: none;border-top: 1px solid #e6e6e6;margin: 12px 0;"
size="1"
color="#E6E6E6"
class="dre-horizontalRule" />
<br
class="dre-paragraph"
style="line-height: 1.3; margin-top: 0.1em; margin-bottom: 0.1em; background-color: transparent; color: rgb(64, 64, 64); font-family: Calibri; font-size: 11pt" />
<h3
class="Heading3"
style="font-weight: normal; line-height: 1.1; margin-top: 0.2em; margin-bottom: 0.2em;; background-color: transparent; color: rgb(64, 64, 64); font-family: Calibri; font-size: 15pt">Lorem
Ipsum</h3>
<br
class="dre-paragraph"
style="line-height: 1.3; margin-top: 0.1em; margin-bottom: 0.1em; background-color: transparent; color: rgb(64, 64, 64); font-family: Calibri; font-size: 11pt" />
</body>
</html>
After adding above HTML content as altchunk and using mainDocumentPart.convertAltChunks()
the generated docx elements(mainDocumentPart.getContent()
) have few extra text elements with single space(
). Tried remove those elements as well resulting run elements having no child elements but still generated docx have more line breaks than the number of br
tags which should not be the case.
How to fix this?
本文标签:
版权声明:本文标题:java - How to remove additional line breaks rendered in docx from `br` tags when using docx4j `mainDocumentPart.convertAltChunks 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741904499a2404062.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论