Merge EPUB

GroupDocs.Merger for Python via .NET allows you to combine multiple EPUB e-book files into a single file programmatically. All content from the source files is preserved in the merged output — no third-party e-reader software required.

Steps to merge EPUB files

  1. Create an instance of the Merger class and pass the path to the first (base) EPUB file.
  2. Call merger.join() with the path to each additional EPUB file to append.
  3. Call merger.save() with the desired output path to write the merged file.
from groupdocs.merger import Merger

def merge_epub_documents():
    # Load the first EPUB file as the merge base
    with Merger("./input.epub") as merger:
        # Append the second EPUB file
        merger.join("./input2.epub")
        # Save the combined EPUB file
        merger.save("./output.epub")

if __name__ == "__main__":
    merge_epub_documents()

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

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

Binary file (EPUB, 49 KB)

Download full output

Explanation

  • Load base document: Merger("./input.epub") opens the first EPUB file as the merge base inside a context manager.
  • Append second document: merger.join("./input2.epub") appends the content of the second file. Call join again for each additional file.
  • Save result: merger.save("./output.epub") writes the merged EPUB to disk.

About EPUB File Format

Files with the .EPUB extension are an e-book file format that provides a standard for digital publications accepted by publishers and consumers worldwide. The format is supported by many e-readers and software applications. On macOS, the pre-installed Books app can open EPUB files directly. Compatible software is also widely available for smartphones, tablets, and desktop computers.

Merge EPUB Live Demo

GroupDocs.Merger for Python via .NET provides an online EPUB Merger App, which allows you to try it for free and check its quality and accuracy.

“Merge EPUB”

API reference

  • Merger — main class; join, save methods.

See also