Metadata-Version: 2.4
Name: groupdocs-merger-net
Version: 26.12.0
Summary: GroupDocs.Merger for Python via .NET - Merge, split, reorder and manipulate document pages
Author-email: GroupDocs <support@groupdocs.com>
License-Expression: LicenseRef-Proprietary
Project-URL: Homepage, https://products.groupdocs.com/merger/python-net/
Project-URL: Documentation, https://docs.groupdocs.com/merger/python-net/
Keywords: merger,merge,split,join,combine,document,pdf,docx,pages,groupdocs,dotnet
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: Unix
Classifier: Operating System :: MacOS
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Utilities
Requires-Python: <3.15,>=3.5
Description-Content-Type: text/markdown
Requires-Dist: groupdocs-shared-net>=26.11.0

[![banner](https://raw.githubusercontent.com/groupdocs/groupdocs.github.io/master/img/banners/groupdocs-merger-python-net-banner.png)](https://docs.groupdocs.com/merger/python-net/)

[![PyPI](https://img.shields.io/pypi/v/groupdocs-merger-net)](https://pypi.org/project/groupdocs-merger-net/) [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/groupdocs-merger-net)](https://pypi.org/project/groupdocs-merger-net/)

[Product Page](https://products.groupdocs.com/merger/python-net/) | [Docs](https://docs.groupdocs.com/merger/python-net/) | [Demos](https://products.groupdocs.app/merger/family) | [API Reference](https://reference.groupdocs.com/merger/python-net/) | [Blog](https://blog.groupdocs.com/category/merger/) | [Free Support](https://forum.groupdocs.com/c/merger) | [Temporary License](https://purchase.groupdocs.com/temporary-license)

GroupDocs.Merger for Python via .NET is a document-manipulation API for combining and reorganizing documents. Join files into one, split a document into several, and extract, remove, move, swap or rotate pages in Word, Excel, PowerPoint, PDF, Visio, OneNote, OpenDocument, eBook, web, image, text and archive formats, through one API and with no Microsoft Office or other software installed. It also adds and removes passwords, changes page orientation, renders page previews to files or memory, and its `groupdocs-merger` command joins and splits documents from the shell.

## Get Started

```bash
pip install groupdocs-merger-net
```

```python
from groupdocs.merger import Merger

with Merger("report.docx") as merger:
    merger.join("appendix.docx")
    merger.save("combined.docx")
```

Or from the command line:

```bash
groupdocs-merger merge report.pdf appendix.pdf -o combined.pdf
```

## How It Works

The package is a self-contained Python wheel (about 150 MB on Windows, 165 MB on Linux and macOS) that bundles the .NET 10 runtime and everything else needed to load, change and save documents. No external software installation is required — just `pip install` and start merging; pip also installs `groupdocs-shared-net`, the small package of modules every GroupDocs Python package shares. For an offline install, download both wheels and install them together: `pip install --no-index --find-links <folder> groupdocs-merger-net`. The wheel works across Python 3.5 – 3.14 on Windows, Linux, and macOS (Intel + Apple Silicon).

## Features

- **Join**: combine whole documents or page ranges. Word documents can start on a new page or run on, spreadsheets can add their worksheets or append their rows below the data, images can be stacked or placed side by side, and documents of different formats can be joined into one PDF.
- **Split**: one file per page, or a new file at each listed page; text files split by lines.
- **Page management**: extract, remove, move, swap and rotate pages, change page orientation, and pick the odd or even pages of a range.
- **Passwords**: add, change or remove a document's password, and open protected documents.
- **Document information**: format, page count, size and the size of each page.
- **Page previews**: render pages to PNG, JPEG or BMP, into files or into memory (`io.BytesIO`).
- **Command line**: `groupdocs-merger` merges, splits, extracts and removes pages without writing code.
- **Safe with untrusted documents**: images and other resources a document links to are not loaded unless you allow them.
- **Cross-Platform**: Windows x64, Linux x64, macOS x64/ARM64.

## Common Tasks

- Merge PDFs, Word documents, spreadsheets or presentations into one file
- Combine monthly spreadsheets into one sheet, keeping a single header row
- Split a document into one file per page, or into sections at given pages
- Keep only the pages you need, or remove the ones you don't
- Reorder, rotate or swap pages
- Protect a document with a password, or remove one
- Render page thumbnails for a document preview in a web application
- Merge or split documents in a shell script or a CI job

## Supported File Formats

For the operations available for each format, see [supported formats](https://docs.groupdocs.com/merger/python-net/getting-started/supported-document-formats/).

| Category | Formats |
|---|---|
| **Word Processing** | DOC, DOCX, DOCM, DOT, DOTX, DOTM, ODT, OTT, RTF, TXT |
| **Spreadsheets** | XLS, XLSX, XLSM, XLSB, XLT, XLTX, XLTM, XLAM, ODS, CSV, TSV |
| **Presentations** | PPT, PPTX, PPTM, PPS, PPSX, PPSM, POTX, POTM, ODP, OTP |
| **Fixed-Layout** | PDF, XPS, TEX |
| **Visio Diagrams** | VSD, VSDX, VSDM, VSS, VSSX, VSSM, VST, VSTX, VSTM, VDX, VSX, VTX |
| **Note-taking** | ONE |
| **eBooks & Web** | EPUB, HTML, MHT, MHTML |
| **Images** | BMP, JPG, JPEG, PNG, GIF, TIF, TIFF, SVG, SVGZ, EMF, EMZ |
| **Archives & Audio** (join) | ZIP, TAR, 7Z, MP3, WAV |

## Platform & Format Support

| Format family | Windows | Linux / macOS |
|---|:---:|:---:|
| OneNote (ONE) | Yes | With `libgdiplus` installed |
| Presentations (PPTX, PPT, PPS, POT*, ODP, OTP) | Yes | Yes; on Linux with fontconfig (`libfontconfig1`) |
| All other formats | Yes | Yes |

Windows wheels run the Windows build of the engine (`GroupDocs.Merger.Net100.Windows`); Linux and macOS wheels run its cross-platform build (`GroupDocs.Merger.Net100`), which does everything without `libgdiplus` except open OneNote documents. To work with OneNote on Linux or macOS, install it: `apt-get install libgdiplus`, or `brew install mono-libgdiplus`.

## Examples

### Merge documents

```python
from groupdocs.merger import Merger

with Merger("january.pdf") as merger:
    merger.join("february.pdf")
    merger.join("march.pdf")
    merger.save("first-quarter.pdf")
```

### Append spreadsheet rows below the data

```python
from groupdocs.merger import Merger
from groupdocs.merger.domain.options import SpreadsheetJoinMode, SpreadsheetJoinOptions

options = SpreadsheetJoinOptions()
options.mode = SpreadsheetJoinMode.ROWS   # instead of adding the worksheets
options.skip_rows = 1                     # each joined workbook's header row

with Merger("sales-january.xlsx") as merger:
    merger.join("sales-february.xlsx", options)
    merger.save("sales.xlsx")
```

### Get document info

```python
from groupdocs.merger import Merger

with Merger("document.pdf") as merger:
    info = merger.get_document_info()
    print("Type:", info.type.file_format)
    print("Pages:", info.page_count)
    print("Size:", info.size, "bytes")
    for page in info.pages:
        print("  page", page.number, ":", page.width, "x", page.height)
```

### Split a document

```python
from groupdocs.merger import Merger
from groupdocs.merger.domain.options import SplitMode, SplitOptions

with Merger("document.pdf") as merger:
    # one file per page: page_1.pdf, page_2.pdf
    merger.split(SplitOptions("page_{0}.pdf", [1, 2]))

with Merger("document.pdf") as merger:
    # a new file at page 2: part_0.pdf holds page 1, part_1.pdf the rest
    merger.split(SplitOptions("part_{0}.pdf", [2], SplitMode.INTERVAL))
```

`{0}` is the page number with `SplitMode.PAGES`. With `SplitMode.INTERVAL`, and in both modes of
`TextSplitOptions`, it is the part's index, from 0.

### Extract, remove, and reorder pages

```python
from groupdocs.merger import Merger
from groupdocs.merger.domain.options import (
    ExtractOptions, RemoveOptions, RotateMode, RotateOptions, SwapOptions)

with Merger("document.pdf") as merger:
    merger.swap_pages(SwapOptions(1, 2))                      # swap pages 1 and 2
    merger.rotate(RotateOptions(RotateMode.ROTATE90, [2]))    # turn page 2
    merger.save("reordered.pdf")

with Merger("document.pdf") as merger:
    merger.extract_pages(ExtractOptions([1]))                 # keep page 1 only
    merger.save("first-page.pdf")

with Merger("document.pdf") as merger:
    merger.remove_pages(RemoveOptions([1]))                   # drop page 1
    merger.save("without-cover.pdf")
```

### Add a password, and open a protected document

```python
from groupdocs.merger import Merger
from groupdocs.merger.domain.options import AddPasswordOptions, LoadOptions

with Merger("document.pdf") as merger:
    merger.add_password(AddPasswordOptions("secret"))
    merger.save("protected.pdf")

with Merger("protected.pdf", LoadOptions("secret")) as merger:
    print("Pages:", merger.get_document_info().page_count)
```

### Render page previews into memory

```python
import io
from groupdocs.merger import Merger
from groupdocs.merger.domain.options import PreviewMode, PreviewOptions

pages = {}  # page number -> io.BytesIO holding a PNG

def create_page(page_number):
    pages[page_number] = io.BytesIO()
    return pages[page_number]

with Merger("document.pdf") as merger:
    merger.generate_preview(PreviewOptions(create_page, PreviewMode.PNG, [1, 2]))

png = pages[1].getvalue()
```

To write files instead, return `open("page-%d.png" % page_number, "wb")` from `create_page`.

### Merge streams, and save into memory

```python
import io
from groupdocs.merger import Merger

with open("document1.pdf", "rb") as first, open("document2.pdf", "rb") as second:
    with Merger(first) as merger:
        merger.join(second)
        buffer = io.BytesIO()
        merger.save(buffer)

data = buffer.getvalue()
```

### Load the resources a trusted document links to

```python
from groupdocs.merger import Merger
from groupdocs.merger.domain import FileType
from groupdocs.merger.domain.options import LoadOptions

options = LoadOptions(FileType.HTML)
options.skip_external_resources = False   # only for documents you trust

with Merger("page.html", options) as merger:
    merger.join("page.html")
    merger.save("pages.html")
```

`whitelisted_resources` allows only the URL prefixes it lists, each an absolute URI such as `https://cdn.example.com/`. To decide per resource, give `LoadOptions.external_resource_handler` a function or an object with an `on_loading(args)` method: set `args.skipped` to allow or skip `args.uri`, or put the bytes to use in `args.data`. The handler has the last word over both settings.

A relative link (`<img src="photo.png">`) is resolved against the working directory, not the document's folder. Run from the document's folder, or supply the bytes in the handler.

## Merge and Split from the Command Line

The package installs a `groupdocs-merger` command:

```bash
groupdocs-merger merge report.pdf appendix.pdf -o combined.pdf
groupdocs-merger merge sales-1.xlsx sales-2.xlsx -o sales.xlsx --sheet-mode rows --skip-rows 1
groupdocs-merger merge scan-1.png scan-2.png -o scans.png --image-layout horizontal
groupdocs-merger split handbook.pdf -o parts --at 3,6          # pages 1-2, 3-5, 6 to the end
groupdocs-merger split handbook.pdf -o pages --pages 1- --name page-{0}.pdf
groupdocs-merger extract contract.pdf -o pages.pdf --pages 2-4,7
groupdocs-merger remove scan.pdf -o odd.pdf --pages 1- --even
python -m groupdocs.merger --version
```

| Command | What it writes | Options |
|---|---|---|
| `merge INPUT INPUT... -o OUTPUT` | The documents joined in order. The result keeps the first document's format and extension. | `--image-layout vertical\|horizontal`, `--word-mode default\|continuous\|disable-section-breaks`, `--sheet-mode worksheets\|rows`, `--skip-rows N`, `--password` |
| `split INPUT -o FOLDER` | One file per page of `--pages LIST`, or a new file at each page of `--at LIST`. A text file splits by lines. | `--name PATTERN` (`{0}`: the page number with `--pages`, the part's index from 0 with `--at` and for a text file), `--odd`, `--even`, `--password` |
| `extract INPUT -o OUTPUT --pages LIST` | Only the listed pages. | `--odd`, `--even`, `--password` |
| `remove INPUT -o OUTPUT --pages LIST` | The document without the listed pages. | `--odd`, `--even`, `--password` |

Pages count from 1: `1,3,5-7` lists pages, and `5-` runs to the last page. `--license SOURCE` applies a licence file or URL first (`GROUPDOCS_LIC_PATH` also works). A mistake in the command line exits with code 2 and writes nothing, and a document the engine cannot process exits with code 1.

## AI Agent & LLM Friendly

This package is designed for seamless integration with AI agents, LLMs, and automated code generation tools.

- **`AGENTS.md` in the package** -- AI coding assistants (Claude Code, Cursor, GitHub Copilot) auto-discover the API surface, usage patterns, and troubleshooting tips from the installed package
- **MCP server** -- connect your AI tool to GroupDocs documentation for on-demand API lookups:
  ```json
  { "mcpServers": { "groupdocs-docs": { "url": "https://docs.groupdocs.com/mcp" } } }
  ```
- **GroupDocs.Merger MCP server** -- let an agent merge documents and extract pages on your machine, with nothing uploaded: [docs.groupdocs.com/merger/mcp](https://docs.groupdocs.com/merger/mcp/)
- **Machine-readable docs** -- full documentation available as plain text for RAG and LLM context:
  - Single file: `https://docs.groupdocs.com/merger/python-net/llms-full.txt`
  - Per page: append `.md` to any docs URL

## Evaluation Mode

The API works without a license in evaluation mode with the following limitations:
- Only the first three pages of a document are processed: a result holds at most three pages, a split writes at most three parts, previews stop at page 3, and `get_document_info` reports at most three pages.
- Results carry the notice "Created with evaluation version of GroupDocs.Merger": on every page of a PDF and every slide of a presentation, at the start of a Word document, and on an extra "Evaluation Warning" worksheet in a spreadsheet.

To remove these limitations, apply a license or request a [temporary license](https://purchase.groupdocs.com/temporary-license):

```python
from groupdocs.merger import License
License().set_license("path/to/license.lic")
```

Or set the environment variable, which is applied at the first Merger call:
```bash
export GROUPDOCS_LIC_PATH="path/to/license.lic"
```

If that licence cannot be applied (an expired subscription, a licence for another product, a
missing file), every Merger call raises `LicenseError` with the reason until a licence is
applied. Set `GROUPDOCS_LIC_STRICT=0` to run in evaluation mode with a `LicenseWarning` instead.

## Troubleshooting

| Issue | Platform | Fix |
|---|---|---|
| `MissingDependencyException` ("A required component is not available ... Install the native library it needs") opening a OneNote document | Linux/macOS | Install `libgdiplus`: `apt-get install libgdiplus`, or `brew install mono-libgdiplus`. No other format needs it |
| The same `MissingDependencyException` opening a PowerPoint or OpenDocument presentation, naming `libaspose.slides.drawing.capi` | Linux | Install fontconfig: `apt-get install libfontconfig1` |
| `FileCorruptedException` opening an EPUB, or `Value cannot be null. (Parameter 'trueTypeFont')` previewing a Visio diagram | Linux | No font is installed. `apt-get install libfontconfig1` brings DejaVu |
| `Line number should be equal or less than lines count 1` splitting a text file by lines | Windows | A known issue of engine 26.11: on Windows only CRLF line breaks are counted. Convert the file's LF breaks to CRLF first |
| Text parts start with a byte order mark (U+FEFF) and end their lines with CRLF | All | A known issue of engine 26.11: each part is written as UTF-8 with a byte order mark and CRLF line breaks, whatever the input's. Read it with `encoding="utf-8-sig"` |
| A red cross where an HTML or MHT document showed an image | All | The image is an external resource, and those are not loaded by default. For a document you trust, set `skip_external_resources = False` on its `LoadOptions`, list allowed URL prefixes in `whitelisted_resources`, or decide per resource with `external_resource_handler`. A relative link is resolved against the working directory, not the document's folder |
| `IncorrectPasswordException` / `PasswordRequiredException` | All | Open the document with its password: `Merger(path, LoadOptions("password"))` |
| Garbled text or missing fonts in a result or preview, or an EPUB with more pages than on Windows | Linux | Install the fonts the documents use. The Microsoft core fonts give Windows' layout: `apt-get install ttf-mscorefonts-installer && fc-cache -f` (Debian: enable `contrib`) |
| An `Aspose/Drawing/SystemFontCache.xml` appears in the working directory | Linux | The engine's font cache goes there only when `~/.local/share` cannot be created, as in a read-only home: the package creates the folder otherwise. Set `XDG_DATA_HOME` to a writable folder |
| The process exits with code 134 and `Couldn't find a valid ICU package`, with no Python exception | Linux | Install ICU (`apt-get install libicu-dev`). Do NOT set `DOTNET_SYSTEM_GLOBALIZATION_INVARIANT` instead |
| `RuntimeError: The .NET runtime cannot be used in a process forked after it started` (up to 26.6.0: the parent process died with a segmentation fault) | Linux/macOS | A worker was forked after the parent's first GroupDocs call: `multiprocessing` with the `fork` start method, `gunicorn --preload`, Celery prefork. Use `multiprocessing.get_context("spawn")`, start the workers before the first call, or drop `--preload`. `uvicorn --workers` is safe |
| `is not a supported wheel on this platform`, `No matching distribution found for groupdocs-merger-net`, or pip installs a version older than 26.12 | Linux/macOS | The OS is older than the wheel needs (glibc 2.27, macOS 12), or pip is older than 20.3: `python -m pip install --upgrade pip`. Versions up to 26.6 were tagged for older systems, so an unpinned install falls back to them — and they fail at first use there. On an Intel Mac, a Python built against an old SDK reports macOS 10.16 — use pip 24.1+ or `SYSTEM_VERSION_COMPAT=0 pip install groupdocs-merger-net` |

## System Requirements

- Python 3.5 - 3.14, pip 20.3 or newer
- Windows x64, Linux x64, macOS x64/ARM64 — 64-bit Python only; there is no 32-bit Windows wheel
- Linux: glibc 2.27 or newer (e.g. Ubuntu 18.04+, Debian 10+, RHEL 8+), plus ICU and fontconfig (`apt-get install libicu-dev libfontconfig1`). `libgdiplus` only for OneNote documents. The Microsoft core fonts (`ttf-mscorefonts-installer`; on Debian enable `contrib` first) make an EPUB paginate as on Windows.
- macOS 12 or newer, Intel or Apple Silicon; `mono-libgdiplus` only for OneNote documents.

## Upgrading from 26.6

- **Relative output paths are relative to the working directory.** 26.6 wrote `merger.save("merged.pdf")` into the package's own folder (`site-packages/groupdocs/merger/_native/libs/Output/`), and `SplitOptions("part_{0}.pdf", ...)` raised "The path is empty".
- **Previews and split parts written to an `io.BytesIO` hold the output.** In 26.6 they stayed empty. A release callback, `PreviewOptions(create, release, ...)`, gets the stream as its second argument: `release(page_number, stream)`.
- **A misspelled option raises.** Assigning an attribute that a class does not have raises `AttributeError` with a "Did you mean" hint. 26.6 stored it on the Python object and the engine never saw it: `options.use_bookmark = True` did nothing; the property is `use_bookmarks`.
- **A licence that cannot be applied raises `LicenseError`** at the first Merger call, where 26.6 ran in evaluation mode without a word. `GROUPDOCS_LIC_STRICT=0` brings evaluation mode back, with a `LicenseWarning`.
- **Presentations need no `libgdiplus` on Linux and macOS.** Without it, 26.6 could not join, split, extract or remove pages of, preview or password-protect any PowerPoint file; 26.12 needs it only for OneNote documents. On Linux, presentations need fontconfig instead (`apt-get install libfontconfig1`).
- **No font cache in the working directory on Linux.** Where `~/.local/share` did not exist, as in a fresh container, 26.6 left the engine's `Aspose/Drawing/SystemFontCache.xml` in the working directory. The package now creates that folder, and the cache goes there.
- **Resources a document links to are not loaded by default** (engine 26.10): an image an HTML page links by a `file:///` address was in a 26.6 result, and is a red cross now. Allow them as shown in "Load the resources a trusted document links to".
- **pip also installs `groupdocs-shared-net`**, the package of `groupdocs.pydrawing` and `groupdocs.pycore` that every GroupDocs Python package shares. An offline install needs both wheels in one folder.
- **A file object passed to `Merger` stays open** after the call; 26.6 closed it.
- **The engine** is GroupDocs.Merger for .NET 26.11 on its .NET 10 build (`GroupDocs.Merger.Net100.Windows` on Windows, `GroupDocs.Merger.Net100` on Linux and macOS), with the .NET runtime 10.0.15. It adds spreadsheet joins by rows (`SpreadsheetJoinOptions`), and raises `MissingDependencyException` when a component a format needs is missing.

## More Resources

- [Documentation](https://docs.groupdocs.com/merger/python-net/)
- [Code Examples](https://github.com/groupdocs-merger/GroupDocs.Merger-for-Python-via-.NET)
- [Free Support Forum](https://forum.groupdocs.com/c/merger)
- [Temporary License](https://purchase.groupdocs.com/temporary-license)

Also available for other platforms:
[.NET](https://products.groupdocs.com/merger/net/) | [Java](https://products.groupdocs.com/merger/java/) | [Node.js](https://products.groupdocs.com/merger/nodejs-java/)

---

[Product Page](https://products.groupdocs.com/merger/python-net/) | [Docs](https://docs.groupdocs.com/merger/python-net/) | [Demos](https://products.groupdocs.app/merger/family) | [API Reference](https://reference.groupdocs.com/merger/python-net/) | [Blog](https://blog.groupdocs.com/category/merger/) | [Free Support](https://forum.groupdocs.com/c/merger) | [Temporary License](https://purchase.groupdocs.com/temporary-license)
