scanny / python-pptx

Create Open XML PowerPoint documents in Python
MIT License
2.26k stars 498 forks source link

Hyper Link to external sources #951

Closed adumitrescu20 closed 4 months ago

adumitrescu20 commented 4 months ago

Hello, I am currently trying to manually change a powerpoint and send the file over an api request for a project, however when I try to hyperlink the sources in a shape like this:

run = paragraph.add_run() hlink = run.hyperlink hlink.type = "run" hlink.address = i["source"] add_text(run, i["source"]+ "\n", 8, "Calibri", True)

with the add text function being def add_text(run, text, font_size, font, bold): run.text = text run.font.size = Pt(font_size) run.font.name = font run.font.bold = bold

the problem is that this clearly hyperlinks the text as the font color changes to blue and is underlined, however I can not click and be redirected to the source at all, has this been encountered before by anyone/ am I setting the hyperlink wrong?

adumitrescu20 commented 4 months ago

The shapes I am trying to hyperlink text for are not in the presentation itself they are off to the side. My desire is to be able to click on the hyperlink when editing the ppt is that possible with ppt?

scanny commented 4 months ago

I believe hyperlinks are only active in slide-show mode.

This makes sense otherwise you wouldn't be able to select them when in edit mode :)