Default-section page footer carrying a line of text, referenced from sectPr/footerReference.
Library verdicts: python-docx: — docxjs: pass
| Feature id | docx/page-footer |
|---|---|
| Format | docx |
| Category | page-layout |
| Spec | ecma-376-5-part-1 § 17.10.1 w:footerReference |
| ID / part | Predicate | XPath | python-docx | docxjs |
|---|---|---|---|---|
footerReference-presentword/document.xml | existThe section must carry a default-type footerReference. | //w:sectPr/w:footerReference[@w:type='default'] | — | — |
footer-text-presentword/footer1.xml | existThe footer part must carry the expected text in a run. | //w:p/w:r/w:t[normalize-space()='Document footer text'] | — | — |
| ID | Predicate | Selector | python-docx | docxjs |
|---|---|---|---|---|
footer-element-rendered | css_selector/ match-text = Document footer textA renderer-exposed footer container (footer / .docx-footer / [data-part='footer']) must contain the footer text. | .docx-wrapper footer, .docx-wrapper .docx-footer, .docx-wrapper [data-part='footer'] | — | pass |
scripts/gen_page_footer.py
#!/usr/bin/env python3
"""Generate ``fixtures/docx/page-footer.docx``.
A minimal document exercising the default-section page footer. The
footer carries a single text line; the body carries an unrelated
paragraph. python-docx emits the footer as ``word/footer1.xml``.
Designed to satisfy the assertions in ``features/docx/page-footer.json``.
"""
from __future__ import annotations
from pathlib import Path
from docx import Document
_REPO_ROOT = Path(__file__).resolve().parent.parent
_OUT = _REPO_ROOT / "fixtures" / "docx" / "page-footer.docx"
def main() -> int:
doc = Document()
section = doc.sections[0]
footer = section.footer
footer.paragraphs[0].text = "Document footer text"
doc.add_paragraph("Body paragraph one")
_OUT.parent.mkdir(parents=True, exist_ok=True)
doc.save(_OUT, reproducible=True)
print(_OUT)
return 0
if __name__ == "__main__":
raise SystemExit(main())
{
"$schema": "../manifest.schema.json",
"id": "docx/page-footer",
"title": "Page footer",
"format": "docx",
"category": "page-layout",
"summary": "Default-section page footer carrying a line of text, referenced from sectPr/footerReference.",
"spec": {
"source": "ecma-376-5-part-1",
"clause": "17.10.1",
"element": "w:footerReference",
"rnc_reference": "spec/ecma-376-5/part-1/rnc/WordprocessingML.rnc",
"xsd_reference": "spec/ecma-376-5/part-1/xsd/wml.xsd",
"notes": "A page footer is a separate part (<w:ftr>) reached via <w:footerReference w:type=\"default\" r:id=\"rIdN\"/> inside <w:sectPr>. python-docx emits the part as word/footer1.xml."
},
"fixtures": {
"machine": "docx/page-footer",
"office": "docx/page-footer"
},
"generator": {
"python": "scripts/gen_page_footer.py"
},
"assertions": [
{
"id": "footerReference-present",
"part": "word/document.xml",
"namespaces": {
"w": "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
"r": "http://schemas.openxmlformats.org/officeDocument/2006/relationships"
},
"xpath": "//w:sectPr/w:footerReference[@w:type='default']",
"must": "exist",
"description": "The section must carry a default-type footerReference."
},
{
"id": "footer-text-present",
"part": "word/footer1.xml",
"namespaces": {
"w": "http://schemas.openxmlformats.org/wordprocessingml/2006/main"
},
"xpath": "//w:p/w:r/w:t[normalize-space()='Document footer text']",
"must": "exist",
"description": "The footer part must carry the expected text in a run."
}
],
"render_assertions": [
{
"id": "footer-element-rendered",
"kind": "css_selector",
"selector": ".docx-wrapper footer, .docx-wrapper .docx-footer, .docx-wrapper [data-part='footer']",
"must": "match-text",
"value": "Document footer text",
"description": "A renderer-exposed footer container (footer / .docx-footer / [data-part='footer']) must contain the footer text."
}
]
}
