forked from reingart/pyfpdf
-
Notifications
You must be signed in to change notification settings - Fork 227
/
test_write.py
38 lines (32 loc) · 1.11 KB
/
test_write.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from pathlib import Path
import fpdf
from test.conftest import assert_pdf_equal, LOREM_IPSUM
HERE = Path(__file__).resolve().parent
def test_write_page_break(tmp_path):
doc = fpdf.FPDF()
doc.add_page()
doc.set_font("helvetica", size=24)
doc.y = 20
doc.write(txt=LOREM_IPSUM)
doc.write(txt=LOREM_IPSUM)
assert_pdf_equal(doc, HERE / "write_page_break.pdf", tmp_path)
def test_write_soft_hyphen(tmp_path):
s = "Donau\u00addamp\u00adfschiff\u00adfahrts\u00adgesellschafts\u00adkapitäns\u00admützen\u00adstreifen. "
doc = fpdf.FPDF()
doc.add_page()
doc.set_font("helvetica", size=24)
doc.y = 20
doc.write(txt=s)
doc.set_font("helvetica", size=24, style="B")
doc.write(txt=s)
doc.set_font("helvetica", size=24, style="I")
doc.write(txt=s)
doc.set_font("helvetica", size=24)
doc.write(txt=s)
doc.set_font("helvetica", size=24, style="B")
doc.write(txt=s)
doc.set_font("helvetica", size=24, style="I")
doc.write(txt=s)
doc.set_font("helvetica", size=24)
doc.write(txt=s)
assert_pdf_equal(doc, HERE / "write_soft_hyphen.pdf", tmp_path)