Skip to content

Phase D.27: DrawingML shapes and text box content access #40

@loadfix

Description

@loadfix

Add read access to text inside DrawingML shapes, text boxes, and other drawing elements.

Problem

Text inside shapes/text boxes/diagrams is currently invisible to python-docx. paragraph.text and document.paragraphs skip over drawing elements entirely.

API Design

  • paragraph.drawings — list of Drawing objects found in the paragraph
  • Drawing.text — concatenated text from all text frames in the drawing
  • Drawing.paragraphs — list of Paragraph objects inside the drawing's text frame
  • Drawing.type — shape, text_box, group, chart, diagram

XML

  • w:drawing > wp:inline or wp:anchor > a:graphic > a:graphicData
  • Text in shapes: wps:wsp > wps:txbx > w:txbxContent > w:p (regular paragraphs)

Read-only is sufficient for now. Write support would be a separate issue.

Upstream: python-openxml#380 (8 comments)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestphase-dQuality of Life

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions