I use apache.poi create doc, use aspose.words to save the doc but toc page num is error

@ssj123ssj As I have mentioned PAGE fields in the document’s header/footer are update on the fly by the consumer application. To update these fields MS Word builds the document layout. The difference might be cause by different font set used on the machine where the document was generated and on the machine where the document is viewed.

Can you help me take a look at this issue.
I want to use aspose to load a piece of HTML, some of which have annotations added. How can I recognize these contents and create annotations when generating the doc.

@ssj123ssj Could you please attach your input HTML and expected output DOCX? We will check the documents and provide you more information.

it just like this:
this is my html:
html.docx (10.4 KB)

this is the doc I want to generate:
字体测试1 (8).docx (15.2 KB)

@ssj123ssj You should use the following HTML structure to insert content with comments:

<div>
    <p style="margin-top:0pt; margin-bottom:8pt">
        <span>Test </span><a name="_cmntref1"><span>commented text</span></a><a href="#_cmnt1" style="text-decoration:none"><span style="font-size:8pt">[AN1]</span></a><span> some other text</span>
    </p>
</div>
<div id="_cmnt1" style="-aw-comment-author:'Alex Noskov'; -aw-comment-datetime:'2024-09-03T14:41:00'; -aw-comment-initial:'AN'">
    <p style="margin-top:0pt; margin-bottom:8pt; line-height:normal; font-size:10pt">
        <a href="#_cmntref1" style="text-decoration:none"><span style="font-size:8pt">[AN1]</span></a><span>Comment text</span>
    </p>
</div>

thanks,could you tell me what this AN1 means.
and if I have multiple annotations and some of them have replies, how should I write this HTML.

I tried using this HTML and it also is okay, but I don’t know how to add annotations reply:

<div>
    <p style="margin-top:0pt; margin-bottom:8pt">
        <span>这是</span><a name="_cmntref1"><span>我的批注1</span></a><a href="#_cmnt1"></a><span>测试文档1</span>
    </p>
	<p style="margin-top:0pt; margin-bottom:8pt">
        <span>这是</span><a name="_cmntref2"><span>我的批注2</span></a><a href="#_cmnt2"></a><span>测试文档2</span>
    </p>
	<p style="margin-top:0pt; margin-bottom:8pt">
        <span>这是</span><a name="_cmntref3"><span>我的批注3</span></a><a href="#_cmnt3"></a><span>测试文档3</span>
    </p>
</div>
<div id="_cmnt1" style="-aw-comment-author:'SSJ'; -aw-comment-datetime:'2024-09-03T14:31:00'; -aw-comment-initial:'ssj'">
    <p style="margin-top:0pt; margin-bottom:8pt; line-height:normal; font-size:10pt">
        <a href="#_cmntref1"></a><span>批注1</span>
    </p>
</div>
<div id="_cmnt2" style="-aw-comment-author:'HGG'; -aw-comment-datetime:'2024-09-03T14:41:00'; -aw-comment-initial:'ssj'">
    <p style="margin-top:0pt; margin-bottom:8pt; line-height:normal; font-size:10pt">
        <a href="#_cmntref2"></a><span>批注2</span>
    </p>
</div>
<div id="_cmnt3" style="-aw-comment-author:'RML'; -aw-comment-datetime:'2024-09-03T14:51:00'; -aw-comment-initial:'ssj'">
    <p style="margin-top:0pt; margin-bottom:8pt; line-height:normal; font-size:10pt">
        <a href="#_cmntref3"></a><span>批注3</span>
    </p>
</div>

@ssj123ssj AN1 is initials. You can create the required content in MS Word document and save it to HTML using Aspose.Words. Such way you can see how Aspose.Words exports the roundtrip information. Here is HTML of comment with replies:

