Skip to content

Phase D.22: SVG image support #35

@loadfix

Description

@loadfix

Add support for inserting SVG images into documents.

Challenges

  • Word uses a dual representation: SVG in mc:AlternateContent with a PNG/EMF fallback
  • The SVG is stored as a separate part (image/svg+xml)
  • The fallback raster image must be generated or provided by the caller

API Design

  • document.add_picture(svg_path) — detect SVG, create both SVG part and fallback
  • Options: provide explicit fallback image, or auto-generate using cairosvg/rsvg if available
  • InlineShape.image should return the SVG data when the image is an SVG

XML

mc:AlternateContent > mc:Choice (with a16sv3:svgBlip) + mc:Fallback (with standard a:blip to raster)

Upstream: python-openxml#351, python-openxml#651, python-openxml#798 (12+8+6 = 26 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