Hi,
I am using aspose-words-18.5-jdk16 api for java.
I am converting docx to xml. and again xml to docx (i.e docx -> xml -> docx). But last section of Resulting docx is not appending properly, it is taking extra space in paragraphs.
I have attached source and output docx, please check their last sections.
Source and Output doc.zip (1.2 MB)
Project.zip (7.4 MB)
Thanks.
@ngshinde999,
In Document.appendDocument method, please change ImportFormatMode.USE_DESTINATION_STYLES parameter to as shown below:
dstDoc.appendDocument(srcDoc, ImportFormatMode.KEEP_SOURCE_FORMATTING);
Hope, this helps.
In our case If I use ImportFormatMode.KEEP_SOURCE_FORMATTING, then it does not maintain Section style .
i.e. Heading 1, Heading 2.
If you run the given project and check output, you will see the difference.
@ngshinde999,
You can try copying Styles from source document into destination document by using StyleCollection.AddCopy Method.
Hi,
Thanks for reply,
I checked using above method, it is not working. It does not copy “Heading 1” style to destination docx.
@ngshinde999,
In that case, please change ImportFormatMode.USE_DESTINATION_STYLES parameter to as shown below:
dstDoc.appendDocument(srcDoc, ImportFormatMode.KEEP_DIFFERENT_STYLES);
The styles will be imported with name Heading 1_0 and Heading 2_0.