2

I merged multiple PDF files into one PDF file. After merged, I checked size of newly merged PDF file size is to much. I want to compress the PDF file size without losing quality. I wrote the following code to merge pdf files.

from PyPDF2 import PdfFileMerger

def merge_pdf(pdfs):
   merger = PdfFileMerger()

   for pdf in pdfs:
      merger.append(pdf)

   file = merger.write("C:\\Users\\ts1292\\Downloads\\result.pdf")
   print(file) 

  if __name__ == "__main__":
      pdfs = ["C:\\Users\\ts1292\\Downloads\\Sample1.pdf", "C:\\Users\\ts1292\\Downloads\\Sample2.pdf"]
      merge_pdf(pdfs=pdfs)

Could someone recommend me the way to merge files without losing quality?

Jan Christoph Terasa
  • 5,781
  • 24
  • 34
anu sharma
  • 21
  • 1
  • 2
  • 1
    Your question is ambiguous. In the title you ask for a way to **compress** PDF files without losing quality while in the last sentence you ask people recommend you a way to **merge** files without losing quality. What's your purpose finally? – xilopaint Feb 26 '19 at 11:21

0 Answers0