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
| Key | Category | Summary |
|---|---|---|
| MERGERPYTHON‑34 | Feature | Add the groupdocs-merger command to merge, split, extract and remove pages from the command line |
| MERGERPYTHON‑49 | Feature | Append the rows of several spreadsheets to one worksheet with SpreadsheetJoinOptions |
| MERGERPYTHON‑50 | Feature | Choose which external resources a document loads with skip_external_resources, whitelisted_resources and external_resource_handler on LoadOptions |
| MERGERPYTHON‑51 | Enhancement | Update the GroupDocs.Merger engine from 26.4 to 26.11, on its .NET 10 build |
| MERGERPYTHON‑52 | Enhancement | Raise LicenseError when the licence in GROUPDOCS_LIC_PATH cannot be applied, instead of running in evaluation mode silently |
| MERGERPYTHON‑53 | Enhancement | Pass stream input and BytesIO output to .NET by pointer instead of base64 JSON |
| MERGERPYTHON‑54 | Enhancement | Install the modules every GroupDocs Python package shares from the groupdocs-shared-net package |
| MERGERPYTHON‑36 | Fix | Components with known CVEs in 26.6.0: .NET runtime 10.0.0 and libpng 1.6.44 |
| MERGERPYTHON‑56 | Fix | Assigning an option that does not exist was silently ignored |
| MERGERPYTHON‑57 | Fix | A file object passed as input was closed by the call, and emptied when opened for update |
| MERGERPYTHON‑58 | Fix | Memory grew with every call that passed a stream or a callback: their .NET objects were never released |
| MERGERPYTHON‑59 | Fix | A process forked after the first Merger call made the parent process crash with a segmentation fault |
| MERGERPYTHON‑60 | Fix | Previews and split parts written to a BytesIO stayed empty |
| MERGERPYTHON‑61 | Fix | A relative output path did not resolve against the working directory |
| MERGERPYTHON‑62 | Fix | Calls running in parallel threads could leave a BytesIO output empty or raise another thread’s exception |
| MERGERPYTHON‑63 | Fix | On Windows, the package ran on a .NET installed on the machine instead of the one in its wheel |
| MERGERPYTHON‑64 | Fix | On Python 3.10 and earlier, a SpooledTemporaryFile such as FastAPI’s UploadFile.file could not be passed to Merger |
| MERGERPYTHON‑65 | Fix | An exception raised in a preview or split release function was lost |
| MERGERPYTHON‑66 | Fix | pip installed the Linux and macOS wheels on systems too old to run them |
| MERGERPYTHON‑67 | Fix | On 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:SpreadsheetJoinOptionsjoins spreadsheets by worksheets or by rows (mode,skip_rows,sheet_matching), with the enumsSpreadsheetJoinModeandSpreadsheetSheetMatching.groupdocs.merger.domain.options:ExternalResourceLoadingArgsis what an external resource handler receives (uri,skipped,data),IExternalResourceHandleris the handler interface (on_loading), andIResourceLoadingOptionsis the interface of the three resource properties ofLoadOptions.groupdocs.merger.exceptions:MissingDependencyExceptionis raised when an operation needs a component that is missing on the machine, andAutoTaggingNotSupportedExceptionwhen PDF auto-tagging cannot be applied to a document. Both derive fromGroupDocsMergerException.groupdocs.merger:LicenseErroris raised by every Merger call while a licence that could not be applied is pending;LicenseWarningis warned instead withGROUPDOCS_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 fromgroupdocs.merger.exceptions.groupdocs.merger:CancellationTokenSource,CancellationTokenandOperationCanceledError, as in the other GroupDocs Python packages; no Merger operation takes a cancellation token in this release.
New members on existing classes
| Class | Member | Description |
|---|---|---|
LoadOptions | skip_external_resources | True by default: external resources are not loaded |
LoadOptions | whitelisted_resources | Absolute URI prefixes to load while skip_external_resources is True |
LoadOptions | external_resource_handler | A 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 = Truenow raisesAttributeErrorwith a “Did you mean” hint; the property isuse_bookmarks. - A file object passed as input stays open and unchanged.
Merger(f)closedf, 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
BytesIOinput 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 (
multiprocessingwithfork,gunicorn --preload, Celery prefork) made the parent die with a segmentation fault once the child called Merger too. The child now gets aRuntimeErrorat its first Merger call; usemultiprocessing.get_context("spawn"), or fork before the first call.uvicorn --workersis safe. - Previews and split parts written to a
BytesIOhold 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 insite-packages, and a split topart_{0}.pdffailed 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
SpooledTemporaryFileis 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_14andmacosx_11_0, while the embedded .NET 10 runtime needs glibc 2.27 and macOS 12. They are now taggedmanylinux_2_27andmacosx_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.xmlwas 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,Sheet2and so on, in both join modes. WordJoinMode.CONTINUOUSgives the result ofWordJoinMode.DEFAULT: each joined Word document still starts on a new page. The same holds forgroupdocs-merger merge --word-mode continuous.- The linked pictures of a Word document reach
external_resource_handlerwith an emptyuri, sowhitelisted_resourcescannot allow them. For a document you trust, setskip_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 anexternal_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.permissionsset to a combination ofPdfSecurityPermissionsvalues, such asDENY_PRINTING | DENY_MODIFICATION, denies nothing, although the PDF asks for its password. Each value alone, andDENY_ALL, work.- Joining TIFF images with
ImageJoinOptionswrites PNG data into the.tifffile, 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, notPasswordRequiredException. Catch both. - PostScript (
.ps) is listed byFileType.get_supported_file_types(), but no operation works on a PostScript file. - A
SpooledTemporaryFilereturned by a preview or split function stays empty. Return anio.BytesIOor an open file instead.
Documentation
- The
README.mdon PyPI and theAGENTS.mdinside the package describe the .NET 10 builds and what Linux and macOS need, thegroupdocs-shared-netdependency and the offline install, thegroupdocs-mergercommand, 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-netpackage), System Requirements (the packages Linux and macOS need, andlibgdiplusfor OneNote documents only) and Licensing and Evaluation (LicenseErrorand the measured evaluation limits). - The Getting Started pages moved from
merger/python-net/getting-started/<page>/tomerger/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.libgdiplusis needed for OneNote documents only. The Microsoft core fonts (ttf-mscorefonts-installer; on Debian, enable thecontribcomponent first) make an EPUB paginate as on Windows. - macOS:
mono-libgdiplusfor OneNote documents only (brew install mono-libgdiplus) groupdocs-shared-net26.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
| Platform | Wheel |
|---|---|
| Windows x64 | groupdocs_merger_net-26.12.0-py3-none-win_amd64.whl |
| Linux x64 | groupdocs_merger_net-26.12.0-py3-none-manylinux_2_27_x86_64.whl |
| macOS Intel | groupdocs_merger_net-26.12.0-py3-none-macosx_12_0_x86_64.whl |
| macOS Apple Silicon | groupdocs_merger_net-26.12.0-py3-none-macosx_12_0_arm64.whl |
| Any platform | groupdocs_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.