Example #1
0
def build_c_run(c, para, run):
    c_run_el = para._element._new_r()
    run._element.addnext(c_run_el)
    c_run = Run(c_run_el, run._parent)
    c_run.text = c
    c_run.style = run.style
    c_run.italic = run.italic
    c_run.bold = run.bold
    c_run.underline = run.underline
    c_run.font.name = run.font.name
    c_run.font.size = run.font.size
    return c_run
Example #2
0
 def addToDoc(self, run: Run):
     #img = Image.open(replace)
     #img_with_border = ImageOps.expand(img, border=1, fill='black')
     #imgByteArr = BytesIO()
     #img_with_border.save(imgByteArr, format='PNG')
     #replace = imgByteArr
     try:
         run.text = run.text.replace(search, "")
         run.add_picture(self.path, width=self.width)
     except Exception as e:
         print(f"Error adding picture, {self.path}")
         print(e)