Skip to content

Instantly share code, notes, and snippets.

@GroupDocsGists
Last active June 8, 2023 08:21
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 GroupDocsGists/176f95f46fef1fa8c7c444d665d859b8 to your computer and use it in GitHub Desktop.
Save GroupDocsGists/176f95f46fef1fa8c7c444d665d859b8 to your computer and use it in GitHub Desktop.
Merge Word Documents using C#
// Merge Selective Pages of Word Documents using C#
using (Merger merger = new Merger("source_document.docx"))
{
// Set the merging options
JoinOptions joinOptions = new JoinOptions(2,3); // Specify the starting and ending page number
// Merge the documents
merger.Join("document_to_merge.docx", joinOptions); // using joining settings
merger.Join("another_document_to_merge.docx", new JoinOptions(new[] { 2, 4, 6 })); // Specifying page number(s)
merger.Save("output_document.docx"); // Saving merged document
}
// Merge Two Word Documents using C#
Merger merger = new Merger("source_document.docx"); // Load the source document
merger.Join("document_to_merge.docx"); // Merge the document
merger.Join("another_document_to_merge.docx"); // Merge additional documents
merger.Save("output_document.docx"); // Save the merged document as output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment