def pdf_copy(input: str, output: str, pages: [int], yes_to_all=False):
if not os.path.isfile(input):<EOL><INDENT>print("<STR_LIT>" % input)<EOL>return<EOL><DEDENT>if os.path.isfile(output) and not yes_to_all and not overwrite_dlg(output):<EOL><INDENT>return<EOL><DEDENT>with open(input, "<STR_LIT:rb>") as inputfile:<EOL><INDENT>reader = PdfFileReader(inputfile)<EOL>outputfile = open(output, "<STR_LIT:wb>")<EOL>writer = PdfFileWriter()<EOL>if pages is None:<EOL><INDENT>pages = range(len(reader.pages))<EOL><DEDENT>else:<EOL><INDENT>pages = parse_rangearg(pages, len(reader.pages))<EOL><DEDENT>for pagenr in sorted(pages):<EOL><INDENT>page = reader.getPage(pagenr)<EOL>writer.addPage(page)<EOL>writer.write(outputfile)<EOL><DEDENT>outputfile.close()<EOL><DEDENT>
Copy pages from the input file in a new output file.
:param input: name of the input pdf file
:param output: name of the output pdf file
:param pages: list containing the page numbers to copy in the new file