# PyWebLayout A Python library for HTML-like layout and rendering. ## 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 = """
This is a paragraph rendered from HTML.
The library supports bold, italic, and underlined text.