Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active December 7, 2021 14:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/1c06147b9bd1212e71bfc8b6ec0ef4b8 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/1c06147b9bd1212e71bfc8b6ec0ef4b8 to your computer and use it in GitHub Desktop.
Copy Content from One Word Document to Another in Java
// Load the Word document
Document doc = new Document("document.docx");
// Clone document
Document newDoc= doc.deepClone();
// Save document
newDoc.save("output.docx");
// 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