docx.heading('Editing documents', 2) docx.paragraph('Thanks to the awesomeness of the lxml module, ' 'we can:') points = [ 'Search and replace' , 'Extract plain text of document' , 'Add and delete items anywhere within the document' ] for point in points: docx.paragraph(point, style='ListBullet') # Add an image docx.picture('image2.png', 'This is a test description') # Search and replace print 'Searching for something in a paragraph ...', if docx.search('the awesomeness'): print 'found it!' else: print 'nope.' print 'Searching for something in a heading ...', if docx.search('200 lines'): print 'found it!' else: print 'nope.' print 'Replacing ...', docx.replace('the awesomeness', 'the goshdarned awesomeness') print 'done.' # Add a pagebreak