Ensure hard page break before summary in transcript DOCX
This commit is contained in:
+3
-10
@@ -539,18 +539,11 @@ def create_transcript_docx(text: str, filename: str, summary_text: str = ""):
|
||||
for line_num, line_text in enumerate(page_lines, start=1):
|
||||
_add_transcript_paragraph(doc, line_text, line_number=line_num)
|
||||
|
||||
# Step 5: If summary_text provided, append it with page break
|
||||
# Step 5: If summary_text provided, append it with a hard page break
|
||||
if summary_text and summary_text.strip():
|
||||
# Page break after transcript
|
||||
# Hard page break after transcript
|
||||
p_break = doc.add_paragraph()
|
||||
pPr = p_break._p.get_or_add_pPr()
|
||||
for child in list(pPr):
|
||||
tag = child.tag.split("}")[-1] if "}" in child.tag else child.tag
|
||||
if tag in ("tabs", "spacing", "ind"):
|
||||
pPr.remove(child)
|
||||
page_break = OxmlElement("w:pageBreak")
|
||||
page_break.set("{http://schemas.openxmlformats.org/wordprocessingml/2006/main}val", "1")
|
||||
pPr.append(page_break)
|
||||
p_break.paragraph_format.page_break_before = True
|
||||
|
||||
# Centered "SUMMARY" title
|
||||
title_p = doc.add_paragraph()
|
||||
|
||||
Reference in New Issue
Block a user