Skip to main content

Generate PowerPoint files from JSON with progressive HTML support.

Project description

PPTX HTML Generator

Python library for rendering rich HTML text into python-pptx text frames.

Primary API

Most users should use this directly in their existing python-pptx pipeline:

from pptx_html_generator import render_html_to_text_frame

render_html_to_text_frame(shape.text_frame, html_string, base_styles={...})

This plugs in exactly where your app converts string content into text-frame content.

See:

  • API contract: docs/API.md

Features

  • JSON schema validation with useful error messages
  • Unit parsing for in, cm, pt, emu
  • Presentation generation with text box elements
  • HTML rich-text support:
    • Inline formatting: <b>, <strong>, <i>, <em>, <u>, <s>, <del>, <strike>, <code>, <sup>, <sub>
    • Links and styled spans: <a>, <span style>
    • Block structure: <p>, <br>, <ul>, <ol>, <li>, <h1>-<h6>
  • JSON style/default support:
    • font_name, font_size, font_color
    • alignment, vertical_anchor, word_wrap
  • CLI: json_in -> pptx_out

Quick start

python -m pip install pptx-html-generator

Drop-in usage in an existing python-pptx workflow:

from pptx import Presentation
from pptx_html_generator import render_html_to_text_frame

prs = Presentation()
slide = prs.slides.add_slide(prs.slide_layouts[6])  # blank
shape = slide.shapes.add_textbox(914400, 914400, 7315200, 1828800)
html = "<p><strong>Hello</strong> <em>world</em> with <a href='https://example.com'>a link</a>.</p>"

render_html_to_text_frame(shape.text_frame, html)
prs.save("example.pptx")

Forward generation CLI (optional helper for JSON-driven generation):

pptx-html-generator generate examples/full_implementation.json output/full_implementation_demo.pptx

Development setup:

python -m pip install -e ".[dev]"
pytest

CLI

Generate PPTX:

pptx-html-generator generate examples/full_implementation.json output/full_implementation_demo.pptx

List selectable elements on a slide (uses PowerPoint Selection Pane names):

pptx-html-generator list-elements output/full_implementation_demo.pptx --slide 1

Extract HTML from a selected shape by Selection Pane name:

pptx-html-generator extract-html output/full_implementation_demo.pptx --slide 1 --shape-name "BodyContent"

JSON shape (optional high-level API)

{
  "presentation": {
    "width": "13.333in",
    "height": "7.5in"
  },
  "slides": [
    {
      "layout": "blank",
      "elements": [
        {
          "type": "textbox",
          "position": {
            "left": "1in",
            "top": "1in",
            "width": "8in",
            "height": "2in"
          },
          "content": "Plain text content"
        }
      ]
    }
  ]
}

Project details


Download files

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

Source Distribution

pptx_html_generator-0.1.0.tar.gz (16.4 kB view details)

Uploaded Source

Built Distribution

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

pptx_html_generator-0.1.0-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

Details for the file pptx_html_generator-0.1.0.tar.gz.

File metadata

  • Download URL: pptx_html_generator-0.1.0.tar.gz
  • Upload date:
  • Size: 16.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for pptx_html_generator-0.1.0.tar.gz
Algorithm Hash digest
SHA256 dd9c5dd683fb7e17f60bd157521960b6b290721dc63fe09b83c3108fabdb4689
MD5 7564ace46e63d23af258a7b790594824
BLAKE2b-256 fbca753bed083b32191cc73fff2e560f8650f42d8b8256f6d37e542fb30f6c8e

See more details on using hashes here.

File details

Details for the file pptx_html_generator-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pptx_html_generator-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5fe4411c85812ab53cfbd1f1ecd33c3180aed2b253dac172cb3a7f64a939184d
MD5 fa696ecc6c1f303cec6dd559713df681
BLAKE2b-256 34607831d2990667e74000fce4fe485b68cf508d7ca36475d08a03c1b83e74e7

See more details on using hashes here.

Supported by

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