We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Issue with Import Format while merging two docx files

Hello,

I have one source and destination docx files. Using builder.insertDocument method I am merging these two docx files. I have Template file as a destination file where I set the font to Ariel, Font size to 11 and style as Normal. I have source file named RTE_BP2S_Update_ActionRequired_ContentData.docx which has some rich text which contains bullet points and other content.
If I use ImportFormatMode.KEEP_SOURCE_FORMATTING in insertDocumnet method then keep the source doc file as it is ( which is as per behavior).
If I use ImportFormatMode.USE_DESTINATION_STYLES in insertDocumnet method then it converting some other format ( change the font and font size, also the font for content and bullet point is different). As my destination docx has Ariel font and 11 size then it should display the final docx in same style however it’s not showing.
I have shared the expected output, destination File, source file and two output files which I get after using above two different format. could you please check why I am getting this behavior and what changes I have to make to get the expected output ( I have to use the format as USE_DESTINATION_STYLES so could you please suggest solution accordingly).
Regarding the code there is only one line of code to merge the doc files i.e. builder.insertDocument(doc, ImportFormatMode.USE_DESTINATION_STYLES);

Note-I am using ReplaceHandler to insert final documents.

@vke3

Thanks for your inquiry. Please create a simple Java application ( source code without compilation errors ) that helps us to reproduce your problem on our end and attach it here for testing. We will investigate the issue on our side and provide you more information.

Thanks for your cooperation.

@tahir.manzoor,

Please find the attachment for your reference.

Summary

Files.zip (317.3 KB)

@vke3

Thanks for sharing the detail. You are facing the expected behavior of Aspose.Words. Please note that Aspose.Words mimics the behavior of MS Word. If you copy the content of source document into destination document using MS Word, you will get the same output.

To get the desired output, we suggest you following solution.

  1. Please get the font formatting of your desired text e.g. ${file:RTE_BP2S_Update_ActionRequired_ContentData.docx}
  2. Iterate over the Paragraph and Run nodes of source document and set their font formatting according to desired text.
  3. Insert the document into Destination_File.docx.