Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

docx change font python

import docx
document = docx.Document()
run = document.add_paragraph().add_run()
'''Apply style'''
style = document.styles['Normal']
font = style.font
font.name = 'MS Gothic'
font.size = docx.shared.Pt(15)
paragraph = document.add_paragraph('Some text
')
'''Add another sentence to the paragraph'''
sentence = paragraph.add_run('A new line that should have a different font')
'''Then format the sentence'''
sentence.font.name = 'Arial'
sentence.font.size = docx.shared.Pt(10)
Comment

PREVIOUS NEXT
Code Example
Python :: how to use regex in a list 
Python :: python choose sample from list with replacement 
Python :: how to return an html file in flask 
Python :: dunder pyhton 
Python :: how to import date python 
Python :: python change terminal name 
Python :: python random integer in range 
Python :: create an empty dataframe 
Python :: python: calculate number of days from today date in a data frame 
Python :: df.select_dtypes 
Python :: fastest clicker python 
Python :: Prime numbers within given range in python 
Python :: packing and unpacking in python 
Python :: tkinter messagebox 
Python :: cannot safely cast non-equivalent float64 to int64 
Python :: python read pdf 
Python :: swapping of two numbers in python 
Python :: path of current working directory with os module python 
Python :: handle queries in listview django 
Python :: read specific rows from csv in python 
Python :: how to download nltk in python 
Python :: python sentence splitter 
Python :: python requests post 
Python :: how to install whl file in python 
Python :: named tuple python iterate 
Python :: how to iterate over rows in a dataframe in pandas 
Python :: pandas count number missing values 
Python :: python logger get level 
Python :: calculate age python 
Python :: intersection between two arrays using numpy 
ADD CONTENT
Topic
Content
Source link
Name
4+6 =