I am using PyPDF2 to merge multiple pdf files and then use python shutil method to copy the output to the final destination and use smtplib to email a copy(as an attachment) to a user.
The merged files in the final destination is appearing correctly but the emailed copy(attachment) is not. Only fist item in an array is appearing but rest page is blank with correct total number of pages.
Here is my workflow
- Merge Files and save merged to local folder --- Working as expected
- Copy merged file to final destination --- Working as expected -
- Email a copy of merged file to user email address -- First file in an array, empty pages after that. The total number of pages matches with the total count.
I am using following code to merge files
pdf_list=['pdf_source.pdf','second_file.pdf','third_file.pdf']
for pdf in pdf_list:
merger.append(PdfFileReader(pdf),'rb')
with open(merge_file_name, 'wb') as new_file:
merger.write(new_file)
Please suggest