Skip to content

Instantly share code, notes, and snippets.

@conholdate-gists
Created June 17, 2021 10:25
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 conholdate-gists/9d404af999079633a15bc719fca77557 to your computer and use it in GitHub Desktop.
Save conholdate-gists/9d404af999079633a15bc719fca77557 to your computer and use it in GitHub Desktop.
Merge Word Documents using Java
Merge Word Documents using Java
1. Java API for Merging Word Documents
2. Merge Word Documents using Java
3. Combine Specific Pages of Word Documents using Java
4. Merge and Secure with Password using Java
5. Merge Word Document into PDF using Java
// Initialize API
Merger merger = new Merger("C:\\Files\\merger\\sample.docx");
// Define join options
JoinOptions joinOptions = new JoinOptions(1, 2);
// Merge
merger.join("C:\\Files\\merger\\sample2.docx", joinOptions);
// Save the merged file
merger.save("C:\\Files\\merger\\output.docx");
// Initialize API
Merger merger = new Merger("C:\\Files\\sample.docx");
// Merge files
merger.join("C:\\Files\\sample2.docx");
merger.join("C:\\Files\\sample3.docx");
// Set Password
AddPasswordOptions addOptions = new AddPasswordOptions("password");
merger.addPassword(addOptions);
// Save the merged file
merger.save("C:\\Files\\output.docx");
// Initialize API
Merger merger = new Merger("C:\\Files\\sample.docx");
// Merge files
merger.join("C:\\Files\\sample2.docx");
merger.join("C:\\Files\\sample3.docx");
// Save the merged file
merger.save("C:\\Files\\output.docx");
// Initialize API
Merger merger = new Merger("C:\\Files\\sample.pdf");
// Merge files
merger.join("C:\\Files\\sample.docx");
// Save the merged file
merger.save("C:\\Files\\output.pdf");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment