SPB Git

Repository Public Research preview

check_overflow.py 1.2 KB 21 lines python

1#!/usr/bin/env python32# Vérifie qu'aucune diapo d'un PDF Beamer ne déborde sur le pied de page : pour chaque page, le bas des blocs de texte et des dessins3# (hors pied de page) doit rester au-dessus de la ligne du pied. Usage : python3 check_overflow.py deck.pdf [page_debut]4import sys, fitz5pdf = sys.argv[1]; start = int(sys.argv[2]) if len(sys.argv) > 2 else 16d = fitz.open(pdf)7bad = []8for i in range(start - 1, len(d)):9    p = d[i]; H = p.rect.height10    first = p.get_text().strip().split("\n")[0] if p.get_text().strip() else ""11    if first.isdigit() and len(first) <= 2: continue  # page de section (gros numéro)12    foot = [b for b in p.get_text("blocks") if b[1] > H * 0.9 and ("Boucher" in b[4] or "/" in b[4])]13    footer_y = min(b[1] for b in foot) if foot else H * 0.95514    limit = footer_y - 1.515    over = [b for b in p.get_text("blocks") if b[3] > limit + 2 and b[1] < footer_y - 4 and b not in foot and b[4].strip()]16    if over:17        bad.append((i + 1, round(max(b[3] for b in over) - footer_y, 1), p.get_text().split("\n")[0][:70]))18for b in bad: print(f"page {b[0]:3d}  +{b[1]:5.1f} pt  {b[2]}")19print(f"{len(bad)} page(s) en débordement sur {len(d) - start + 1}")20sys.exit(1 if bad else 0)21
Files main
Menu

Theme