pdfdol.checks#
Checks that verify a PDF, rather than looking at a few of its pages.
text_overlaps finds text lines whose boxes overlap, the signature of a broken
pagination (a block drawn on top of another). It needs PyMuPDF, which is part of the
figures (and chromium) extra of pdfdol.
Functions
|
Pages (1-based) with text lines that overlap, and the pairs of overlapping lines. |
- pdfdol.checks.text_overlaps(pdf, *, min_frac=0.3, snippet_len=40)[source]#
Pages (1-based) with text lines that overlap, and the pairs of overlapping lines.
Two lines overlap when the area they share is at least
min_fracof the smaller line’s area. An empty dict means no overlapping text.- Parameters:
- Return type:
>>> import io >>> from reportlab.pdfgen import canvas >>> def make(y2): ... buf = io.BytesIO(); c = canvas.Canvas(buf) ... c.drawString(72, 700, "first line of text"); c.drawString(72, y2, "second line of text") ... c.save(); return buf.getvalue() >>> text_overlaps(make(100)) {} >>> text_overlaps(make(699)) {1: [('first line of text', 'second line of text')]}