Name | pptx-replace JSON |
Version |
0.1.6
JSON |
| download |
home_page | None |
Summary | python package for replaceing elemnets in pptx files |
upload_time | 2024-09-03 01:38:18 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.8 |
license | MIT |
keywords |
pptx
image
replace
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# pptx-replace
A python package for replaceing text, images and tables in pptx files
```python
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
```bash
pip install pptx-replace
```
If you want to put `altair` picture into pptx file, you need install some extra packages.
```bash
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.
```python
import pptx
import pptx_replace
prs = Presentation("tests/templates/test_template.pptx")
```
### replace text
Replace any text in your ppt
```python
# 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!
```python
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
```python
import pandas as pd
import numpy as np
df = pd.DataFrame(np.random.rand(6, 10))
replace_table(slide, df)
```
Raw data
{
"_id": null,
"home_page": null,
"name": "pptx-replace",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "pptx, image, replace",
"author": null,
"author_email": "John Lyu <paleneutron@outlook.com>",
"download_url": "https://files.pythonhosted.org/packages/aa/38/f848a6907eaf020a0526e18dd6fd4f0f2ac5c3cab550c62fa278017518ae/pptx_replace-0.1.6.tar.gz",
"platform": null,
"description": "# pptx-replace\n\nA python package for replaceing text, images and tables in pptx files\n\n```python\nimport pptx\nimport pptx_replace\n\nprs = Presentation(\"tests/templates/test_template.pptx\")\nreplace_text(prs, \"{Main title}\", \"this is main report title\")\nslide = prs.slides[1]\nreplace_text(slide, \"{title}\", \"This is a title\")\nreplace_picture(prs.slides[0], \"image.png\", auto_reshape=True)\n```\n\n## installation\n\n```bash\npip install pptx-replace\n```\n\nIf you want to put `altair` picture into pptx file, you need install some extra packages.\n\n```bash\npip install \"pptx-replace[alt]\"\n```\n\nsee: <https://github.com/altair-viz/altair_saver>\n\n### extra dependency\n\nDepends on your usage, if you want to export table and keep style in jupyter, `selemium` and browser driver is required.\n\nsee: <https://github.com/dexplo/dataframe_image/>\n\n\n## usage\n\nFirst open your pptx file.\n\n```python\nimport pptx\nimport pptx_replace\n\nprs = Presentation(\"tests/templates/test_template.pptx\")\n```\n\n\n### replace text\n\nReplace any text in your ppt\n\n```python\n# repalce all occurances of {Main title} in pptx\nreplace_text(prs, \"{Main title}\", \"this is main report title\")\nslide = prs.slides[1]\n\n# replace in just one slide\nreplace_text(slide, \"{title}\", \"This is a title\")\n\nreplace_text(slide, \"{content}\", \"a quick brown fox jumps over the lazy dog\\n\" * 5)\n```\n\n### replace picture\n\nReplace picture just by matplotlib figuer!\n\n```python\nimport matplotlib.pyplot as plt\n\nplt.plot([1, 2, 3, 4])\nfig = plt.gcf()\n\nreplace_picture(prs.slides[1], fig, auto_reshape=False, order=\"l2r\")\n```\n\n### replace table\n\nreplace table by pandas dataframe\n\n```python\nimport pandas as pd\nimport numpy as np\n\ndf = pd.DataFrame(np.random.rand(6, 10))\nreplace_table(slide, df)\n\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "python package for replaceing elemnets in pptx files",
"version": "0.1.6",
"project_urls": {
"Source Code": "https://github.com/PaleNeutron/pptx-replace"
},
"split_keywords": [
"pptx",
" image",
" replace"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "2d2276e65f494949402bb123686c8bedbdc6cc29659c46abd1a35ec183412244",
"md5": "16bb68cc1e5cfe9fa73a9cd1beb4c43a",
"sha256": "71d37dc2cf47c54c18795f053f677cf424d19b272e46cef3aca3ac2d9c237232"
},
"downloads": -1,
"filename": "pptx_replace-0.1.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "16bb68cc1e5cfe9fa73a9cd1beb4c43a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 7479,
"upload_time": "2024-09-03T01:38:16",
"upload_time_iso_8601": "2024-09-03T01:38:16.457678Z",
"url": "https://files.pythonhosted.org/packages/2d/22/76e65f494949402bb123686c8bedbdc6cc29659c46abd1a35ec183412244/pptx_replace-0.1.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "aa38f848a6907eaf020a0526e18dd6fd4f0f2ac5c3cab550c62fa278017518ae",
"md5": "a9f3fdd2a9255eea7a0c83acb7679bef",
"sha256": "00eb7f6e7bb69e94d2bfaa0926a46f8e4bfd37ebe31ce2382c0c5d7279b0b847"
},
"downloads": -1,
"filename": "pptx_replace-0.1.6.tar.gz",
"has_sig": false,
"md5_digest": "a9f3fdd2a9255eea7a0c83acb7679bef",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 13827070,
"upload_time": "2024-09-03T01:38:18",
"upload_time_iso_8601": "2024-09-03T01:38:18.134443Z",
"url": "https://files.pythonhosted.org/packages/aa/38/f848a6907eaf020a0526e18dd6fd4f0f2ac5c3cab550c62fa278017518ae/pptx_replace-0.1.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-03 01:38:18",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "PaleNeutron",
"github_project": "pptx-replace",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "pptx-replace"
}