Skip to content

Commit

Permalink
tests/test_story.py:test_2753(): new, checks handling of page-break-a…
Browse files Browse the repository at this point in the history
…fter.
  • Loading branch information
julian-smith-artifex-com committed Nov 13, 2023
1 parent 9996d42 commit 53c2566
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions tests/test_story.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fitz
import os
import textwrap


def test_story():
Expand Down Expand Up @@ -30,3 +31,42 @@ def test_story():
writer.end_page()

writer.close()


def test_2753():

def rectfn(rect_num, filled):
return fitz.Rect(0, 0, 200, 200), fitz.Rect(50, 50, 100, 100), None

def make_pdf(html, path_out):
story = fitz.Story(html=html)
document = story.write_with_links(rectfn)
print(f'Writing to: {path_out=}.')
document.save(path_out)
return document

doc_before = make_pdf(
textwrap.dedent('''
<p>Before</p>
<p style="page-break-before: always;"></p>
<p>After</p>
'''),
os.path.relpath(f'{__file__}/../../tests/test_2753-out-before.pdf'),
)

doc_after = make_pdf(
textwrap.dedent('''
<p>Before</p>
<p style="page-break-after: always;"></p>
<p>After</p>
'''),
os.path.relpath(f'{__file__}/../../tests/test_2753-out-after.pdf'),
)

assert len(doc_before) == 2

if fitz.mupdf_version_tuple > (1, 23, 5) and fitz.mupdf_version_tuple < (1, 24, 0):
assert len(doc_after) == 2
else:
# page-break-after not handled correctly.
assert len(doc_after) == 1

0 comments on commit 53c2566

Please sign in to comment.