converting multipage tiff to pdf python
$ img2pdf img1.png img2.jpg -o out.pdf
converting multipage tiff to pdf python
$ img2pdf img1.png img2.jpg -o out.pdf
converting multipage tiff to pdf python
for i in....
# Create one pdf file per tiff file
with open(str(i) + '.pdf', "wb") as f, io.BytesIO() as output:
img = PIL.Image.open(str(i) + '.tiff')
img.save(output, format='tiff')
f.write(img2pdf.convert(output.getvalue()))
# merge the pdf file into one output pdf file
pdf_writer = PdfFileWriter()
output_file = publication_number + ".pdf"
file_list = os.listdir()
pdf_list = []
for file in file_list:
if file.endswith(".pdf"):
pdf_list.append(file)
pdf_list.sort(key=lambda f: int(
''.join(filter(str.isdigit, f)))) # trier la liste d'image du plus petit au plus grand (et pas 1, 10, 11, 2, 3)
for pdf_file in pdf_list:
pdf_reader = PdfFileReader(pdf_file)
for page in range(pdf_reader.getNumPages()):
pdf_writer.addPage(pdf_reader.getPage(page))
with open(output_file, 'wb') as fh:
pdf_writer.write(fh)
for i in range(1, max_page + 1):
os.remove(str(i) + '.tiff')
os.remove(str(i) + '.pdf')
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us