<div>
	<p style="margin-top:0pt; margin-bottom:8pt">
		<a name="_cmntref1"></a><a name="_cmntref2"><span>test</span><span style="-aw-comment-end:_cmntref1"></span></a><a href="#_cmnt1" style="text-decoration:none"><span style="font-size:8pt">[AN1]</span></a><span style="-aw-comment-end:_cmntref2"></span><a href="#_cmnt2" style="text-decoration:none"><span style="font-size:8pt">[AN2]</span></a>
	</p>
</div>
<hr style="width:33%; height:1px; text-align:left" />
<div id="_cmnt1" style="-aw-comment-author:'Alex Noskov'; -aw-comment-datetime:'2024-09-04T07:25:00'; -aw-comment-initial:'AN'">
	<p style="margin-top:0pt; margin-bottom:8pt; line-height:normal; font-size:10pt">
		<a href="#_cmntref1" style="text-decoration:none"><span style="font-size:8pt">[AN1]</span></a><span>This is comment</span>
	</p>
</div>
<div id="_cmnt2" style="-aw-comment-author:'Alex Noskov'; -aw-comment-datetime:'2024-09-04T07:26:00'; -aw-comment-initial:'AN'; -aw-comment-parent-id:_cmnt1">
	<p style="margin-top:0pt; margin-bottom:8pt; line-height:normal; font-size:10pt">
		<a href="#_cmntref2" style="text-decoration:none"><span style="font-size:8pt">[AN2]</span></a><span>This is reply</span>
	</p>
</div>

That’s OK. Thank you very much!

1 Like

Can you help me take a look at this issue.
This document paragraph have multiple sections, which will be displayed based on different conditions. so how to continue the numbering at the beginning of the paragraph.
This is the original document content:


It could be like this:

It could also be like this

I want to make the document number correct.

@ssj123ssj You can use list numbering to achieve this. Please see our documentation for more information:
https://docs.aspose.com/words/java/working-with-lists/

Of course, I have reviewed your technical documentation, but the code above is just some simple examples that are not applicable to my scenario.

What I want to know is if my document has already been generated, can I go and regenerate the list numbers in the document, it have different ListTemplate type.

@ssj123ssj If you would like to get the displayed list item label, you can use ListLabel.LabelString property, but first it is required to call Document.UpdateListLabels method.

Maybe I didn’t explain the problem clearly. I was reading a section of HTML to generate a document, and because the content read varies under different conditions, the numbering of the document list is not continuous.
the html maybe like this:

