I am trying to deep copy contents from source.docx file to output.docx file. However, I am not getting exact paragraph style in destination document especially bullet list and number list is not getting displayed with text content.
My source.docx is having multiple paragraphs like Normal, number list and bullet list. However, the problem is I get paragraph style as 'List Paragraph' for both numbered list and bulleted list and due to this I am not able to print some content in my output.docx. In my below code: its not executing both if conditions and control is going in else only. How can I distinguish between bullet and number list in python?
import docx
my_doc = docx.Document()
source_doc = docx.Document('source.docx')
for paragraph in source_doc.paragraphs:
if paragraph.style.name==('List Paragraph'):
if new_paragraph.style == 'List Bullet':
new_paragraph.style = my_doc.styles['List Bullet']
if new_paragraph.style == 'List Number':
new_paragraph.style = my_doc.styles['List Number']
else:
new_paragraph.style = my_doc.styles['List Bullet']