new page per chapter

This commit is contained in:
2025-11-04 22:59:58 +01:00
parent 562b4cf5d0
commit d542f08dd0
4 changed files with 82 additions and 4 deletions
+20 -2
View File
@@ -6,7 +6,7 @@ from pyWebLayout.concrete import Page, Line, Text
from pyWebLayout.concrete.image import RenderableImage
from pyWebLayout.concrete.functional import LinkText
from pyWebLayout.abstract import Paragraph, Word, Link
from pyWebLayout.abstract.block import Image as AbstractImage
from pyWebLayout.abstract.block import Image as AbstractImage, PageBreak
from pyWebLayout.abstract.inline import LinkedWord
from pyWebLayout.style.concrete_style import ConcreteStyleRegistry, RenderingContext, StyleResolver
from pyWebLayout.style import Font, Alignment
@@ -78,7 +78,6 @@ def paragraph_layouter(paragraph: Paragraph, page: Page, start_word: int = 0, pr
# Cap font size to page maximum if needed
if font.font_size > page.style.max_font_size:
from pyWebLayout.style import Font
font = Font(
font_path=font._font_path,
font_size=page.style.max_font_size,
@@ -211,6 +210,25 @@ def paragraph_layouter(paragraph: Paragraph, page: Page, start_word: int = 0, pr
return True, None, None
def pagebreak_layouter(page_break: PageBreak, page: Page) -> bool:
"""
Handle a page break element.
A page break signals that all subsequent content should start on a new page.
This function always returns False to indicate that the current page is complete
and a new page should be created for subsequent content.
Args:
page_break: The PageBreak block
page: The current page (not used, but kept for consistency)
Returns:
bool: Always False to force creation of a new page
"""
# Page break always forces a new page
return False
def image_layouter(image: AbstractImage, page: Page, max_width: Optional[int] = None,
max_height: Optional[int] = None) -> bool:
"""