Skip to content

Latest commit

 

History

History
259 lines (198 loc) · 5.41 KB

File metadata and controls

259 lines (198 loc) · 5.41 KB

PDF Editor - Quick Start Guide

Get up and running with the PDF Editor in 5 minutes!

Prerequisites

  • Docker Desktop installed and running
  • Git (to clone the repository)

1. Clone and Start

# Clone the repository
git clone <repository-url>
cd pdf_editor_project

# Start all services
docker-compose up -d

# Wait for services to be healthy (30-60 seconds)
docker-compose ps

2. Verify Installation

# Check backend health
curl http://localhost:5000/health

# Expected response:
# {"status":"healthy","database":"connected","redis":"connected"}

3. Create Your First User

curl -X POST http://localhost:5000/api/auth/register \
  -H "Content-Type: application/json" \
  -d '{
    "username": "demo",
    "email": "demo@example.com",
    "password": "demo123"
  }'

Save the access_token from the response!

4. Upload a PDF

# Set your token
export TOKEN="your_access_token_here"

# Upload a PDF
curl -X POST http://localhost:5000/api/upload \
  -H "Authorization: Bearer $TOKEN" \
  -F "file=@your_document.pdf"

Save the document id from the response!

5. Try Some Operations

Rotate PDF

export DOC_ID="your_document_id"

curl -X POST http://localhost:5000/api/rotate \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d "{
    \"document_id\": \"$DOC_ID\",
    \"rotation\": 90,
    \"pages\": \"all\"
  }"

Add Watermark

curl -X POST http://localhost:5000/api/watermark \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d "{
    \"document_id\": \"$DOC_ID\",
    \"text\": \"CONFIDENTIAL\",
    \"opacity\": 0.3,
    \"position\": \"diagonal\"
  }"

Compress PDF

curl -X POST http://localhost:5000/api/compress \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d "{
    \"document_id\": \"$DOC_ID\",
    \"quality\": \"medium\"
  }"

6. View Your Documents

# List all documents
curl -X GET http://localhost:5000/api/documents \
  -H "Authorization: Bearer $TOKEN"

# Get document stats
curl -X GET http://localhost:5000/api/documents/stats \
  -H "Authorization: Bearer $TOKEN"

7. Download Results

# Download a document
curl -X GET http://localhost:5000/api/documents/$DOC_ID/download \
  -H "Authorization: Bearer $TOKEN" \
  -o result.pdf

Common Commands

View Logs

# Backend logs
docker-compose logs -f backend

# All services
docker-compose logs -f

Restart Services

# Restart all
docker-compose restart

# Restart specific service
docker-compose restart backend

Stop Services

docker-compose down

Rebuild After Changes

docker-compose up -d --build

Troubleshooting

Port Already in Use

Edit docker-compose.yml and change the external ports:

ports:
  - "5555:5000"  # Change 5555 to another port

Services Not Starting

# Check Docker is running
docker ps

# Check logs for errors
docker-compose logs backend
docker-compose logs db

Database Issues

# Reset database
docker-compose down -v
docker-compose up -d

Next Steps

  1. Read the API Documentation for all available endpoints
  2. Try the Testing Guide for comprehensive examples
  3. Check Implementation Summary for feature details
  4. Explore the README for full documentation

Quick Reference

Service URLs

Default Credentials

  • Database: postgres/postgres
  • No default user - create via registration

File Limits

  • Max upload size: 100MB
  • Supported formats: PDF, PNG, JPG, JPEG, GIF, BMP, TIFF

Example Workflow

#!/bin/bash

# Complete workflow example
TOKEN=$(curl -s -X POST http://localhost:5000/api/auth/register \
  -H "Content-Type: application/json" \
  -d '{"username":"quickstart","email":"quick@start.com","password":"pass123"}' \
  | jq -r '.access_token')

echo "Token: ${TOKEN:0:20}..."

# Upload two PDFs
DOC1=$(curl -s -X POST http://localhost:5000/api/upload \
  -H "Authorization: Bearer $TOKEN" \
  -F "file=@doc1.pdf" | jq -r '.document.id')

DOC2=$(curl -s -X POST http://localhost:5000/api/upload \
  -H "Authorization: Bearer $TOKEN" \
  -F "file=@doc2.pdf" | jq -r '.document.id')

echo "Uploaded: $DOC1, $DOC2"

# Merge them
MERGED=$(curl -s -X POST http://localhost:5000/api/merge \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d "{\"document_ids\":[\"$DOC1\",\"$DOC2\"]}" \
  | jq -r '.document.id')

echo "Merged: $MERGED"

# Add watermark
FINAL=$(curl -s -X POST http://localhost:5000/api/watermark \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d "{\"document_id\":\"$MERGED\",\"text\":\"FINAL\",\"opacity\":0.3}" \
  | jq -r '.document.id')

echo "Final document: $FINAL"

# Download
curl -X GET http://localhost:5000/api/documents/$FINAL/download \
  -H "Authorization: Bearer $TOKEN" \
  -o final_result.pdf

echo "Done! Check final_result.pdf"

Support

  • Check logs: docker-compose logs -f
  • View health: curl http://localhost:5000/health
  • Database status: docker exec -it pdf_editor_db psql -U postgres -d pdfeditor
  • Redis status: docker exec -it pdf_editor_redis redis-cli ping

Happy PDF editing! 🎉