#list numberedList = document.addList('first') numberedList.addItem('piet') numberedList.addItem('henk') numberedList.addItem('Jan') numberedList.addItem('Klaas', level=1) numberedList.addItem('Rene', level=1) numberedList.addItem('Frits') numberedList.addItem('Bert') document.closeList(numberedList) document.addImage('image.jpg', width='20%', height='20%', url='http://www.nu.nl') document.addHeader('Header tekst') document.addFooter('Footer tekst') document.save("test1.docx", readOnly=True) """ NEW DOCUMENT WITH NO INPUT FILE, CREATING FROM SCRATCH """ #creating complete file document = Document() #paragraph document.addParagraph("vanuit python toegevoegd onderaan", styles={'bold' : True, 'italic' : True, 'underline' : 'red', 'uppercase' : True, 'color' : 'red', 'font' : 'Times New Roman'}) document.addParagraph("vanuit python toegevoegd na klaas", 'aftertext:klaas', styles={'size' : 18}) #search and replace document.searchAndReplace("klaas", "jan")
numberedList.addItem('Frits') numberedList.addItem('Bert') document.closeList(numberedList) #add heading document.addParagraph("This file is created through python for testing", 'first', 'Heading1', styles={'bold' : True}) #add image to end of file document.addImage('image.jpg', position='first', width='10%', height='10%') document.addImage('image1.jpg', width='30%', height='30%', url='http://www.tweakers.net') #pagebreak document.insertBreak('page') document.addParagraph("vanuit python toegevoegd onderaan", styles={'bold' : True, 'italic' : True, 'underline' : 'red', 'uppercase' : True, 'color' : 'red', 'font' : 'Times New Roman'}) # adding headers document.addHeader('Header tekst even pages', 'even') document.addHeader('Header tekst odd pages', 'default') document.addFooter('Default footer text', 'default') document.addFooter('Different footer text', 'first') #search and replace on headers document.searchAndReplace("odd pages", "oneven paginas") document.searchAndReplace("even pages", "even paginas") #add anchor document.makeTextHyperlink("vanuit", "python", anchor='anker') document.save("test2.docx")