python-pptx icon indicating copy to clipboard operation
python-pptx copied to clipboard

How to change the color of hyperlink text?

Open 602303068 opened this issue 3 years ago • 5 comments

How do I change the color of hyperlink text? Now add a hyperlink and use color The RGB setting has no effect. It is always the default blue color

602303068 avatar Jun 20 '22 07:06 602303068

I can't find the answer to this question either

gradinarnn avatar May 06 '23 19:05 gradinarnn

Color written in the xml. Previewed with the correct color, wrong after open the pptx. Need help, thanks.

parkernode avatar Nov 09 '23 12:11 parkernode

Post the minimum reproducible example of the code you used that's not behaving as you expect. https://stackoverflow.com/help/minimal-reproducible-example

scanny avatar Nov 09 '23 17:11 scanny

Hyperlink color and underline not work, still default blue. hyperlink has no font property. Python version: 3.11.4 python-pptx: 0.6.23

prs = Presentation() blank_slide_layout = prs.slide_layouts[6] slide = prs.slides.add_slide(blank_slide_layout)

txBox = slide.shapes.add_textbox(Inches(1), Inches(1), Inches(8), Inches(1)) tf = txBox.text_frame

p = tf.paragraphs[0] r = p.add_run() r.text = "Test test."

hlink = r.hyperlink hlink.address='http://www.github.com'

font = r.font font.size = Pt(20) font.color.rgb = RGBColor(0, 255, 0) font.underline = False

prs.save('test.pptx')

parkernode avatar Nov 10 '23 01:11 parkernode

Hmm, post what you get from print(r.xml) placed just before prs.save() and lets have a look at that ...

scanny avatar Nov 10 '23 17:11 scanny