# HTML Multi-Page Rendering Examples This directory contains working examples that demonstrate how to render HTML content across multiple pages using the pyWebLayout system. The examples show the complete pipeline from HTML parsing to multi-page layout. ## Overview The pyWebLayout system provides a sophisticated HTML-to-multi-page rendering pipeline that: 1. **Parses HTML** using the `pyWebLayout.io.readers.html_extraction` module 2. **Converts to abstract blocks** (paragraphs, headings, lists, etc.) 3. **Layouts content across pages** using the `pyWebLayout.layout.document_layouter` 4. **Renders pages as images** for visualization ## Examples ### 1. `html_multipage_simple.py` - Basic Example A simple demonstration that shows the core functionality: ```bash python examples/html_multipage_simple.py ``` **Features:** - Parses basic HTML with headings and paragraphs - Uses 600x800 pixel pages - Demonstrates single-page layout - Outputs to `output/html_simple/` **Results:** - Parsed 11 paragraphs from HTML - Rendered 1 page with 20 lines - Created `page_001.png` (19KB) ### 2. `html_multipage_demo_final.py` - Complete Multi-Page Demo A comprehensive demonstration with true multi-page functionality: ```bash python examples/html_multipage_demo_final.py ``` **Features:** - Longer HTML document with multiple chapters - Smaller pages (400x500 pixels) to force multi-page layout - Enhanced page formatting with headers and footers - Smart heading placement (avoids orphaned headings) - Outputs to `output/html_multipage_final/` **Results:** - Parsed 22 paragraphs (6 headings, 16 regular paragraphs) - Rendered 7 pages with 67 total lines - Average 9.6 lines per page - Created 7 PNG files (4.9KB - 10KB each) ## Technical Details ### HTML Parsing The system uses BeautifulSoup to parse HTML and converts elements to pyWebLayout abstract blocks: - `

-

` → `Heading` blocks - `

` → `Paragraph` blocks - `