A simple python script that helps with doing simple stuff with PDFs. It is going to
become a simple python package after main.py
reaches 1000 lines of code.
- Merge PDFs: Merge multiple PDFs into one PDF
- Split PDFs: Split a PDF into multiple PDFs, each containing a range of pages from the original PDF
- Export as image: Export designated pages from a PDF as image files
- Remove pages: Remove designated pages from a PDF
- Encrypt a PDF
- Decrypt a PDF
- Add watermark to a PDF
- Extract images from a PDF
- Extract text: Export text from a PDF file and optionally save it to a text file
- Extract links from a PDF
- Image to PDF: Export one or multiple images as a PDF file
If you want any other feature to be added, feel free to open an issue or fork the repo and make a pull request after adding your contribution.
-
Install Python for your operating system. Visit python.org
-
Clone the repo:
git clone https://GitHub.com/MPCodeWriter21/PDF-Helper
- Use pip to install the dependencies:
pip install -r requirements.txt
Merge multiple PDFs into one PDF:
python3 main.py merge -i <input_file_1> <input_file_2>... <input_file_n> -o <output_file>
# E.g. Merge PDFs 1, 2 and 3 into a new PDF
python3 main.py merge -i 1.pdf 2.pdf 3.pdf -o new.pdf
Split a PDF into multiple PDFs, each containing a range of pages:
python3 main.py split -i <input_file> -o <output_folder> -s <split_point_1>,<split_point_2>
# E.g. Split a PDF into three PDFs, one with pages 1-10, the second with pages 11-20 and
# the third with pages 21-end
python3 main.py split -i my-pdf.pdf -o my-split-pdfs -s 10,20
# E.g. Split a PDF into PDFs each containing one page
python3 main.py split -i my-pdf.pdf -o my-split-pdfs # No need to specify split points
Export PDF pages as image files:
python3 main.py to-image -i <input_file> -o <output_folder> \
-p <page_number_1>,<page_number_2>,...,<page_number_n> -s <scale_factor>
# E.g. Export pages 1, 2, 3 and 6 from a PDF with scale factor 1
python3 main.py to-image -i 1.pdf -o images -p 1-3,6 -s 1
# E.g. Export all pages from a PDF with scale 2
python3 main.py to-image -i my-pdf.pdf -o my-images
Remove pages from a PDF:
python3 main.py remove-pages -i <input_file> -o <output_file> -p <page_number_1>,<page_number_2>,...,<page_number_n>
# E.g. Remove pages 1, 2, 3 and 6 from a PDF
python3 main.py remove-pages -i 1.pdf -o new.pdf -p 1-3,6
To extract text from a PDF file and export them to text files you can do as follows:
python3 main.py extract-text -i <input_file> -o <output_file_name>
# E.g. Extract text from a PDF named my-pdf.pdf and save it to my-text.txt
python3 main.py extract-text -i my-pdf.pdf -o my-text.txt
You simply provide the script with your images, and it will create a PDF file with them:
python3 main.py image-to-pdf -i <image_1> <image_2> <image_3> ... -o <output_file>
# E.g. Take 1.png, 2.jpg, and 3.png and create a PDF named 123.pdf and override
# if already exists
python3 main.py image-to-pdf -i 1.png 2.jpg 3.png -o 123.pdf -f
Author: CodeWriter21
GitHub: MPCodeWriter21/PDF-To-Image
Your donations are very welcome: nowpayments.io
You can also consider donating a Star to the repo.
This project is licensed under the MIT License.
See the LICENSE