Thursday, 4 November 2021

Python merge pdfs without compression

I want to merge a number of pdfs into one pdf using python, but the method I use right now seems to compress the output:

from pathlib import Path
import PyPDF2

merged_object = PyPDF2.PdfFileMerger()

for file_item in list_of_pdfs:
    if Path(file_item).suffix != '.pdf':
        file_item = f'{file_item}.pdf'
    merged_object.append(PyPDF2.PdfFileReader(str(file_item)))

merged_object.write(str(directory))

I haven't been able to find a way to merge pdfs compressionless, any solutions?



from Python merge pdfs without compression

No comments:

Post a Comment