This project, pdf_utils_api, is a Django-powered API designed to streamline PDF manipulation. It currently offers two core services:
- Split: Splits a PDF file into individual PDFs, one per page.
- Merge: Combines multiple PDF files into a single consolidated PDF, maintaining the order of attachment.
IP_CLIENT_CORS=localhostPORT_CLIENT_CORS=3001
These environment variables configure Cross-Origin Resource Sharing (CORS) to permit requests from your frontend application (presumably running on localhost:3001).
- URL:
/split/ - Method:
POST - Request:
pdf_file(in form-data) - The PDF file to be split.
- Response: A
.zipfile containing the split PDFs.
- URL:
/merge/ - Method:
POST - Request:
pdf_files(multiple files in form-data) - The PDF files to be merged.
- Response: A single merged PDF file.
-
Clone the repository:
git clone https://github.com/peluza/pdf_utils_api.git cd pdf_utils_api -
Install dependencies:
pip install -r requirements.txt
-
Set environment variables:
export IP_CLIENT_CORS=localhost export PORT_CLIENT_CORS=3001
Our .env file
IP_CLIENT_CORS=localhost PORT_CLIENT_CORS=3001
-
Start the development server:
python manage.py runserver
Your API should now be accessible at http://127.0.0.1:8000/.
Notes
- Ensure you have the necessary PDF manipulation libraries installed (e.g., PyPDF2).
- Adjust the CORS settings if your frontend is hosted on a different domain or port.