@dp.message_handler(content_types=['document'])
async def send_document(message: types.Message):
folder = pathlib.Path(path).resolve()
for item in folder.iterdir():
if item.is_file() and item.suffix == '.pdf' and not item.name == 'wtr.pdf':
with open(f'{item}', 'rb') as file, open('wtr.pdf', 'rb') as wtr:
input_file_reader = PyPDF2.PdfFileReader(file)
wtr_reader = PyPDF2.PdfFileReader(wtr)
wtr_page = wtr_reader.getPage(0)
output = PyPDF2.PdfFileWriter()
for i in range(input_file_reader.numPages):
page = input_file_reader.getPage(i)
page.mergePage(wtr_page)
output.addPage(page)
with open(f'merged_{item.name}', 'wb') as merged_file:
output.write(merged_file)
await bot.send_document(chat_id = message.from_user.id, document = merged_file)
Допущена ошибка в await bot.send_document(chat_id = message.from_user.id, document = merged_file)
А конкретнее документ не правильный, что надо вписать вместо merged_file?