Hi, I am facing problem in formatting Docx file using python docx library.
I am able to replace some paragraph text but not able to maintain text font 
and font weight. Below is the pseudo code for this 

from docx import Document

# read doc file
doc = Document(file name)

# now I need to replace few words in a paragraph,(lets say I want to 
replace a key in the paragraph by val) and paragraph index (pid) is known.

paragraph = doc.paragraphs[int(pid)].text

para = re.sub(key, val, paragraph.rstrip())  
doc.paragraphs[pid].text = para

# So after saving this document, now I can see replaced text in the file 
but not able to maintain the font. I mean, earlier common font in the file 
was "Times New Roman" but after text replacement paragraph font and weight 
is different.

I want to maintain the fort "Times New Roman" in the document. How to do 
that?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to