feature: Paragraph.add_hyperlink()
See original GitHub issueProtocol might be something like this:
>>> hyperlink = paragraph.add_hyperlink(text='foobar', url='http://github.com')
>>> hyperlink
<docx.text.Hyperlink instance at 0xdeadbeef1>
>>> hyperlink.url
'http://github.com'
>>> hyperlink.text
'foobar'
XML specimen:
<w:p>
<w:r>
<w:t xml:space="preserve">This sentence has a </w:t>
</w:r>
<w:hyperlink r:id="rId5" w:history="1">
<w:r>
<w:rPr>
<w:rStyle w:val="Hyperlink"/>
</w:rPr>
<w:t>hyperlink</w:t>
</w:r>
</w:hyperlink>
<w:r>
<w:t xml:space="preserve"> in it.</w:t>
</w:r>
</w:p>
Issue Analytics
- State:
- Created 9 years ago
- Reactions:5
- Comments:51 (6 by maintainers)
Top Results From Across the Web
Hyperlink | Documents for Word, .NET Edition
Load("AddHyperlink.docx"); //Modify the hyperlink code Hyperlink link1 = doc.Body.Sections.First.GetRange().Paragraphs.First.GetRange().Hyperlinks.
Read more >MigraDoc Sample: Hello MigraDoc
This sample shows various features of MigraDoc including table of contents, ... all styles and paragraphs that do not redefine the font.
Read more >Adding links to pdf by using MigraDoc
I tried to use AddHyperlink() for adding link, and it was the first step for this. The code below shows correct using: var...
Read more >Working with Actions in PDF
Add Hyperlink in a PDF File ... It also offers the feature to add links to PDF pages and a link can either...
Read more >Add hyperlinks to a location within the same document
Mark the hyperlink destination with a bookmark or a heading style. Insert a bookmark. Select text or an item, or click where you...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@posterberg I don’t know how to make a workaround that returns a run, but I have improved the current one to take the color and underline as arguments.
Here are the steps I took to change the text color, in case you need to add other properties:
word/folder in the unzipped archive and opendocument.xml<w:color w:val="FF8822"/>inside the<w:rPr>element. (Side note: rPr stands for “run Properties”)rPr.Here is the updated workaround with control of color and underlining:
This function is the hyperlink equivalent of duct tape: It get the job done, but becomes harder to use when the complexity of the task increases.
The workaround didn’t work for me. I had to modify it to insert the hyperlink directly into the paragraph: