fix: wrap recall/investigation table cells in Paragraph to prevent text overflow in PDF
This commit is contained in:
+19
-10
@@ -262,13 +262,18 @@ def generate_pdf(data: dict) -> str:
|
|||||||
story.append(Spacer(1, 6))
|
story.append(Spacer(1, 6))
|
||||||
|
|
||||||
if recalls:
|
if recalls:
|
||||||
r_rows = [["#", "Campaña", "Componente", "Descripción breve"]]
|
P = lambda txt, bold=False: Paragraph(
|
||||||
|
str(txt),
|
||||||
|
ParagraphStyle("rc", fontSize=7, fontName="Helvetica-Bold" if bold else "Helvetica",
|
||||||
|
textColor=NAVY2, leading=9, wordWrap="LTR"),
|
||||||
|
)
|
||||||
|
r_rows = [[P("#", True), P("Campaña", True), P("Componente", True), P("Descripción breve", True)]]
|
||||||
for i, r in enumerate(recalls[:20], 1):
|
for i, r in enumerate(recalls[:20], 1):
|
||||||
comp = (r.get("Component") or r.get("component") or "—")[:35]
|
comp = (r.get("Component") or r.get("component") or "—")[:120]
|
||||||
summary = (r.get("Summary") or r.get("summary") or "—")[:80]
|
summary = (r.get("Summary") or r.get("summary") or "—")[:300]
|
||||||
campaign = r.get("NHTSACampaignNumber") or r.get("campaignNumber") or "—"
|
campaign = r.get("NHTSACampaignNumber") or r.get("campaignNumber") or "—"
|
||||||
r_rows.append([str(i), campaign, comp, summary])
|
r_rows.append([P(i), P(campaign), P(comp), P(summary)])
|
||||||
story.append(_table(r_rows, [0.3*inch, 1.1*inch, 1.8*inch, W-3.2*inch]))
|
story.append(_table(r_rows, [0.25*inch, 1.0*inch, 1.9*inch, W-3.15*inch]))
|
||||||
|
|
||||||
# ── Complaints ────────────────────────────────────────────────────────────
|
# ── Complaints ────────────────────────────────────────────────────────────
|
||||||
story += _section("4 — QUEJAS DE PROPIETARIOS")
|
story += _section("4 — QUEJAS DE PROPIETARIOS")
|
||||||
@@ -291,13 +296,17 @@ def generate_pdf(data: dict) -> str:
|
|||||||
story += _section("5 — INVESTIGACIONES DE SEGURIDAD")
|
story += _section("5 — INVESTIGACIONES DE SEGURIDAD")
|
||||||
|
|
||||||
if invests:
|
if invests:
|
||||||
inv_rows = [["Número", "Asunto", "Estado"]]
|
PI = lambda txt, bold=False: Paragraph(
|
||||||
|
str(txt),
|
||||||
|
ParagraphStyle("iv", fontSize=7, fontName="Helvetica-Bold" if bold else "Helvetica",
|
||||||
|
textColor=NAVY2, leading=9, wordWrap="LTR"),
|
||||||
|
)
|
||||||
|
inv_rows = [[PI("Número", True), PI("Asunto", True), PI("Estado", True)]]
|
||||||
for inv in invests[:10]:
|
for inv in invests[:10]:
|
||||||
num = inv.get("InvestigationNumber") or inv.get("investigationNumber") or "—"
|
num = inv.get("InvestigationNumber") or inv.get("investigationNumber") or "—"
|
||||||
subj = (inv.get("Subject") or inv.get("subject") or "—")[:60]
|
subj = (inv.get("Subject") or inv.get("subject") or "—")[:200]
|
||||||
closed = inv.get("ClosingDate") or inv.get("closingDate")
|
closed = inv.get("ClosingDate") or inv.get("closingDate")
|
||||||
status = "Cerrada" if closed else "Abierta"
|
inv_rows.append([PI(num), PI(subj), PI("Cerrada" if closed else "Abierta")])
|
||||||
inv_rows.append([num, subj, status])
|
|
||||||
story.append(_table(inv_rows, [1.2*inch, W-2.4*inch, 1.2*inch]))
|
story.append(_table(inv_rows, [1.2*inch, W-2.4*inch, 1.2*inch]))
|
||||||
else:
|
else:
|
||||||
story.append(Paragraph("Sin investigaciones activas.", STYLE_BODY))
|
story.append(Paragraph("Sin investigaciones activas.", STYLE_BODY))
|
||||||
|
|||||||
Reference in New Issue
Block a user