Skip to main content

pptx-slide-copier

PowerPoint slide copier utility - Deep copy slides between presentations while preserving all formatting, images, and layouts.

Features

  • Deep copy slides from one PowerPoint presentation to another
  • Preserves all formatting, fonts, colors, and styles
  • Copies images with correct relationship IDs
  • Matches slide layouts via slide masters (supports custom layouts)
  • Compatible with python-pptx 1.0.2+ API
  • Handles themes and layout preservation

Installation

pip install pptx-slide-copier

For development:

git clone https://github.com/SpringMT/pptx-slide-copier.git
cd pptx-slide-copier
pip install -e ".[dev]"

Quick Start

from pptx import Presentation
from pptx_slide_copier import SlideCopier

# Open source and target presentations
source_prs = Presentation("source.pptx")
target_prs = Presentation("target.pptx")

# Copy slide 0 from source to target
copied_slide = SlideCopier.copy_slide(source_prs, 0, target_prs)

# Save the target presentation
target_prs.save("output.pptx")

Usage

Basic Slide Copying

from pptx import Presentation
from pptx_slide_copier import SlideCopier

# Load presentations
source = Presentation("template.pptx")
target = Presentation()  # Create new presentation

# Copy first slide (index 0)
SlideCopier.copy_slide(source, 0, target)

# Copy multiple slides
for i in range(3):
    SlideCopier.copy_slide(source, i, target)

target.save("output.pptx")

Copying to Presentation Based on Template

For best results (to preserve themes and layouts), create the target presentation from the same template:

from pptx import Presentation
from pptx_slide_copier import SlideCopier

# Load template
template = Presentation("template.pptx")

# Create target from same template to preserve theme
target = Presentation("template.pptx")

# Remove all slides from target
while len(target.slides) > 0:
    rId = target.slides._sldIdLst[0].rId
    target.part.drop_rel(rId)
    del target.slides._sldIdLst[0]

# Now copy slides
SlideCopier.copy_slide(template, 0, target)

target.save("output.pptx")

How It Works

Deep Copying at XML Level

The library uses deepcopy at the XML element level to ensure all shape properties, formatting, and attributes are preserved:

from copy import deepcopy
new_element = deepcopy(shape.element)
dest_slide.shapes._spTree.insert_element_before(new_element, "p:extLst")

Image Relationship Mapping

Images are copied with proper relationship ID mapping to ensure they display correctly:

  1. Copy image data from source slide
  2. Add image to target presentation
  3. Map old relationship IDs to new ones
  4. Update XML references in copied shapes

Layout Matching

Slide layouts are matched via slide masters to support custom layouts:

  1. Find source slide's layout and master
  2. Match master by name in target presentation
  3. Find matching layout within the matched master
  4. Fall back to index-based matching if name match fails

Technical Details

  • python-pptx 1.0.2+ compatibility: Handles both old and new API for get_or_add_image_part()
  • XML namespaces: Correctly handles presentationml, drawingml, and relationship namespaces
  • Theme preservation: Works best when target presentation is created from same template
  • Error handling: Gracefully continues if individual shapes or images fail to copy

Testing

pytest

With coverage:

pytest --cov=pptx_slide_copier --cov-report=html

License

MIT

Author

SpringMT

Metadata

Release files for pptx-slide-copier 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pptx-slide-copier 0.1.5
File Size Uploaded Provenance Actions
pptx_slide_copier-0.1.5.tar.gz 16.4 kB Without provenance Details for pptx_slide_copier-0.1.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pptx-slide-copier 0.1.5
File Interpreter ABI Platform Actions
pptx_slide_copier-0.1.5-py3-none-any.whl Python 3 none any Details for pptx_slide_copier-0.1.5-py3-none-any.whl

Total release size: 26.7 kB

Release files / pptx_slide_copier-0.1.5.tar.gz

Download URL pptx_slide_copier-0.1.5.tar.gz
Size 16.4 kB
Tags Source
SHA-256 checksum
How to use checksums
0337639db42a673f67a2dd29939754f0d67a327bd3febe05713be1472e3cacb9
BLAKE2b-256 checksum
How to use checksums
675c02a126f8dfc6fb9de5abb5faf65b541fcebeabb16103f9cdbd21d2ab9a45
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.5

Release files / pptx_slide_copier-0.1.5-py3-none-any.whl

Download URL pptx_slide_copier-0.1.5-py3-none-any.whl
Size 10.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8c7927841a55a4f7978261d7cf49164988bee4100bad7c67ba4bc043e6310792
BLAKE2b-256 checksum
How to use checksums
7ceb4fa85f0c61d4426940c733cf37c7fbbfcf60f1feec950826d3d38707a970
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.5

Security for pptx-slide-copier 0.1.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page