ImagesToPdf is a Python script combined with a shell script to convert images to a PDF and recover corrupted PDFs.
- Convert Images to PDF: Converts
.webp,.jpeg, and.jpgimages in a specified directory into a single PDF file. - Recover Corrupted PDF: Merges a potentially corrupted PDF with a valid PDF to recover the contents using Ghostscript.
- Python 3.6 or higher
Pillowlibraryghostscript(for PDF recovery)
-
Clone the repository:
git clone https://github.com/yourusername/ImagesToPdf.git
-
Navigate to the project directory:
cd ImagesToPdf
Install the required Python dependencies:
pip install pillow
Install Ghostscript for PDF recovery:
-
On Ubuntu/Debian:
sudo apt-get install ghostscript -
On macOS:
brew install ghostscript
Convert Images to PDF
-
Edit the directory_path in imageToPdf.py to specify the directory containing your images.
-
Run the Python script to convert images to a PDF:
python imageToPdf.py
This will generate images1.pdf in the specified directory.
-
Ensure you have images.pdf (the potentially corrupted PDF) in the same directory.
-
Run the shell script to recover the corrupted PDF:
bash join.sh
This will create output.pdf, which attempts to recover the contents from images.pdf and creates new file as recovered.pdf.
To convert images in the Documents directory:
python imageToPdf.py
To recover a corrupted PDF:
bash join.sh
Feel free to open issues or submit pull