Skip to content

Instantly share code, notes, and snippets.

@GroupDocsGists
Last active May 4, 2021 19:02
Show Gist options
  • Save GroupDocsGists/a5fbd8bfba0cfddd998cd60a3089e584 to your computer and use it in GitHub Desktop.
Save GroupDocsGists/a5fbd8bfba0cfddd998cd60a3089e584 to your computer and use it in GitHub Desktop.
Merge two or more difference types of files into one file in C# using .NET API
// Combine two or more different types of files into one using C#
using (Merger merger = new Merger("document.pdf"))
{
merger.Join("document.docx");
merger.Join("spreadsheet.xlsx");
merger.Save("merge_document.pdf");
}
// Combine selective pages of two or more different types of files into one using C#
using (Merger merger = new Merger("document.pdf"))
{
// Merge first page of DOCX file
JoinOptions joinOptions = new JoinOptions(new int[] {1});
merger.Join("document.docx", joinOptions);
// Merge all the even pages/sheets of the spreadsheet from the provided range
joinOptions = new JoinOptions(1,2, RangeMode.EvenPages);
merger.Join("spreadsheet.xlsx", joinOptions);
merger.Save("merge_document.pdf");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment