HOW TO Merge PDF Files (without uploading files to any Web Service)
When I had a need to merge 2 PDF files, I turned to my AI assistants to let me know the easiest options that won't require uploading my files to any Web Service.
The first option I liked was to use Microsoft Word which I have.
Here are the steps:
- Go to "Insert" tab in the Text Ribbon Group. Select "Object" and then the "Text from File" option. Select the first PDF.
- Repeat the process to insert the second PDF.
- Arrange the pages as needed.
- Save the document as a PDF.
This technique extracted the text with the same formatting as in the PDF but without the headers and footers.
As I wanted the headers, I decided to build my own Python program. ChatGPT generated the following Python script to merge PDFs using the GNU GPL v3 licensed PDF-handling library PyMuPDF (7.1k Stars). Install it using the command before running the script - pip install pymupdf
PyMuPDF (also known as fitz) is a powerful and fast GNU GPL v3 licensed PDF-handling library that supports merging along with advanced features like annotations, images, and text extraction.
PyMuPDF is fast and memory-efficient. It works well for large PDFs and you can also manipulate individual pages, images, and text later if needed.
You can also merge PDFs with Python using open-source libraries like PyPDF2, pypdf, or pdfmerger.

Comments
Post a Comment