rpa-bot-handoff: fit the SOP in 4 real pages

The first SOP (MEK Charge Reconciliation, 1,327 words) printed on 5 pages:
Word's 2.5 cm default margins and 10.5 pt table text. to_docx.py now uses
1.8/1.6 cm margins and 9.5 pt table text; the trimmed SOP (1,226 words)
prints on 3 pages. The verify step counts real pages through Word when it
is installed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
VasanthandClaude Opus 5.5 committed 2026-10-28 17:02:20 +05:30
1 parent ff2f7fcd4a
commit 717f2c40c5
2 files changed
+8 -2

No files matched your search

+7 -2
View File
@@ -16,9 +16,9 @@ import tempfile
from pathlib import Path
from docx import Document
from docx.shared import Pt
from docx.shared import Cm, Pt
MAX_WORDS = 1400 # about 4 pages with tables
MAX_WORDS = 1400 # about 4 pages with the margins and table font below
INLINE = re.compile(r"(\*\*[^*]+\*\*|\*[^*\s][^*]*\*|`[^`]+`)")
@@ -42,6 +42,9 @@ def convert(md_text, out_path):
doc = Document()
doc.styles["Normal"].font.name = "Calibri"
doc.styles["Normal"].font.size = Pt(10.5)
for section in doc.sections: # Word's 2.5 cm default margins push a 4-page SOP onto 5
section.left_margin = section.right_margin = Cm(1.8)
section.top_margin = section.bottom_margin = Cm(1.6)
lines = md_text.splitlines()
i = 0
while i < len(lines):
@@ -69,6 +72,8 @@ def convert(md_text, out_path):
for c, text in enumerate(row):
par = table.cell(r, c).paragraphs[0]
add_runs(par, text)
for run in par.runs:
run.font.size = Pt(9.5)
if r == 0:
for run in par.runs:
run.bold = True