py-pdf / pdfly

CLI tool to extract (meta)data from PDF and manipulate PDF files
BSD 3-Clause "New" or "Revised" License
108 stars 18 forks source link

In the cat subcommand, replace the usage of the deprecated PdfMerger class from pypdf #31

Closed Lucas-C closed 11 months ago

Lucas-C commented 1 year ago

PdfMerger is used in the in the cat subcommand: https://github.com/py-pdf/pdfly/blob/main/pdfly/cat.py#L51

But this class is deprecated in pypdf since version 3.9.1: https://github.com/py-pdf/pypdf/releases/tag/3.9.1

We should replace it by combining PdfReader, its merge_page() method & PdfWriter from pypdf. An example of code using those can be found there: https://py-pdf.github.io/fpdf2/CombineWithPypdf.html

Extra unit tests could be added in the process in https://github.com/py-pdf/pdfly/blob/main/tests/test_cat.py in order to ensure that pdfly cat still works similarly as it currently does.