GroupDocs.Merger for Python via .NET 26.12 Release Notes

This release upgrades the GroupDocs.Merger engine from 26.4 to 26.11 and moves it to the engine’s .NET 10 build, and it brings every fix made to the Python layer since 26.6. A new groupdocs-merger command merges, splits, extracts and removes pages from the shell. Spreadsheets can be joined row by row into one worksheet, and you decide which external resources, such as linked images and stylesheets, a document loads. Previews and split parts can be written to memory, relative output paths resolve against the working directory, and a licence that cannot be applied raises LicenseError instead of quietly running in evaluation mode. Memory no longer grows with each call that passes a stream, a forked process no longer crashes its parent, and file objects passed in stay open and unchanged. Presentations no longer need libgdiplus on Linux and macOS, and the embedded .NET runtime moves from 10.0.0 to 10.0.15.

Four changes can affect existing code. Assigning an option that a class does not have now raises AttributeError; it used to be dropped silently, so code with a misspelled option (use_bookmark for use_bookmarks) did nothing. A licence in GROUPDOCS_LIC_PATH that cannot be applied now raises LicenseError at the first call; GROUPDOCS_LIC_STRICT=0 brings back evaluation mode, with a warning. The engine no longer loads the external resources a document links to, such as the images of an HTML page, unless you allow them with the new LoadOptions properties. pip now also installs groupdocs-shared-net, so an offline install needs both wheels. Nothing is removed or renamed.

Full List of Changes in This Release

KeyCategorySummary
MERGERPYTHON‑34FeatureAdd the groupdocs-merger command to merge, split, extract and remove pages from the command line
MERGERPYTHON‑49FeatureAppend the rows of several spreadsheets to one worksheet with SpreadsheetJoinOptions
MERGERPYTHON‑50FeatureChoose which external resources a document loads with skip_external_resources, whitelisted_resources and external_resource_handler on LoadOptions
MERGERPYTHON‑51EnhancementUpdate the GroupDocs.Merger engine from 26.4 to 26.11, on its .NET 10 build
MERGERPYTHON‑52EnhancementRaise LicenseError when the licence in GROUPDOCS_LIC_PATH cannot be applied, instead of running in evaluation mode silently
MERGERPYTHON‑53EnhancementPass stream input and BytesIO output to .NET by pointer instead of base64 JSON
MERGERPYTHON‑54EnhancementInstall the modules every GroupDocs Python package shares from the groupdocs-shared-net package
MERGERPYTHON‑36FixComponents with known CVEs in 26.6.0: .NET runtime 10.0.0 and libpng 1.6.44
MERGERPYTHON‑56FixAssigning an option that does not exist was silently ignored
MERGERPYTHON‑57FixA file object passed as input was closed by the call, and emptied when opened for update
MERGERPYTHON‑58FixMemory grew with every call that passed a stream or a callback: their .NET objects were never released
MERGERPYTHON‑59FixA process forked after the first Merger call made the parent process crash with a segmentation fault
MERGERPYTHON‑60FixPreviews and split parts written to a BytesIO stayed empty
MERGERPYTHON‑61FixA relative output path did not resolve against the working directory
MERGERPYTHON‑62FixCalls running in parallel threads could leave a BytesIO output empty or raise another thread’s exception
MERGERPYTHON‑63FixOn Windows, the package ran on a .NET installed on the machine instead of the one in its wheel
MERGERPYTHON‑64FixOn Python 3.10 and earlier, a SpooledTemporaryFile such as FastAPI’s UploadFile.file could not be passed to Merger
MERGERPYTHON‑65FixAn exception raised in a preview or split release function was lost
MERGERPYTHON‑66Fixpip installed the Linux and macOS wheels on systems too old to run them
MERGERPYTHON‑67FixOn Linux, the engine’s font cache was written into the working directory

Major Features

Merge and split from the command line

The package installs a groupdocs-merger command, which python -m groupdocs.merger also runs:

groupdocs-merger merge report.pdf appendix.pdf -o combined.pdf
groupdocs-merger merge sales-january.xlsx sales-february.xlsx -o sales.xlsx --sheet-mode rows --skip-rows 1
groupdocs-merger split handbook.pdf -o parts --at 3,6     # pages 1-2, 3-5, 6 to the end
groupdocs-merger extract contract.pdf -o pages.pdf --pages 2-4,7
groupdocs-merger remove scan.pdf -o odd-pages.pdf --pages 1- --even
python -m groupdocs.merger --version

