return FALSE; $r = well_tag_thread__update(array('id' => $id), $update); return $r; } function well_tag_thread_find($tagid, $page, $pagesize) { $arr = well_tag_thread__find(array('tagid' => $tagid), array('id' => -1), $page, $pagesize); return $arr; } function well_tag_thread_find_by_tid($tid, $page, $pagesize) { $arr = well_tag_thread__find(array('tid' => $tid), array(), $page, $pagesize); return $arr; } ?>java - How to remove additional line breaks rendered in docx from `br` tags when using docx4j `mainDocumentPart.convertAltChunks
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

java - How to remove additional line breaks rendered in docx from `br` tags when using docx4j `mainDocumentPart.convertAltChunks

programmeradmin1浏览0评论

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?

发布评论

评论列表(0)

  1. 暂无评论