Command Line Interface

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 →

Installing the groupdocs-merger-net package also puts a groupdocs-merger command on your PATH. It runs the Python API for the jobs where a script is more than you need: shell pipelines, Make rules, CI steps and one-off tasks. The command arrived with version 26.12.

Prerequisites

The command ships inside the package, so nothing else needs installing. Install groupdocs-merger-net as described in Installation, then check that the command is available:

groupdocs-merger --version
groupdocs-merger 26.12.0
Note
If the shell does not find groupdocs-merger, the package’s script folder is not on your PATH. python -m groupdocs.merger runs the same command, for example python -m groupdocs.merger --version.

Sample files

The examples on this page use these sample files. Download them into one folder and run the commands from there:

Commands

The command has four subcommands. Run groupdocs-merger --help for the full list of options, or groupdocs-merger <command> --help for one subcommand. Page lists count from 1: 1,3,5-7 lists pages, and 5- runs to the last page.

merge

Join two or more documents in the order given. The result keeps the format of the first document, so the output file takes its extension.

groupdocs-merger merge north-pier-report.pdf cold-store-audit.pdf -o north-pier.pdf

north-pier.pdf holds the three pages of the report followed by the two pages of the audit. The command prints the path of the file it wrote.

These options tune the join for a format:

OptionApplies toEffect
--image-layout vertical|horizontalImagesStack the images (the default) or place them side by side.
--word-mode default|continuous|disable-section-breaksWord documentsStart each document on a new page (the default), continue on the same page, or drop the section breaks.
--sheet-mode worksheets|rowsSpreadsheetsAdd the worksheets of each workbook (the default), or append its rows below the existing data.
--skip-rows NSpreadsheets, with --sheet-mode rowsSkip the first N rows of each joined workbook, such as its header row.
--password PASSWORDAny formatThe password of the first document, if it is protected.
# Append February's orders below January's, without February's header row
groupdocs-merger merge ledger-2026-01.xlsx ledger-2026-02.xlsx -o ledger-2026.xlsx --sheet-mode rows --skip-rows 1

# Place two pictures side by side
groupdocs-merger merge photo-card-1.png photo-card-2.png -o photo-cards.png --image-layout horizontal

ledger-2026.xlsx has one worksheet: the header row and the 24 orders of both months. photo-cards.png is 1200 × 405 pixels, the two pictures side by side.

split

Split a document into several files in a folder, which is created if it is missing. --pages writes one file per listed page, and --at starts a new file at each listed page.

# Three files: pages 1-2, pages 3-5, and page 6 to the end
groupdocs-merger split board-pack.pdf -o parts --at 3,6

# One file per page, named page-1.pdf to page-6.pdf
groupdocs-merger split board-pack.pdf -o pages --pages 1- --name page-{0}.pdf

The first command writes board-pack_0.pdf (pages 1 and 2), board-pack_1.pdf (pages 3 to 5) and board-pack_2.pdf (page 6) into the parts folder. The command prints the path of each file it wrote, and the number of files to standard error.

OptionEffect
--pages LISTOne file per listed page.
--at LISTA new file starts at each listed page: 3,6 gives pages 1-2, 3-5 and 6 to the end.
--name PATTERNThe names of the files. {0} stands for the page number with --pages, and for the part’s index, counted from 0, with --at. The default is the input’s name followed by _{0} and its extension.
--odd, --evenOnly the odd or the even pages of the list.
--password PASSWORDThe password of the document, if it is protected.

A text file is split by lines: the lists then give line numbers, and {0} is the part’s index, counted from 0.

extract

Keep only the listed pages:

groupdocs-merger extract board-pack.pdf -o board-pack-2-4.pdf --pages 2-4

board-pack-2-4.pdf holds pages 2, 3 and 4. The options are --odd, --even and --password.

remove

Drop the listed pages:

# Remove the even pages: pages 1, 3 and 5 are left
groupdocs-merger remove board-pack.pdf -o board-pack-odd.pdf --pages 1- --even

The options are --odd, --even and --password. A list that would remove every page is refused.

Protected documents

--password opens a protected document:

groupdocs-merger extract budget-2027-pss.pdf -o budget-summary.pdf --pages 1 --password p@ss

budget-summary.pdf holds page 1 and opens without a password. Without --password, the command stops with exit code 1 and suggests passing one.

License

--license SOURCE applies a license file, or the URL of one, before the subcommand runs. Place it before the subcommand’s name:

groupdocs-merger --license GroupDocs.Merger.lic merge north-pier-report.pdf cold-store-audit.pdf -o north-pier.pdf

The command also reads the GROUPDOCS_LIC_PATH environment variable, as the Python API does, so with the variable set you can omit --license. See Licensing and Evaluation for both. Without a license, the command runs in evaluation mode: a result holds at most three pages and carries an evaluation notice. A license that cannot be read or applied stops the command with exit code 1 and a message that says why.

Exit codes

CodeMeaning
0Success.
2A mistake in the command line, such as a missing input file, a page past the end of the document, or an output extension that differs from the input’s. Nothing is written.
1The document or the license could not be processed. The reason is printed to standard error.

These codes make the command easy to branch on in shell scripts and CI pipelines.

When to use the Python API instead

The command joins and splits files on disk. For anything beyond that, use the Python API: streams and in-memory documents, page previews, document information, adding, changing and removing passwords, moving, swapping and rotating pages, and importing documents as OLE objects or attachments. See the Developer Guide for runnable examples of each.

Next steps