Skip to main content

Wokelo Docs

Create, read, and update Microsoft Word (.docx) and PowerPoint (.pptx) files with extended features

Wokelo Docs is an open-source Python library that merges and extends the functionality of python-docx and python-pptx, empowering developers to automate and enhance document and presentation creation. This library is designed to enable seamless generation and manipulation of Microsoft Word and PowerPoint files without requiring Microsoft Office.

Features

Word Enhancements

  • Native support for comments and footnotes.
  • Enhanced chart support, allowing the addition of dynamic charts to Word documents, positioning and scaling them with precision.

PowerPoint Enhancements

  • New functionality for adding and manipulating pictures in slide masters with improved picture shape ID management.

Office File Analysis

  • Extract text and images from both Word and PowerPoint files.

Installation

Install via pip:

pip install wokelo-docs

Usage

Word Documents (.docx)

Create and manipulate Word documents, including comments and footnotes

from wokelo_docs.docx import Document
from datetime import datetime

# Create document with comprehensive comment usage
doc = Document()

# Add content
p1 = doc.add_paragraph("This is the introduction paragraph.")
p2 = doc.add_paragraph("This paragraph contains important information.")

# Add comments to specific runs
intro_run = p1.runs[0]
intro_comment = intro_run.add_comment(
    text="Consider expanding this introduction",
    author="Reviewer 1",
    initials="R1",
    dtime=datetime.now().isoformat()
)

important_run = p2.runs[0]
important_comment = important_run.add_comment(
    text="This needs fact-checking",
    author="Editor",
    initials="ED"
)

# Save and later read comments
doc.save('reviewed_document.docx')

# Read comments back
doc2 = Document('reviewed_document.docx')
for paragraph in doc2.paragraphs:
    for run in paragraph.runs:
        if run.comments:
            for comment in run.comments:
                print(f"{comment.author}: {comment.text}")

PowerPoint Presentations (.pptx)

Create and update PowerPoint presentations, suitable for dynamic content or automation.

from wokelo_docs.pptx import Presentation
from wokelo_docs.pptx.enum.shapes import MSO_SHAPE
from wokelo_docs.pptx.util import Inches

prs = Presentation()
slide = prs.slides.add_slide(prs.slide_layouts[0])

# Create individual shapes first
shape1 = slide.shapes.add_shape(MSO_SHAPE.RECTANGLE, Inches(1), Inches(1), Inches(1), Inches(1))
shape2 = slide.shapes.add_shape(MSO_SHAPE.OVAL, Inches(2.5), Inches(1), Inches(1), Inches(1))
shape3 = slide.shapes.add_shape(MSO_SHAPE.TRIANGLE, Inches(1.75), Inches(2.5), Inches(1), Inches(1))

# Create a group with the shapes
group = slide.shapes.add_group_shape([shape1, shape2, shape3])

# The group automatically calculates its extents based on contained shapes
print(f"Group position: ({group.left}, {group.top})")
print(f"Group size: {group.width} x {group.height}")

# Add more shapes to the group
group_shapes = group.shapes
new_shape = group_shapes.add_shape(
    MSO_SHAPE.STAR_5_POINT,
    Inches(0.5),  # Relative to group
    Inches(0.5),
    Inches(0.5),
    Inches(0.5)
)

prs.save('presentation_with_groups.pptx')

For documentation, please refer Docs

Acknowledgment

Wokelo Docs leverages the incredible work done by the open-source projects python-docx and python-pptx for handling Microsoft Word and PowerPoint file operations. These libraries form the foundation of Wokelo Docs, upon which we've added enhanced features for more dynamic content generation and richer document functionality.

License

This project is dual-licensed under the MIT License and the Apache 2.0 License LICENSE

The core code of the project is licensed under the MIT License.

New features, enhancements, or contributions are licensed under the Apache 2.0 License.

Metadata

Release files for wokelo-docs 0.1.0

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

Source distribution (sdist)

Source distribution for wokelo-docs 0.1.0
File Size Uploaded
wokelo_docs-0.1.0.tar.gz 634.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for wokelo-docs 0.1.0
File Interpreter ABI Platform
wokelo_docs-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 1.4 MB

Release files / wokelo_docs-0.1.0.tar.gz

Download URL wokelo_docs-0.1.0.tar.gz
Size 634.7 kB
Tags Source
SHA-256 checksum
How to use checksums
96c8ab97a9d54952e257a26c2b2e7431cedc6dd897db7d65f262dda0848096e6
BLAKE2b-256 checksum
How to use checksums
24ca2d8c0a71942d99172467e745d84a088a9f9d7b5a9f4702b402f4ddd4b856
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.6

Release files / wokelo_docs-0.1.0-py3-none-any.whl

Download URL wokelo_docs-0.1.0-py3-none-any.whl
Size 794.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2c3d2ded6dd75faee54be0f39fcf928c484cefbca06f45bbb50d1f5a59d06809
BLAKE2b-256 checksum
How to use checksums
df6b9504ac13fb63c4d3ad65c616f986e679d42ddfa93932c5573dacc96e7b40
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.6

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

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