<html>
 <head></head>
 <body>
  <h1 style="text-align: center;"><span style="mso-bookmark: _Toc5270;"><span style="mso-bookmark: _Toc30437;"><span style="mso-bookmark: _Toc22413;"><span style="mso-bookmark: _Toc30113;"><span style="mso-bookmark: _Toc25776;"><span style="mso-bookmark: _Toc7987;"><span style="mso-bookmark: _Toc31317;"><span style="mso-bookmark: _Toc2401;"><strong style="mso-bidi-font-weight: normal;"><span style="font-size: 16.0pt; line-height: 150%; font-family: 仿宋; mso-bidi-font-family: 仿宋; mso-font-kerning: 0pt;">三、承诺与声明</span></strong></span></span></span></span></span></span></span></span></h1>
  <p class="MsoNormal" style="text-indent: 24.0pt; mso-char-indent-count: 2.0; line-height: 150%;"><span style="font-size: 12.0pt; line-height: 150%; font-family: 仿宋; mso-bidi-font-family: 仿宋; mso-font-kerning: 0pt;">(一)管理人承诺与声明</span></p>
  <p class="MsoNormal" style="text-indent: 24.0pt; mso-char-indent-count: 2.0; line-height: 150%;"><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: 仿宋; mso-bidi-font-family: 仿宋; mso-font-kerning: 0pt;">1.</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 仿宋; mso-bidi-font-family: 仿宋; mso-font-kerning: 0pt;">在签订本合同前充分向投资者说明了有关法律、行政法规和相关投资工具的运作市场及方式,并充分揭示了相关风险。</span></p>
  <p class="MsoNormal" style="text-indent: 24.0pt; mso-char-indent-count: 2.0; line-height: 150%;"><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: 仿宋; mso-bidi-font-family: 仿宋; mso-font-kerning: 0pt;">3.</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 仿宋; mso-bidi-font-family: 仿宋; mso-font-kerning: 0pt;">已经了解投资者的风险偏好、风险认知能力和承受能力,对投资者的财务状况进行了充分评估。</span></p>
  <p class="MsoNormal" style="text-indent: 24.0pt; mso-char-indent-count: 2.0; line-height: 150%;"><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: 仿宋; mso-bidi-font-family: 仿宋; mso-font-kerning: 0pt;">4.</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 仿宋; mso-bidi-font-family: 仿宋; mso-font-kerning: 0pt;">按照《基金法》恪尽职守、诚实信用、谨慎勤勉的原则管理和运用受托资产,不保证受托资产一定盈利,也不保证最低收益或本金不受损失,以及限定投资损失金额或者比例。</span></p>
  <p class="MsoNormal" style="text-indent: 24.0pt; mso-char-indent-count: 2.0; line-height: 150%;"><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: 仿宋; mso-bidi-font-family: 仿宋; mso-font-kerning: 0pt;">6.</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 仿宋; mso-bidi-font-family: 仿宋; mso-font-kerning: 0pt;">风险恪尽职守偏好已经了解投资者的风险偏好、风险认知能力和承受能力,对投资者的财务状况进行了充分评估。</span></p>
  <p class="MsoNormal" style="text-indent: 24.0pt; mso-char-indent-count: 2.0; line-height: 150%;"><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: 仿宋; mso-bidi-font-family: 仿宋; mso-font-kerning: 0pt;">8.</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 仿宋; mso-bidi-font-family: 仿宋; mso-font-kerning: 0pt;">恪尽职签订本合同前守按照《基金法》恪尽职守、诚实信用、谨慎勤勉的原则管理和运用受托资产,不保证受托资产一定盈利,也不保证最低收益或本金不受损失,以及限定投资损失金额或者比例。</span></p>
  <p class="MsoNormal" style="text-indent: 24.0pt; mso-char-indent-count: 2.0; line-height: 150%;"><span style="font-size: 12.0pt; line-height: 150%; font-family: 仿宋; mso-bidi-font-family: 仿宋; mso-font-kerning: 0pt;">(二)托管人承诺与声明</span></p>
  <p class="MsoNormal" style="text-indent: 24.0pt; mso-char-indent-count: 2.0; line-height: 150%;"><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: 仿宋; mso-bidi-font-family: 仿宋; mso-font-kerning: 0pt;">2.</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 仿宋; mso-bidi-font-family: 仿宋; mso-font-kerning: 0pt;">按照《基金法》恪尽职守、诚实信用、谨慎勤勉的原则安全保管受托资产,履行信义义务以及本合同约定的其他义务。</span></p>
  <p class="MsoNormal" style="text-indent: 24.0pt; mso-char-indent-count: 2.0; line-height: 150%;"><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: 仿宋; mso-bidi-font-family: 仿宋; mso-font-kerning: 0pt;">3.</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 仿宋; mso-bidi-font-family: 仿宋; mso-font-kerning: 0pt;">根据法律、行政法规、中国证监会及证券投资基金业协会的规定和资产管理合同的约定,对管理人的投资或者清算指令等进行监督。</span></p>
  <p class="MsoNormal" style="text-indent: 24.0pt; mso-char-indent-count: 2.0; line-height: 150%;"><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: 仿宋; mso-bidi-font-family: 仿宋; mso-font-kerning: 0pt;">5.</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 仿宋; mso-bidi-font-family: 仿宋; mso-font-kerning: 0pt;">根据管理人发生法律、行政法规、中国证监会及证依照法律券投资基金业协会的规定和资产管理合同的约定,对管理人的投资或者清算指令等进行监督。</span></p>
  <p class="MsoNormal" style="text-indent: 24.0pt; mso-char-indent-count: 2.0; line-height: 150%;"><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: 仿宋; mso-bidi-font-family: 仿宋; mso-font-kerning: 0pt;">6.</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 仿宋; mso-bidi-font-family: 仿宋; mso-font-kerning: 0pt;">根据依照法律法律、行政法规、中国证监会依照法律及证券投资基金业协会的规定和资产管理合同的约定,对管理人的投资或者清算指令等进行监督。</span></p>
  <p class="MsoNormal" style="text-indent: 24.0pt; mso-char-indent-count: 2.0; line-height: 150%;"><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: 仿宋; mso-bidi-font-family: 仿宋; mso-font-kerning: 0pt;">8.</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 仿宋; mso-bidi-font-family: 仿宋; mso-font-kerning: 0pt;">在管理人发生异常且无法履行管理职能时,依照法律、行政法规以及合同约定召集份额持有人大会(如有),维护投资者权益,份额持有人大会设立日常机构的除外。</span></p>
  <p class="MsoNormal" style="text-indent: 24.0pt; mso-char-indent-count: 2.0; line-height: 150%;"><span style="font-size: 12.0pt; line-height: 150%; font-family: 仿宋; mso-bidi-font-family: 仿宋; mso-font-kerning: 0pt;">(三)投资者承诺与声明</span></p>
  <p class="MsoNormal" style="text-indent: 24.0pt; mso-char-indent-count: 2.0; line-height: 150%;"><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: 仿宋; mso-bidi-font-family: 仿宋; mso-font-kerning: 0pt;">1.</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 仿宋; mso-bidi-font-family: 仿宋; mso-font-kerning: 0pt;">符合《运作规定》合格投资者的要求,向管理人或者销售机构提供的有关投资目的、投资偏好、投资限制、财产收入情况和风险承受能力等基本情况真实、完整、准确、合法,不存在任何虚假记载、误导性陈述或者重大遗漏。前述信息资料如发生任何实质性变更,及时书面告知管理人或者销售机构。</span></p>
  <p class="MsoNormal" style="text-indent: 24.0pt; mso-char-indent-count: 2.0; line-height: 150%;"><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: 仿宋; mso-bidi-font-family: 仿宋; mso-font-kerning: 0pt;">2.</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 仿宋; mso-bidi-font-family: 仿宋; mso-font-kerning: 0pt;">投资者承诺以真实身份和自有资金参与集合计划,财产的来源以及用途符合国家有关规定,未使用贷款、发行债券等筹集的非自有资金投资资产管理计划,且投资事项符合法律、行政法规的规定以及业务决策程序的要求。投资者承诺,如投资资金为资产管理产品募集的资金时,将确保资产管理产品的投资者中不包含其他资产管理产品。如投资资金为除公募资产管理产品外的合伙企业、契约等非法人形式,最终投资者满足法律、行政法规、监管规则规定的合格投资者要求,并向管理人充分披露实际投资者和最终资金来源,保证所提供文件真实、准确、完整、合法。</span></p>
  <p class="MsoNormal" style="text-indent: 24.1pt; mso-char-indent-count: 2.0; line-height: 150%;"><strong style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-size: 12.0pt; mso-bidi-font-size: 11.0pt; line-height: 150%; font-family: 仿宋; mso-bidi-font-family: 仿宋; mso-font-kerning: 0pt;">3.</span></strong><strong style="mso-bidi-font-weight: normal;"><span style="font-size: 12.0pt; mso-bidi-font-size: 11.0pt; line-height: 150%; font-family: 仿宋; mso-bidi-font-family: 仿宋; mso-font-kerning: 0pt;">已充分理解本合同条款,了解相关权利义务,了解有关法律、行政法规以及所投资资产管理计划的风险收益特征,知晓管理人、托管人以及相关机构不应对资产管理计划的收益状况或本金不受损失作出任何承诺,了解“卖者尽责,买者自负”的原则,投资于本计划将自行承担投资风险。</span></strong></p>
  <p class="MsoNormal" style="text-indent: 24.1pt; line-height: 150%;"><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: 仿宋; mso-bidi-font-family: 仿宋; mso-font-kerning: 0pt;">4.</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 仿宋; mso-bidi-font-family: 仿宋; mso-font-kerning: 0pt;">投资者已知晓并理解《个人信息保护法》第十七条规定的事项及个人在个人信息处理活动中的各项权利。</span></p>
  <p class="MsoNormal" style="text-indent: 24.1pt; line-height: 150%;"><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: 仿宋; mso-bidi-font-family: 仿宋; mso-font-kerning: 0pt;">5.</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 仿宋; mso-bidi-font-family: 仿宋; mso-font-kerning: 0pt;">投资者已充分知晓并同意管理人基于监管要求或为客户提供产品及服务需要处理个人信息。</span></p>
  <p class="MsoNormal" style="text-indent: 24.1pt; line-height: 150%;"><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: 仿宋; mso-bidi-font-family: 仿宋; mso-font-kerning: 0pt;">6.</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 仿宋; mso-bidi-font-family: 仿宋; mso-font-kerning: 0pt;">如由投资者提供第三方个人信息的,投资者承诺其提供的信息真实、准确、完整,并已取得相关信息主体的同意。</span></p>
  <p class="MsoNormal" style="text-indent: 24.1pt; line-height: 150%;"><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: 仿宋; mso-bidi-font-family: 仿宋; mso-font-kerning: 0pt;">7.</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 仿宋; mso-bidi-font-family: 仿宋; mso-font-kerning: 0pt;">投资者已了解尽管管理人已采取各项措施保障投资者个人信息安全,但仍有可能存在个人信息泄露、篡改、丢失的风险,并愿意承担相关风险及损失。</span></p>
  <p class="MsoNormal" style="text-indent: 24.0pt; mso-char-indent-count: 2.0; line-height: 150%;"><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: 仿宋; mso-bidi-font-family: 仿宋; mso-font-kerning: 0pt;">8.</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 仿宋; mso-bidi-font-family: 仿宋; mso-font-kerning: 0pt;">知悉并遵守《中华人民共和国反洗钱法》《金融机构客户身份识别和客户身份资料及交易记录保存管理办法》《金融机构大额交易和可疑交易报告管理办法》等反洗钱相关法律、行政法规的规定,用于证券投资的资金来源不属于违法犯罪所得及收益,用于证券投资的资金来源和去向不涉及洗钱、恐怖融资和逃税等违法犯罪行为;声明出示真实有效的身份证件或其他身份证明文件,提供真实有效的业务性质与股权或者控制权结构、受益所有人信息等资料,积极履行反洗钱职责,不借助本计划开展洗钱等违法犯罪活动。<strong>投资者知悉并同意,为积极配合履行非居民金融账户涉税信息尽职调查、反洗钱、反恐怖融资工作,管理人有权将其取得的投资者个人信息及受益所有人信息等资料,提供予托管人,用于非居民金融账户涉税信息尽职调查、反洗钱、反恐怖融资工作的开展。</strong></span></p>
 </body>
</html>

@ssj123ssj Thank you for additional information. But could you please also provide your code, current and expected output documents? We will check the scenario on our side and provide you more information.

This is my code, it simply reads HTML to generate a document:

List<ContractTempParaDTO> paras = new ArrayList<>();
    Document doc = new Document();
    DocumentBuilder builder = new DocumentBuilder(doc);
    paras.forEach(p -> {
      try {
        if (StrUtil.isBlank(p.getParaContent())) {
          return;
        }
        builder.insertHtml(p.getParaContent());
      } catch (Exception e) {
        log.error("文档生成异常");
      }
    });

@ssj123ssj Thank you for additional information. In your HTML numbering in paragraphs is not applied as list numbering. It is represented with simple text so numbers are not updated after adding or deleting items. This is an expected behavior.

Thanks. How could I write list numbering in my html.

@ssj123ssj You can use standard HTML tags <ol> to define numbered list and <li> to define list item. But I would suggest to insert the list as a whole instead of insertion list item one by one.