GroupDocs.Merger for Python via .NET

Swap MHTML pages

GroupDocs.Merger for Python via .NET enhances Python applications with advanced document processing. Swap pages in MHTML files to better organize and control your content.

How to swap MHTML pages

GroupDocs.Merger makes it easy to swap MHTML pages, giving you full control over document content. Use it in your Python via .NET applications for seamless document processing.

  1. Specify the path to the MHTML file.
  2. Select the page numbers to swap.
  3. Use the appropriate method to swap pages.
  4. Save the updated document to the desired location.
import groupdocs.merger as gm

# Load the document into Merger
with gm.Merger("document.mhtml") as merger:
    
    # Specify the page numbers to swap
    swapOptions = gm.domain.options.SwapOptions(1, 2)

    # Swap the selected pages
    merger.swap_pages(swapOptions)

    # Save the modified file
    merger.save("result.mhtml")
npm i @groupdocs/groupdocs.merger
click to copy
copied
More examples Documentation

Advanced document management

GroupDocs.Merger for Python via .NET provides a powerful set of tools for processing over 50 file formats with ease.

Key capabilities of GroupDocs.Merger

Merge various document types

Combine PDFs, Word documents, spreadsheets, presentations, Visio diagrams, images, and archive files. Customize output with flexible options.

Rearrange document pages

Modify document layout by moving, swapping, or deleting pages for better content organization.

Adjust page orientation

Rotate pages to a specific angle or switch between portrait and landscape mode.

Extract selected pages

Select specific pages or page ranges and save them as a separate document.

Swap the first and last pages of a MHTML file

This example shows how to swap pages in a MHTML file in just a few steps.

JavaScript

import groupdocs.merger as gm

# Load the source document
with gm.Merger("document.mhtml") as merger:
  
    # Get the total number of pages
    info = merger.get_document_info()
    lastPage = info.page_count

    # Define swap options with selected pages
    swapOptions = gm.domain.options.SwapOptions(1, lastPage)

    # Execute the swap operation
    merger.swap_pages(swapOptions)

    # Save the modified document
    merger.save("result.mhtml")
npm i @groupdocs/groupdocs.merger
click to copy
copied
More examples Documentation

GroupDocs.Merger features

GroupDocs.Merger for Python via .NET is a document processing library that supports 50+ file formats, including PDF, Word, Excel, PowerPoint, Visio, images, and archives. Add it to your applications to merge, split, extract, rearrange, swap, and remove pages in widely used document formats.
Learn more
About illustration

Ready to get started?

Download GroupDocs.Merger for free or get a trial license for full access!

Useful resources

Explore documentation, code samples, and community support to enhance your experience.

Main features

Discover the key features of our document processing library.

Swap pages in various file formats

GroupDocs.Merger supports over 50 file formats, allowing precise document modifications.

Temporary license tips

1
Sign up with your work email.
Free mail services are not allowed.
2
Use Get a temporary license button on the second step.
 English