A collection of command-line tools for working with PDF files.
Extract the first page from multiple PDF files and combine them into a single PDF.
Add customizable page numbers to PDF files with different positioning options.
- Python 3.6 or higher
- PyMuPDF
- PyPDF2
- reportlab (for test PDF generation)
# Clone the repository
git clone https://github.com/1a1a11a/pdf_tools.git
cd pdf_tools
# Install dependencies
pip install -r requirements.txtThis tool extracts the first page from each input PDF file and combines them into a single output PDF.
python extract_first_page.py -o output.pdf input1.pdf input2.pdf input3.pdfYou can also use a directory containing PDF files:
python extract_first_page.py -o output.pdf path/to/pdf/directoryOptions:
-o, --output: Output PDF file path (required)inputs: One or more input PDF files or directories (required)-v, --verbose: Enable verbose output
This tool adds page numbers to one or more PDF files.
python add_pagenumber.py -i input.pdf -o output.pdfYou can also process an entire directory:
python add_pagenumber.py -i input_directory -o output_directoryOptions:
-i, --input: Input PDF file or directory (required)-o, --output: Output PDF file or directory (required)-p, --position: Position of page numbers (choices: bottom, top, bottomright, bottomleft, topright, topleft; default: bottom)-f, --font: Font to use for page numbers (default: helv)-s, --size: Font size in points (default: 12)-v, --verbose: Enable verbose output--open: Open the output PDF file(s) when done
Extract first pages from a directory:
python extract_first_page.py -o combined_first_pages.pdf -v ~/Documents/PDFs/Add page numbers to bottom right of PDFs:
python add_pagenumber.py -i ~/Reports/ -o ~/Reports/Numbered/ -p bottomright -s 10 -vMIT License
Created by Juncheng