Skip to content

SupaMafia/remote_pdf_server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PDF Server

I have multiple PCs, and I always want a way to edit my pdfs remotely. I have tried just to use file syncing between my computers. But I find the solution sub optimum. I rather just to have one PC to host all the pdfs and I would edit them on some other machines.

So I wrote a PDF server with FastAPI that allows PDFs to be edited in a browser, and they can then be saved onto the server.

The service also has file tracking ability to tack previous versions of the pdf.

Supported Operations

  • Upload PDF files
  • Edit PDF content remotely
  • HTTP authentication

Frontend Repository

Check out the corresponding frontend: PDF Frontend

Installation & Setup

1. Environment Setup

Create a Python virtual environment and install the required dependencies:

python -m venv venv
source venv/bin/activate
pip install -r requirements

2. Configuration

Set the following environment variables:

Variable Description Required
USR Username for HTTP authentication Yes
PASSWORD Password for HTTP authentication Yes
DATA_DIR Location of the database for this server Yes
MAX_RETAIN Maximum number of temp files retrained No
TEST_PDF_PATH Path for test PDF file (optional) No

For local development, you can create a .env file in the root directory:

USR="your_username"
PASSWORD="your_password"
DATA_DIR="/path/to/data/directory"
MAX_RETAIN=5
TEST_PDF_PATH=""  # Leave empty if not needed

3. Run the Server

Start the FastAPI server:

nohup fastapi run pdf_api.py --host 0.0.0.0 --port 8000 > server.log 2>&1 &

Installation & Setup (Docker compose)

1. Create a docker-compose.yml file

In root directory create:

services:
  pdf-editor:
    build: .
    container_name: pdf_editor_container
    ports:
      - "8000:8000"
    environment:
      - USR=admin          # <--- set usr here
      - PASSWORD=secret    # <--- set usr password here
      - MAX_RETAIN=5
      - DATA_DIR=/app/data
    volumes:
      - ./data:/app/data
      - /home/user/your-pdf-directory:/mnt/documents # <--- update this path

2. Start the service

sudo docker-compose up --build -d

3. Note

With docker you will only have access to the files in the server directory set in docker-compose.yml. To get your pdfs, you need to use their path in the docker container: /mnt/documents

NOTICE:

This is in very early testing phase. Only recommended for local development use.

  • The server requires HTTP basic authentication using the provided credentials
  • All data is stored in the specified DATA_DIR location
  • The MAX_RETAIN setting limits the number of files retained by the server. the temp files are the previous versions of the pdf.

About

pdf server

Resources

License

Stars

Watchers

Forks