sync chunk 11/12
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
from pathlib import Path
|
||||
import sys
|
||||
from docx import Document
|
||||
from docx.oxml.ns import qn
|
||||
|
||||
|
||||
def inspect_docx(path: Path) -> None:
|
||||
doc = Document(path)
|
||||
print(f"DOCX {path}\nparagraphs={len(doc.paragraphs)} tables={len(doc.tables)} shapes={len(doc.inline_shapes)}")
|
||||
for i, para in enumerate(doc.paragraphs):
|
||||
text = para.text.strip()
|
||||
if text:
|
||||
style = getattr(para.style, "name", "") or ""
|
||||
drawings = para._p.xpath(".//w:drawing")
|
||||
rels = para._p.xpath(".//a:blip/@r:embed")
|
||||
print(f"P{i}|{style}|drawings={len(drawings)}|rels={','.join(rels)}|{text}")
|
||||
for i, table in enumerate(doc.tables):
|
||||
print(f"TABLE {i} {len(table.rows)}x{len(table.columns)}")
|
||||
for row in table.rows:
|
||||
print(" | ".join(cell.text.replace("\n", " / ") for cell in row.cells))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
inspect_docx(Path(sys.argv[1]))
|
||||
Reference in New Issue
Block a user