To run the Python script for splitting a PDF into segments of just under 25MB each, you'll need to follow these steps:
Python Installation: Ensure that Python is installed on your system. If not, you can download and install it from python.org.
PyPDF2 Library: The script uses the PyPDF2 library. You can install it using pip, Python's package installer. If pip is not already installed, it comes bundled with Python 3.4 and later versions.
Open Terminal or Command Prompt: On Windows, you can open Command Prompt by searching for cmd in the Start menu. On macOS or Linux, open Terminal.
Install PyPDF2: Run the following command to install the PyPDF2 library:
pip install PyPDF2
Save the Script: Save the provided Python script to a file on your computer. Let's name it split_pdf_25MB.py.
Locate the PDF: Make sure you know the path of the PDF file you want to split and that it is accessible.
Open Terminal/Command Prompt in the Script's Directory:
On Windows: Navigate to the folder where split_pdf_25MB.py is saved using the cd command. For example, if it's saved in C:\Users\YourUsername\Documents, use cd C:\Users\YourUsername\Documents. On macOS/Linux: Use the cd command to navigate to the directory where the script is saved. Run the Script: Execute the script by typing:
python split_pdf_25MB.py
Follow the on-screen prompts to enter the filename and the output prefix.
The script will ask for the file name of the PDF and a prefix for the output files. Ensure the file name is correct and the file exists in the specified default directory (~/Desktop/mitta/). The output PDFs will be saved in the same directory as the input file, named with the provided prefix and indicating the page ranges. If you encounter any issues during installation or running the script, check for error messages in the command prompt or terminal, which can provide insights into what might be going wrong.