Tools which Compare PDF files by stacking images
The comments in source codes is written in Japanese. This aplications are proto type. I plan to improve them gradually.
We execute aplications on virtual python environments.
- Windows
py -m venv .venv
.\.venv\Scripts\activate
python -m pip install --upgrade pip
- Linux
$ python -m venv .venv
$ source .venv/bin/activate
$ python -m pip install --upgrade pip
$ pip install --upgrade pymupdf
$ pip install --upgrade pillow
[Arguments]
- Required parametetrs
pdf1_path: Path to the first PDF filepdf2_path: Path to the second PDF file
- Optional Parameters
output_path: Custom output filename (defaults to "comparison_result.pdf")page_number: Specific page to compare (defaults to page 1)
- Verify the existence of both input PDF files
- Validate specified page numbers for availability
- Comprehensive bilingual error reporting (Japanese and English)
# Basic Execution
$ python main.py /path/to/input1.pdf /path/to/input1.pdf
# Specify the output path/file
$ python main.py /path/to/input1.pdf /path/to/input1.pdf /path/to/output.pdf
# Specify the pages for comparison
$ python main.py /path/to/input1.pdf /path/to/input1.pdf /path/to/output.pdf 1
Execute main.py with following arguments --help or -h
$ python main.py --help
or
$ python main.py -h
- Execute
getPDFImage.pyto save each page from PDF file as PNG image file
$ python3 getPDFImage.py
- Execute
ChangeImageColor.pyandchangeImageColorForStacking.pyto change the color of the image of comparison
$ python3 ChangeImageColor.py
$ python3 changeImageColorForStacking.py
- Execute
createDiffPDF.pyto create a PDF file of the comparison results
$ python3 createDiffPDF.py
The libraries used are as follows.
- How I created a PDF comparison tool : Article introducing the tool