def makeTextHyperlink(self, text, url, anchor=None) : rel_id = 0 if anchor == None : rel_id = self.files['word/_rels/document.xml.rels'].addRelation('hyperlink', url=url) hyperlink = Hyperlink(text, str(rel_id), url, anchor) self.doc.makeTextHyperlink(text, hyperlink.get()) if anchor != None : self.doc.addAnchorToText(url, anchor)
def addHyperlink(self, text, url, position='last', anchor=None) : rel_id = 0 if anchor == None : rel_id = self.files['word/_rels/document.xml.rels'].addRelation('hyperlink', url) paraElement = Paragraph().get() hyperlink = Hyperlink(text, str(rel_id), url, anchor) paraElement.append(hyperlink.get()) self.doc.addElement(paraElement, position)