Skip to main content

pptx-replace

A python package for replaceing text, images and tables in pptx files

import pptx
import pptx_replace

prs = Presentation("tests/templates/test_template.pptx")
replace_text(prs, "{Main title}", "this is main report title")
slide = prs.slides[1]
replace_text(slide, "{title}", "This is a title")
replace_picture(prs.slides[0], "image.png", auto_reshape=True)

installation

pip install pptx-replace

If you want to put altair picture into pptx file, you need install some extra packages.

pip install "pptx-replace[alt]"

see: https://github.com/altair-viz/altair_saver

extra dependency

Depends on your usage, if you want to export table and keep style in jupyter, selemium and browser driver is required.

see: https://github.com/dexplo/dataframe_image/

usage

First open your pptx file.

import pptx
import pptx_replace

prs = Presentation("tests/templates/test_template.pptx")

replace text

Replace any text in your ppt

# repalce all occurances of {Main title} in pptx
replace_text(prs, "{Main title}", "this is main report title")
slide = prs.slides[1]

# replace in just one slide
replace_text(slide, "{title}", "This is a title")

replace_text(slide, "{content}", "a quick brown fox jumps over the lazy dog\n" * 5)

replace picture

Replace picture just by matplotlib figuer!

import matplotlib.pyplot as plt

plt.plot([1, 2, 3, 4])
fig = plt.gcf()

replace_picture(prs.slides[1], fig, auto_reshape=False, order="l2r")

replace table

replace table by pandas dataframe

import pandas as pd
import numpy as np

df = pd.DataFrame(np.random.rand(6, 10))
replace_table(slide, df)

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pptx_replace-0.1.6.tar.gz (13.8 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pptx_replace-0.1.6-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file pptx_replace-0.1.6.tar.gz.

File metadata

  • Download URL: pptx_replace-0.1.6.tar.gz
  • Upload date:
  • Size: 13.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for pptx_replace-0.1.6.tar.gz
Algorithm Hash digest
SHA256 00eb7f6e7bb69e94d2bfaa0926a46f8e4bfd37ebe31ce2382c0c5d7279b0b847
MD5 a9f3fdd2a9255eea7a0c83acb7679bef
BLAKE2b-256 aa38f848a6907eaf020a0526e18dd6fd4f0f2ac5c3cab550c62fa278017518ae

See more details on using hashes here.

File details

Details for the file pptx_replace-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: pptx_replace-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for pptx_replace-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 71d37dc2cf47c54c18795f053f677cf424d19b272e46cef3aca3ac2d9c237232
MD5 16bb68cc1e5cfe9fa73a9cd1beb4c43a
BLAKE2b-256 2d2276e65f494949402bb123686c8bedbdc6cc29659c46abd1a35ec183412244

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.6 This release

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page