def pdf_merge(inputs: [str], output: str, delete: bool = False):
writer = PdfFileWriter()<EOL>if os.path.isfile(output):<EOL><INDENT>ans = input(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>" % output<EOL>).lower()<EOL>if ans == "<STR_LIT:a>":<EOL><INDENT>return<EOL><DEDENT><DEDENT>outputfile = open(output, "<STR_LIT:wb>")<EOL>try:<EOL><INDENT>infiles = []<EOL>for filename in inputs:<EOL><INDENT>f = open(filename, "<STR_LIT:rb>")<EOL>reader = PdfFileReader(f)<EOL>for page in reader.pages:<EOL><INDENT>writer.addPage(page)<EOL><DEDENT>infiles.append(f)<EOL><DEDENT>writer.write(outputfile)<EOL><DEDENT>except FileNotFoundError as e:<EOL><INDENT>print(e.strerror + "<STR_LIT>" + e.filename)<EOL><DEDENT>finally:<EOL><INDENT>outputfile.close()<EOL>for f in infiles:<EOL><INDENT>f.close()<EOL><DEDENT><DEDENT>if delete:<EOL><INDENT>for filename in inputs:<EOL><INDENT>os.remove(filename)<EOL><DEDENT><DEDENT>
Merge multiple Pdf input files in one output file.
:param inputs: input files
:param output: output file
:param delete: delete input files after completion if true