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

Could you help me take a look at this issue, how to delete the blank page like this:

@ssj123ssj Word documents are not fixed page formats, they are flow, more like HTML. So, there is no easy way to determine where page starts or ends and no easy way to determine whether some particular page is blank. However, there are few options to set an explicit page break in Word document. For example,

If you delete such explicit page breaks from your document, this might help you to get rid blank pages.

Additionally, you can try using Document.removeBlankPages method.

thanks, After each chapter in my document, page breaks are used for pagination,
I have many page breaks in my document, how can I confirm to delete the page break for this blank page

@ssj123ssj Have you tried using Document.removeBlankPages method.

I can’t find Document.removeBlankPages method in my code.

@ssj123ssj Most likely you are using an old version of Aspose.Words. Document.removeBlankPages method has been introduced in 24.5 version of Aspose.Words.

yes , My Aspose.Words version is 24.3

1 Like

Hello, can you help me take a look at this issue. I have generated a Word document with a table, and I have a List<>data. I want to load the data from this list into the back of this table. Is this possible.

@ssj123ssj Do you mean fill the table with data? If so you can easily achieve this using Mail Merge with Regions or LINQ Reporting Engine.

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.