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.
- Upload PDF files
- Edit PDF content remotely
- HTTP authentication
Check out the corresponding frontend: PDF Frontend
Create a Python virtual environment and install the required dependencies:
python -m venv venv
source venv/bin/activate
pip install -r requirementsSet 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 neededStart the FastAPI server:
nohup fastapi run pdf_api.py --host 0.0.0.0 --port 8000 > server.log 2>&1 &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 pathsudo docker-compose up --build -dWith 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
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_DIRlocation - The
MAX_RETAINsetting limits the number of files retained by the server. the temp files are the previous versions of the pdf.