pdfoutput close(passing 'wbto open(opens the output pdf fileallminutes pdfin writebinary mode thenpassing the resulting file object to the write(method creates the actual pdf file call to the close(method finishes the program ideas for similar programs being able to create pdfs from the pages of other pdfs will let you make programs that can do the followingcut out specific pages from pdfs reorder pages in pdf create pdf from only those pages that have some specific textidentified by extracttext(word documents python can create and modify word documentswhich have the docx file extensionwith the docx module you can install the module by running pip install --user - python-docx=(appendix has full details on installing third-party modules note when using pip to first install python-docxbe sure to install python-docxnot docx the package name docx is for different module that this book does not cover howeverwhen you are going to import the module from the python-docx packageyou'll need to run import docxnot import python-docx if you don' have wordlibreoffice writer and openoffice writer are free alternative applications for windowsmacosand linux that can be used to open docx files you can download them from organd python-docx is available at is version of word for macosthis will focus on word for windows compared to plaintextdocx files have lot of structure this structure is represented by three different data types in python-docx at the highest levela document object represents the entire document the document object contains list of paragraph objects for the paragraphs in the document ( new paragraph begins whenever the user presses enter or return while typing in word document each of these paragraph objects contains list of one or more run objects the single-sentence paragraph in figure - has four runs plain paragraph with some bold and some italic run run run figure - the run objects identified in paragraph object run