Learn how to copy content from one Word document to another in Java: https://blog.aspose.com/2021/10/01/copy-content-from-a-word-document-to-another-in-java/
Last active
December 7, 2021 14:43
-
-
Save aspose-com-gists/1c06147b9bd1212e71bfc8b6ec0ef4b8 to your computer and use it in GitHub Desktop.
Copy Content from One Word Document to Another in Java
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 the Word document | |
Document doc = new Document("document.docx"); | |
// Clone document | |
Document newDoc= doc.deepClone(); | |
// Save document | |
newDoc.save("output.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 source and destination Word documents | |
Document doc = new Document("document.docx"); | |
Document docDest = new Document("document2.docx"); | |
// Copy the content from source document to destination document | |
docDest.appendDocument(doc, ImportFormatMode.KEEP_SOURCE_FORMATTING); | |
// Save document | |
docDest.save("output.docx"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment