new page per chapter
This commit is contained in:
@@ -23,12 +23,12 @@ sys.path.insert(0, str(Path(__file__).parent.parent))
|
||||
|
||||
try:
|
||||
from pyWebLayout.io.readers.epub_reader import read_epub
|
||||
from pyWebLayout.layout.document_layouter import DocumentLayouter, paragraph_layouter, image_layouter
|
||||
from pyWebLayout.layout.document_layouter import DocumentLayouter, paragraph_layouter, image_layouter, pagebreak_layouter
|
||||
from pyWebLayout.concrete.page import Page
|
||||
from pyWebLayout.style.page_style import PageStyle
|
||||
from pyWebLayout.style.fonts import Font
|
||||
from pyWebLayout.style.alignment import Alignment
|
||||
from pyWebLayout.abstract.block import Block, Paragraph, Heading, HList, Table, Image as AbstractImage
|
||||
from pyWebLayout.abstract.block import Block, Paragraph, Heading, HList, Table, Image as AbstractImage, PageBreak
|
||||
from pyWebLayout.style.concrete_style import RenderingContext, StyleResolver
|
||||
from PIL import Image, ImageDraw
|
||||
except ImportError as e:
|
||||
@@ -179,6 +179,19 @@ def layout_blocks_on_pages(blocks: List[Block], page_style: PageStyle,
|
||||
print(f"Warning: Error processing list: {e}")
|
||||
current_block_index += 1
|
||||
|
||||
elif isinstance(block, PageBreak):
|
||||
# PageBreak forces a new page
|
||||
success = pagebreak_layouter(block, page)
|
||||
|
||||
# Mark that we've seen this block
|
||||
current_block_index += 1
|
||||
continuation_word_index = 0
|
||||
continuation_pretext = None
|
||||
|
||||
# PageBreak always returns False to force new page
|
||||
# Break to create a new page for subsequent content
|
||||
break
|
||||
|
||||
elif isinstance(block, Table):
|
||||
# Skip tables for now (not implemented)
|
||||
print(f"Warning: Skipping table (not yet implemented)")
|
||||
|
||||
Reference in New Issue
Block a user