merge joins the documents in order and keeps the first one’s format; --image-layout, --word-mode and --sheet-mode choose how images, Word documents and spreadsheets are joined. split writes one file per page of --pages, or starts a new file at each page of --at, and splits a text file by lines. extract keeps the listed pages and remove drops them. Pages count from 1, 5- runs to the last page, and --odd / --even filter the list. --password opens a protected document, and --license applies a licence file or URL (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.

Spreadsheet rows into one worksheet

SpreadsheetJoinOptions with SpreadsheetJoinMode.ROWS appends the rows of each joined workbook below the last row with data, and skip_rows leaves out each joined file’s header rows:

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

options = SpreadsheetJoinOptions()
options.mode = SpreadsheetJoinMode.ROWS   # append rows instead of adding worksheets
options.skip_rows = 1                     # leave out each joined file's header row

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

sheet_matching pairs the worksheets by position (SpreadsheetSheetMatching.BY_INDEX, the default) or takes the first worksheet of each file only (SpreadsheetSheetMatching.FIRST_SHEET_ONLY). The default mode, SpreadsheetJoinMode.WORKSHEETS, adds the worksheets of each file, as joining spreadsheets always did.

Control over the external resources a document loads

Engine 26.10 stopped loading the external resources a document links to (images, stylesheets and other files on the web, the network or the local disk) unless you allow them. Content a document carries, such as the pictures inside a DOCX, still loads. Three LoadOptions properties decide:

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

def allow_photos(args):
    # args.uri is the reference; args.skipped holds the decision made so far
    if args.uri.startswith("https://images.example.com/") and args.uri.lower().endswith(".jpg"):
        args.skipped = False

options = LoadOptions(FileType.HTML)
options.whitelisted_resources = ["https://cdn.example.com/styles/"]  # load what is under this prefix
options.external_resource_handler = allow_photos                     # then decide per resource

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

whitelisted_resources lists the absolute URI prefixes to load. external_resource_handler takes a function or an object with an on_loading(args) method; it sees every external resource after the defaults and the whitelist have decided, and can load it (args.skipped = False), skip it (True), or supply its content as bytes in args.data. skip_external_resources = False loads every resource, as 26.6 did; use it only for documents you trust.

Previews and split parts in memory

A preview or split function can return an io.BytesIO, which holds the page or the part when the call returns; in 26.6 it stayed empty. A release function written as release(number, stream) also gets the stream its create function returned, already written:

import io
from groupdocs.merger import Merger
from groupdocs.merger.domain.options import PreviewMode, PreviewOptions, SplitMode, SplitOptions

parts, pages = {}, {}

def create_part(number):
    parts[number] = io.BytesIO()
    return parts[number]

def create_page(page_number):
    return io.BytesIO()

def release_page(page_number, stream):
    pages[page_number] = stream.getvalue()   # the PNG of this page

with Merger("document.pdf") as merger:
    merger.split(SplitOptions(create_part, [1, 2], SplitMode.PAGES))
    merger.generate_preview(PreviewOptions(create_page, release_page, PreviewMode.PNG, [1, 2]))

print({number: len(part.getvalue()) for number, part in parts.items()})
print({number: len(png) for number, png in pages.items()})

A release function written as release(number) works as before. Documents also cross to .NET faster: one passed as a BytesIO or another readable object is copied into .NET once, and a result saved to a BytesIO is copied back once, where both used to travel as base64 text inside JSON.

LicenseError instead of silent evaluation mode

A licence that failed to apply (an expired subscription, a licence for another product, a missing file) used to be ignored, and every result quietly came out in evaluation mode: the first three pages only, with the notice “Created with evaluation version of GroupDocs.Merger”. Now every Merger call raises LicenseError until a licence is applied. The message names the variable, the source and the reason:

from groupdocs.merger import LicenseError, Merger

try:
    with Merger("report.pdf") as merger:
        merger.join("appendix.pdf")
        merger.save("combined.pdf")
except LicenseError as error:
    print(error)

GROUPDOCS_LIC_STRICT=0 turns the failure into one LicenseWarning and evaluation mode. License().set_license(...) applied in code ends the refusal.

Engine 26.11 on its .NET 10 build

The package now wraps GroupDocs.Merger for .NET 26.11 through its .NET 10 builds: GroupDocs.Merger.Net100 on Linux and macOS, and GroupDocs.Merger.Net100.Windows on Windows. It brings the engine’s changes of 26.7 to 26.11, among them a page orientation change applied to every page when no pages are given, the preview width and height honoured in every format, PDF auto-tagging that keeps the document’s format and title, and Word page operations that return the right pages when a table spans several pages. A format whose component is missing on the machine raises MissingDependencyException.

On Linux and macOS, presentations no longer need libgdiplus: 26.6.0 could not join, split, preview or protect a PowerPoint file without it, and 26.12.0 needs it for OneNote documents only. On Linux, presentations need fontconfig (libfontconfig1) instead. The embedded .NET runtime moves from 10.0.0 to 10.0.15.

One package for the shared modules

groupdocs.pydrawing (Color, Point, Size, Rectangle) and groupdocs.pycore used to be copied into every product wheel. With several GroupDocs packages in one environment the last install won, and uninstalling one product removed them for the others. They now come from groupdocs-shared-net 26.11.0, which pip installs with groupdocs-merger-net. from groupdocs.merger import Color is unchanged.

API Changes

Nothing is removed or renamed.

New types

  • groupdocs.merger.domain.options: SpreadsheetJoinOptions joins spreadsheets by worksheets or by rows (mode, skip_rows, sheet_matching), with the enums SpreadsheetJoinMode and SpreadsheetSheetMatching.
  • groupdocs.merger.domain.options: ExternalResourceLoadingArgs is what an external resource handler receives (uri, skipped, data), IExternalResourceHandler is the handler interface (on_loading), and IResourceLoadingOptions is the interface of the three resource properties of LoadOptions.
  • groupdocs.merger.exceptions: MissingDependencyException is raised when an operation needs a component that is missing on the machine, and AutoTaggingNotSupportedException when PDF auto-tagging cannot be applied to a document. Both derive from GroupDocsMergerException.
  • groupdocs.merger: LicenseError is raised by every Merger call while a licence that could not be applied is pending; LicenseWarning is warned instead with GROUPDOCS_LIC_STRICT=0.
  • groupdocs.merger: GroupDocsMergerException, the class of every engine error that has no more specific Python exception, is importable from the package root as well as from groupdocs.merger.exceptions.
  • groupdocs.merger: CancellationTokenSource, CancellationToken and OperationCanceledError, as in the other GroupDocs Python packages; no Merger operation takes a cancellation token in this release.

New members on existing classes

ClassMemberDescription
LoadOptionsskip_external_resourcesTrue by default: external resources are not loaded
LoadOptionswhitelisted_resourcesAbsolute URI prefixes to load while skip_external_resources is True
LoadOptionsexternal_resource_handlerA function or an object with on_loading(args) that decides for each external resource

Fixed

  • CVE findings in 26.6.0 (MERGERPYTHON-36). The runtime moves from 10.0.0 to 10.0.15, and the libpng in SkiaSharp from 1.6.44 to 1.6.58. The engine’s Slides native library, which the Linux and macOS wheels now include, brings ICU 59 and libpng 1.6.38 — see Known Issues.
  • An option that does not exist is no longer dropped silently. PdfJoinOptions().use_bookmark = True now raises AttributeError with a “Did you mean” hint; the property is use_bookmarks.
  • A file object passed as input stays open and unchanged. Merger(f) closed f, and a file opened with "r+b" was truncated to 0 bytes.
  • Memory no longer grows with each call. Every .NET object a call created stayed alive until the process ended, so a BytesIO input kept its whole document. Objects are now released when their Python wrappers go, and callbacks when .NET drops them.
  • A forked process no longer crashes its parent. On Linux and macOS, a child forked after the first Merger call (multiprocessing with fork, gunicorn --preload, Celery prefork) made the parent die with a segmentation fault once the child called Merger too. The child now gets a RuntimeError at its first Merger call; use multiprocessing.get_context("spawn"), or fork before the first call. uvicorn --workers is safe.
  • Previews and split parts written to a BytesIO hold their bytes — see Major Features.
  • Relative output paths resolve against the working directory. merger.save("merged.pdf") wrote the file into the package’s folder in site-packages, and a split to part_{0}.pdf failed with “The path is empty”.
  • Parallel calls keep their own outputs. Under a thread pool, one call could copy another call’s half-written BytesIO, or raise the exception of another thread’s callback.
  • On Windows the package runs on the .NET it embeds. On a machine with a newer .NET 10 in C:\Program Files\dotnet, 26.6.0 ran on that runtime, and a second GroupDocs Python package in the same process could fail to start.
  • A SpooledTemporaryFile is accepted on Python 3.10 and earlier. Merger(upload.file) with Starlette’s or FastAPI’s upload matched no overload.
  • An exception in a release function is reported. When a preview or split release function raised, the exception was lost; it is now printed on stderr with its traceback, and the operation still completes.
  • pip no longer installs the Linux and macOS wheels where they cannot run. The 26.6.0 wheels were tagged manylinux1, macosx_10_14 and macosx_11_0, while the embedded .NET 10 runtime needs glibc 2.27 and macOS 12. They are now tagged manylinux_2_27 and macosx_12_0, which pip 20.3 or newer understands.
  • On Linux the font cache no longer lands in the working directory. In a container without ~/.local/share, Aspose/Drawing/SystemFontCache.xml was written into the current directory of every process.

Known Issues

  • The Linux and macOS wheels include the engine’s Slides native library, which serves presentations and contains ICU 59 and libpng 1.6.38; CVE scanners report both. A fix needs an engine release. (MERGERPYTHON-68)
  • Joining spreadsheets renames the worksheets of the result Sheet1, Sheet2 and so on, in both join modes.
  • WordJoinMode.CONTINUOUS gives the result of WordJoinMode.DEFAULT: each joined Word document still starts on a new page. The same holds for groupdocs-merger merge --word-mode continuous.
  • The linked pictures of a Word document reach external_resource_handler with an empty uri, so whitelisted_resources cannot allow them. For a document you trust, set skip_external_resources = False.
  • A relative link in an HTML document (<img src="photo.png">) resolves against the working directory, not the document’s folder. Run from the document’s folder, or supply the content in an external_resource_handler.
  • On Windows, splitting a text file by lines counts only CRLF line breaks: a file with LF breaks fails with “Line number should be equal or less than lines count 1”. Convert the breaks to CRLF first. Split parts and joined text files start with a UTF-8 byte order mark and use CRLF breaks, whatever the input’s; read them with encoding="utf-8-sig".
  • PdfSecurityOptions.permissions set to a combination of PdfSecurityPermissions values, such as DENY_PRINTING | DENY_MODIFICATION, denies nothing, although the PDF asks for its password. Each value alone, and DENY_ALL, work.
  • Joining TIFF images with ImageJoinOptions writes PNG data into the .tiff file, with the first frame of each input only. Join TIFF files without options to keep every frame.
  • Opening an encrypted PDF or Word document without a password raises IncorrectPasswordException, not PasswordRequiredException. Catch both.
  • PostScript (.ps) is listed by FileType.get_supported_file_types(), but no operation works on a PostScript file.
  • A SpooledTemporaryFile returned by a preview or split function stays empty. Return an io.BytesIO or an open file instead.

Documentation

  • The README.md on PyPI and the AGENTS.md inside the package describe the .NET 10 builds and what Linux and macOS need, the groupdocs-shared-net dependency and the offline install, the groupdocs-merger command, joining spreadsheets by rows, external resources, previews and split parts in memory, LicenseError, the evaluation limits (the first three pages, and a notice in the result) and what changes when upgrading from 26.6.
  • The examples of the documentation use new sample files and show a preview of each input and output document.
  • New pages: Hello, World! (merge two documents), Command Line Interface (every subcommand and option of groupdocs-merger), Skip loading of external resources, Import documents (OLE objects in Word, Excel, PowerPoint and Visio documents, and attachments in PDF documents), Merge pages in an arbitrary order, Merge audio and Merge TEX.
  • Updated pages: Merge Excel spreadsheets (rows into one worksheet), Generate page previews (previews into memory), Installation (the 26.12 wheels and the groupdocs-shared-net package), System Requirements (the packages Linux and macOS need, and libgdiplus for OneNote documents only) and Licensing and Evaluation (LicenseError and the measured evaluation limits).
  • The Getting Started pages moved from merger/python-net/getting-started/<page>/ to merger/python-net/<page>/, as in the .NET documentation, and their old addresses redirect. How to Run Examples describes the examples repository as it is now.

Requirements

  • Python 3.5 – 3.14 (python_requires = ">=3.5,<3.15") and pip 20.3 or newer; 64-bit Python only
  • Linux x64 with glibc 2.27 or newer; macOS 12 or newer, Intel or Apple Silicon. On an Intel Mac, a Python built against a pre-11 macOS SDK reports the system as macOS 10.16 — use pip 24.1 or newer there, or SYSTEM_VERSION_COMPAT=0 pip install groupdocs-merger-net
  • Windows: no additional packages
  • Linux: ICU and fontconfig — apt-get install libicu-dev libfontconfig1. libgdiplus is needed for OneNote documents only. The Microsoft core fonts (ttf-mscorefonts-installer; on Debian, enable the contrib component first) make an EPUB paginate as on Windows.
  • macOS: mono-libgdiplus for OneNote documents only (brew install mono-libgdiplus)
  • groupdocs-shared-net 26.11.0, which pip installs with the package
  • The .NET 10.0.15 runtime is embedded in the wheel; no separate install is needed

Wheel Distribution

PlatformWheel
Windows x64groupdocs_merger_net-26.12.0-py3-none-win_amd64.whl
Linux x64groupdocs_merger_net-26.12.0-py3-none-manylinux_2_27_x86_64.whl
macOS Intelgroupdocs_merger_net-26.12.0-py3-none-macosx_12_0_x86_64.whl
macOS Apple Silicongroupdocs_merger_net-26.12.0-py3-none-macosx_12_0_arm64.whl
Any platformgroupdocs_shared_net-26.11.0-py3-none-any.whl
pip install groupdocs-merger-net==26.12.0

For an offline install, put the platform wheel and the groupdocs-shared-net wheel in one folder:

pip install --no-index --find-links <folder> groupdocs-merger-net

Additional Resources

Feedback

Questions and issues are welcome on the GroupDocs.Merger forum.