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:
1 parent
ff2f7fcd4a
commit
717f2c40c5
2 files changed
+8
-2
No files matched your search
@@ -68,6 +68,7 @@ Copy `templates/HANDOVER-SOP.md` to the bot's repo root and fill every `{{PLACEH
|
|||||||
3. No file:line, function names, env var names, client names, PHI, credentials or IPs.
|
3. No file:line, function names, env var names, client names, PHI, credentials or IPs.
|
||||||
4. Run `python <skill>/templates/to_docx.py HANDOVER-SOP.md -o "<Project Name> Handover SOP.docx"`. If it reports more than 1,400 words, cut: merge rows, drop explanations, never drop a message.
|
4. Run `python <skill>/templates/to_docx.py HANDOVER-SOP.md -o "<Project Name> Handover SOP.docx"`. If it reports more than 1,400 words, cut: merge rows, drop explanations, never drop a message.
|
||||||
5. Open the docx with python-docx: 5 numbered section headings, no `**` or `|---` left.
|
5. Open the docx with python-docx: 5 numbered section headings, no `**` or `|---` left.
|
||||||
|
6. When Word is installed, count the real pages (PowerShell: open it with `Word.Application`, read `ComputeStatistics(2)`). More than 4: cut words, then rebuild.
|
||||||
|
|
||||||
## 5. Hand over
|
## 5. Hand over
|
||||||
|
|
||||||
|
|||||||
@@ -16,9 +16,9 @@ import tempfile
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from docx import Document
|
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][^*]*\*|`[^`]+`)")
|
INLINE = re.compile(r"(\*\*[^*]+\*\*|\*[^*\s][^*]*\*|`[^`]+`)")
|
||||||
|
|
||||||
|
|
||||||
@@ -42,6 +42,9 @@ def convert(md_text, out_path):
|
|||||||
doc = Document()
|
doc = Document()
|
||||||
doc.styles["Normal"].font.name = "Calibri"
|
doc.styles["Normal"].font.name = "Calibri"
|
||||||
doc.styles["Normal"].font.size = Pt(10.5)
|
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()
|
lines = md_text.splitlines()
|
||||||
i = 0
|
i = 0
|
||||||
while i < len(lines):
|
while i < len(lines):
|
||||||
@@ -69,6 +72,8 @@ def convert(md_text, out_path):
|
|||||||
for c, text in enumerate(row):
|
for c, text in enumerate(row):
|
||||||
par = table.cell(r, c).paragraphs[0]
|
par = table.cell(r, c).paragraphs[0]
|
||||||
add_runs(par, text)
|
add_runs(par, text)
|
||||||
|
for run in par.runs:
|
||||||
|
run.font.size = Pt(9.5)
|
||||||
if r == 0:
|
if r == 0:
|
||||||
for run in par.runs:
|
for run in par.runs:
|
||||||
run.bold = True
|
run.bold = True
|
||||||
|
|||||||
Reference in new issue
Block a user