elapouya / python-docx-template

Use a docx as a jinja2 template
GNU Lesser General Public License v2.1
1.91k stars 378 forks source link

How can I add RichText to a run? #454

Open cristianoccazinsp opened 1 year ago

cristianoccazinsp commented 1 year ago

Trying to do something as follows:

res = tpl.new_subdoc()
current_p = res.add_paragraph()

rt = RichText("")
rt.add(ele[0], url_id=tpl.build_url_id(ele[1]))
r = current_p.add_run(line)
r.add_text(rt)

But I'm unable to add rich text to an existing run. Basically, I'm trying to add rich text to a subdoc.

Any ideas?

elapouya commented 1 year ago

Rtfm

Le ven. 5 août 2022 à 20:52, Cristiano Coelho @.***> a écrit :

Trying to do something as follows:

res = tpl.new_subdoc() current_p = res.add_paragraph()

rt = RichText("") rt.add(ele[0], url_id=tpl.build_url_id(ele[1])) r = current_p.add_run(line) r.add_text(rt)

But I'm unable to add rich text to an existing run. Basically, I'm trying to add rich text to a subdoc.

Any ideas?

— Reply to this email directly, view it on GitHub https://github.com/elapouya/python-docx-template/issues/454, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGY33EN2KWIF5DKF2IXBIDVXVPHHANCNFSM55W7CPCA . You are receiving this because you are subscribed to this thread.Message ID: @.***>