Hello, World!

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Merger MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-merger -- dnx GroupDocs.Merger.Mcp --yes
Folders, licensing and more →

Introduction

A “Hello, World!” example is often the first step when exploring GroupDocs.Merger for Python via .NET. It serves as a simple test to confirm that your development environment is correctly set up and that the library is functioning as expected.

Overview

GroupDocs.Merger for Python via .NET joins documents into one, splits them, and extracts, removes, moves and rotates their pages. A wide range of supported formats makes it versatile for different use cases.

How to merge two documents

The following steps demonstrate how to merge two PDF documents using GroupDocs.Merger for Python via .NET:

  1. Import the Merger class from groupdocs.merger.
  2. Open a Merger with the path to the first document.
  3. Append the second document with join().
  4. Save the result with save().

Complete example

The example below appends one PDF document to another and saves both as a single PDF:

from groupdocs.merger import Merger

def hello_world():
    # Open the first document, append the second one, and save the result
    with Merger("./input.pdf") as merger:
        merger.join("./input2.pdf")
        merger.save("./output.pdf")

    print("Documents merged successfully. Output saved to ./output.pdf.")

if __name__ == "__main__":
    hello_world()

input.pdf is a sample file used in this example. Click here to download it.

input2.pdf is a sample file used in this example. Click here to download it.

Binary file (PDF, 602 KB)

Download full output

The result keeps the format of the first document: output.pdf holds the three pages of input.pdf followed by the two pages of input2.pdf. Without a license, GroupDocs.Merger runs in evaluation mode, so the result holds the first three pages only and carries an evaluation notice: see Licensing and Evaluation.

The same three calls merge Word documents, spreadsheets, presentations, images and other formats: Merge files has an example for each, with the options each format takes.

Additional resources

This demo references the GroupDocs.Merger for Python via .NET code samples.