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

This is use a template to create document, if I create doc use html, how I can do it

@ssj123ssj Could you please provide you input, data and expected output here for our reference? Unfortunately, your requirements are not clear enough.

This is my html content, I want to fill my List data to the table but not use template;

<p style="text-indent: 2em;">表格测试1表格测试1表格测试</p>
<!-- pagebreak -->
<p style="text-indent: 2em;">首行缩进测试111</p>
<table style="border-collapse: collapse; width: 85.3503%; height: 42.4242px;" border="1"><colgroup><col style="width: 45.7566%;"><col style="width: 54.1691%;"></colgroup>
<tbody>
<tr style="height: 21.2121px;">
<td style="height: 21.2121px;">名称</td>
<td style="height: 21.2121px;">编码</td>
</tr>
<tr style="height: 21.2121px;">
<td style="height: 21.2121px;"><span class="ct-mergetag" contenteditable="false"><span data-tagid="QanndpmQ8rrGvVP1:product_name">名称1-名称</span></span></td>
<td style="height: 21.2121px;"><span class="ct-mergetag" contenteditable="false"><span data-tagid="QanndpmQ8rrGvVP1:product_code">名称1-编码</span></span></td>
</tr>
</tbody>
</table>
<p style="text-indent: 2em;">测试表格</p>

@ssj123ssj I am afraid your requirements are still not clear enough. Do you want to add additional rows into the table inserted from HTML? If so, you can get the appropriate Table node, clone the last row and add the cloned row to the table. Alternatively you can add rows into your HTML and then insert it into the word document using Aspose.Words.

I want to know how to set the header horizontal line use Paragraph.
It like this picture:

@ssj123ssj You can use paragraph bottom border to achieve this:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.moveToHeaderFooter(HeaderFooterType.HEADER_PRIMARY);
builder.getParagraphFormat().setAlignment(ParagraphAlignment.CENTER);
Border bottom = builder.getParagraphFormat().getBorders().getByBorderType(BorderType.BOTTOM);
bottom.setLineStyle(LineStyle.SINGLE);
bottom.setLineWidth(1);
bottom.setColor(Color.BLACK);
builder.write("This is header with the line");
doc.save("C:\\Temp\\out.docx");

It’s okay, thank you

1 Like

Hello, I would like to use Aspose How can I compare two documents using Words for Java and specify the dimensions for comparison while configuring to ignore some formatting changes

@ssj123ssj Yes, you can compare documents using Aspose.Words. Please see our documentation for more information about document comparison feature:
https://docs.aspose.com/words/java/compare-documents/

Aspose.Words document comparison feature works similar to MS Word, i.e. the dirrerences are marked as revisions in the output document.

Section section = document.getFirstSection();
HeaderFooter headerFooter = new HeaderFooter(document, HeaderFooterType.HEADER_FIRST);
section.getHeadersFooters().add(headerFooter);
HeaderFooter header = new HeaderFooter(document, HeaderFooterType.HEADER_PRIMARY);
section.getHeadersFooters().add(header);
header.appendParagraph("首页之后的页眉");

Can you help me?.
this is my code , How can I control the homepage not to generate a header?

@ssj123ssj You should set PageSetup.DifferentFirstPageHeaderFooter.