# PyWebLayout ## Project Status | Badge | Description | |-------|-------------| | ![Test Coverage](https://gitea.tourolle.paris/dtourolle/pyWebLayout/actions/runs/latest/artifacts/coverage-reports/coverage-8236ee7.svg) | **Test Coverage** - Percentage of code covered by unit tests | | ![Documentation Coverage](https://gitea.tourolle.paris/dtourolle/pyWebLayout/actions/runs/latest/artifacts/coverage-reports/coverage-docs-8236ee7.svg) | **Documentation Coverage** - Percentage of code with docstrings | | ![Build Status](./build-status.svg) | **Build Status** - Current CI/CD pipeline status | | ![License](https://img.shields.io/badge/license-MIT-blue.svg) | **License** - Project licensing information | A Python library for HTML-like layout and rendering. > 📋 **Note**: Badges show results from the commit referenced in the URLs. Red "error" badges indicate build failures for that specific step. ## Description PyWebLayout provides classes for rendering HTML-like content to images using a box-based layout system. It includes support for text, tables, and containers, as well as an HTML parser for converting HTML to layout objects. ## Features - HTML-like layout system - Text rendering with font support - Table layouts - Container elements - HTML parsing - Image output ## Installation ```bash pip install pyWebLayout ``` ## Usage ### Basic Example ```python from pyWebLayout.concrete.page import Page, Container from pyWebLayout.abstract.inline import Line from pyWebLayout.layout import Alignment from PIL import ImageFont # Create a page page = Page(size=(800, 600), background_color=(240, 240, 240)) # Add a title container title_container = Container( origin=(0, 0), size=(780, 60), direction='horizontal', spacing=10, padding=(10, 10, 10, 10), halign=Alignment.CENTER, valign=Alignment.CENTER ) page.add_child(title_container) # Create a title line with text title_font = ImageFont.load_default() title_line = Line( spacing=(8, 15), origin=(0, 0), size=(760, 40), font=title_font, text_color=(0, 0, 0), halign=Alignment.CENTER ) title_container.add_child(title_line) title_line.add_word("PyWebLayout", title_font) title_line.add_word("Example", title_font) # Layout and render the page page.layout() image = page.render() image.save("example.png") ``` ### HTML Example ```python from pyWebLayout.html_parser import html_to_image html = """

PyWebLayout HTML Example

This is a paragraph rendered from HTML.

The library supports bold, italic, and underlined text.

""" # Render HTML to an image image = html_to_image(html, page_size=(800, 600)) image.save("html_example.png") ``` ## License MIT License ## Author Duncan Tourolle - duncan@tourolle.paris