A simple Python Script to generate PDF using Images and vice-versa.
- Create a virtual environment
$ python3 -m venv /path/to/new/virtual/env - Install required packages using
$ pip install -r requirements.txtfor Python2 and$ pip3 install -r requirements.txtfor Python3
- Change
output_filename.pdfwith the name of the output pdf file you want os.listdir('.')points to the present working directory, change it toos.listdir('the/directory/path/where/you/want/to/get/images/from')- Change
i.endswith(".jpg")to your desired input image format
- Change
input_filename.pdfto the name of the file you want to convert to images - Change
output_images_folder_name/output_page_{}.jpgtofolder_name_that_stores_the_output_images/output_image_name_{}.jpg {}should not be removed if you want to store the page no. with the output image name so that you don't loose track of different pages