fix: empty field: Qualifikation and Funktion
This commit is contained in:
1 parent
9f0e3cc8fc
commit
b084120c0d
1 file changed
+14
@@ -173,6 +173,11 @@ def _fill_pdf_pages(
|
|||||||
MULTILINE_FIELDS = {"Tätigkeiten_Field", "Dienstreisen_Field"}
|
MULTILINE_FIELDS = {"Tätigkeiten_Field", "Dienstreisen_Field"}
|
||||||
TEXTBOX_WIDTH_PT = 400 # Breite der Textbox in Punkt
|
TEXTBOX_WIDTH_PT = 400 # Breite der Textbox in Punkt
|
||||||
|
|
||||||
|
# Felder mit automatischer Schriftgrößen-Anpassung bei langem Text
|
||||||
|
AUTOSCALE_FIELDS = {"Qualifikation_Field", "Funktion_Field"}
|
||||||
|
AUTOSCALE_MAX_CHARS = 35 # ab dieser Länge wird verkleinert
|
||||||
|
AUTOSCALE_MIN_FACTOR = 0.75 # minimale Schriftgröße relativ zum Original
|
||||||
|
|
||||||
for m in mapping:
|
for m in mapping:
|
||||||
if m.pdf_field is None:
|
if m.pdf_field is None:
|
||||||
continue
|
continue
|
||||||
@@ -199,6 +204,15 @@ def _fill_pdf_pages(
|
|||||||
if not formatted:
|
if not formatted:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# Automatische Schriftgrößen-Anpassung für lange Texte
|
||||||
|
if m.pdf_field in AUTOSCALE_FIELDS and len(formatted) > AUTOSCALE_MAX_CHARS:
|
||||||
|
text_width = fitz.get_text_length(formatted, fontname="helv", fontsize=fontsize)
|
||||||
|
available_width = rect.width
|
||||||
|
if text_width > available_width:
|
||||||
|
factor = available_width / text_width
|
||||||
|
factor = max(factor, AUTOSCALE_MIN_FACTOR)
|
||||||
|
fontsize = fontsize * factor
|
||||||
|
|
||||||
# Mehrzeilige Felder: Zeilenweise per insert_text schreiben
|
# Mehrzeilige Felder: Zeilenweise per insert_text schreiben
|
||||||
if m.pdf_field in MULTILINE_FIELDS:
|
if m.pdf_field in MULTILINE_FIELDS:
|
||||||
# Doppelte Leerzeilen entfernen
|
# Doppelte Leerzeilen entfernen
|
||||||
|
|||||||
Reference in new issue
Block a user