Backend API Documentation

The backend provides RESTful API endpoints for PDF processing operations.

Base URL

All API endpoints are prefixed with /api/pdf/

Endpoints

POST /api/pdf/merge

Merge multiple PDF files into one.

  • Body: FormData with multiple file0, file1, etc. fields
  • Response: PDF file download or JSON error

POST /api/pdf/split

Split a PDF into specific pages or page ranges.

  • Body: FormData with file0 and options (JSON string)
  • Options: { mode: 'pages'|'range', pages?: number[], startPage?: number, endPage?: number }
  • Response: PDF file download or JSON error

POST /api/pdf/pdf-to-images

Convert PDF pages to images (info only - actual conversion requires additional libraries).

  • Body: FormData with file0 and options
  • Options: { format?: 'png'|'jpg', dpi?: number }
  • Response: JSON with conversion info

POST /api/pdf/images-to-pdf

Convert images to a PDF document.

  • Body: FormData with multiple image files
  • Response: PDF file download or JSON error

POST /api/pdf/compress

Compress a PDF file (basic compression by re-saving).

  • Body: FormData with file0
  • Response: PDF file download or JSON error

POST /api/pdf/info

Get PDF metadata and information.

  • Body: FormData with file0
  • Response: JSON with PDF info

POST /api/pdf/protect

Add password protection to PDF (note: requires additional libraries).

  • Body: FormData with file0 and options
  • Options: { password: string }
  • Response: JSON message (protection not fully implemented)

POST /api/pdf/rotate

Rotate PDF pages by specified angle.

  • Body: FormData with file0 and options
  • Options: { angle: 90|180|270, pages?: number[] }
  • Response: PDF file download or JSON error

Error Handling

All endpoints return JSON error responses with { success: false, message: string } format when errors occur.

File Size Limits

  • Maximum file size: 50MB per file
  • Files are processed in memory and not stored permanently