How to fix Python PdfMerger cropping pdf file?

18 Views Asked by At

I have the following functions:

def merge_pdfs(pdfs_append,output_folder = set_output_folder()):
    file_append = [] 
    for item in pdfs_append:
        file_append.append(os.path.basename(item))
    print("Merging File: {}...".format(' and '.join(file_append)))
    merger = PdfMerger()
    try:
        print("Appending pdfs...")
        for pdf in pdfs_append:
            merger.append(pdf)
        merger.write(os.path.join(output_folder,"result.pdf"))
        merger.close()
        print("File {} merged.".format(' and '.join(file_append)))
    except Exception as e:
        print("Appending pdfs failed.")
        print(e)

tried to merge 2 pdf at once, it ran well. However, the result.pdf change the page dimension or size. For example:

this is the result.pdf enter image description here

and this is the original page enter image description here

I didn't either zoom in / out in viewing documents. Just wondering why merger.append() crop the files and how to resolve this?

Thanks in advance!

0

There are 0 best solutions below