Last active
September 10, 2020 15:52
-
-
Save aspose-com-gists/0e5aba636419098aef07e054cbd08d77 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Load Word documents to be merged | |
Document doc1 = new Document("sample1.docx"); | |
Document doc2 = new Document("sample4.docx"); | |
// Set options | |
ImportFormatOptions options = new ImportFormatOptions(); | |
options.setIgnoreHeaderFooter(true); | |
//options.setIgnoreTextBoxes(true); | |
//options.setKeepSourceNumbering(true); | |
//options.setSmartStyleBehavior(true); | |
// Merge documents keeping destination file's styles | |
doc1.appendDocument(doc2, ImportFormatMode.USE_DESTINATION_STYLES, options); | |
// Save merged document as DOCX file | |
doc1.save("merged-customized.docx", SaveFormat.DOCX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Load Word documents to be merged | |
Document doc1 = new Document("sample1.docx"); | |
Document doc2 = new Document("sample4.docx"); | |
// Merge documents keeping source file's formatting | |
doc1.appendDocument(doc2, ImportFormatMode.KEEP_SOURCE_FORMATTING); | |
// Save merged document as DOCX file | |
doc1.save("merged.docx", SaveFormat.DOCX); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment