White space in section


#1

We’re using aspose to handle different templates, when we do the documents Marge in the continuous section, aspose adds a blank space that doesn’t come with the original version but it’s added by aspose.
This space gets bigger if I select “document.getFirstSection (). GetHeadersFooters (). LinkToPrevious (false);”
I show you a word image, the right side is as it should look, and the left side is how it looks when saved with aspose.

I do not know if the error will be due to the style of the section or if some property should be added to the section so that it does not add that blank space.Annotation 2019-11-06 212625.png (7.3 KB)


#2

@angelmd

The HeaderFooterCollection.LinkToPrevious method links or unlinks all headers and footers to the corresponding headers and footers in the previous section. So, the behaviour can be expected. You can check this behaivor using MS Word.

If you still face problem, please attach the following resources here for testing:

  • Your input Word document.
  • Please attach the output Word file that shows the undesired behavior.
  • Please attach the expected output Word file that shows the desired behavior.
  • Please create a standalone console application ( source code without compilation errors ) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.


#3

Hi, thank you for your answer.

I’m attaching the documents, the problem is at second page, as you could see in the wrong document (OUTPUT_WITH_ERROR_AFTER_MERGE) above this words"Asdsds: CONSEQUAT CONSEQUAT CONSEQUAT" it has a space that doesn’t come in the original template (TMPL_2) and it causes an extra blank page.

The expected document should only have 2 pages, but at the time of saving aspose is generating 3 pages. Aspose.zip (306.6 KB)

Snipe Code:

public static void mergeDocx(File[] mergeFile, String savePath) throws Exception {
Document document = new Document(mergeFile[0].getAbsolutePath());
for (int i = 1; i < mergeFile.length; i++) {
Document append = new Document(mergeFile[i].getAbsolutePath());
append.getFirstSection().getHeadersFooters().linkToPrevious(false);
document.appendDocument(append, ImportFormatMode.KEEP_SOURCE_FORMATTING);
}
document.getFieldOptions().setFieldUpdateCultureSource(FieldUpdateCultureSource.FIELD_CODE);
document.save(savePath);
}


#4

@angelmd

Please note that Aspose.Words mimics the behavior of MS Word. If you copy the content of TMPL_2.docx after inserting section break in TMPL_1.docx, you will get the same output.

In your case, we suggest you please set the font size of paragraph to 1 that contains the column break using Paragraph.ParagraphBreakFont property. Hope this helps you.