I’m trying to insert source document into destination document using document builder object with ImportFormatMode.USE_DESTINATION_STYLES
option. (See following code snippet)
public static void main(String[] args) throws Exception {
Document destDoc = new Document("/home/cipet/Downloads/destDoc.docx");
Document srcDoc = new Document("/home/cipet/Downloads/srcDoc.docx");
DocumentBuilder documentBuilder = new DocumentBuilder(destDoc);
documentBuilder.insertDocument(srcDoc, ImportFormatMode.USE_DESTINATION_STYLES);
documentBuilder.getDocument().save("/home/cipet/Downloads/final.docx");
}
But the final document is not generating with expected output. Please let me know what could be the solution to generate final document by using destination document style.
For more details, I've attached source, destination and expected output in the aspose forum https://forum.aspose.com/t/insertdocument-with-use-destination-styles-not-working/227548
Thanks
When you use ImportFormatmode.USE_DESTINATION_STYLES the styles present in the destination document are used. For example if in your source document you have paragraph with Heading1 style, after inserting it into the destination document Heading1 style from destination document will be used.
It is not actually clear what is your expected output, so I would suggest you to ask the question in the corresponding forum and attach your source, destination, output and expected output documents.