Skip to content

aldimhr/bot-pdf-toolbox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

13 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

PDF Toolbox Telegram Bot

Telegram bot MVP for temporary PDF conversion and basic PDF tools.

Current features

  • Convert file/image to PDF
    • Images: .jpg, .jpeg, .png, .webp, .tif, .tiff, .bmp
    • Text-like: .txt, .md, .csv, .log, basic .html
    • Office files: .doc, .docx, .xls, .xlsx, .ppt, .pptx, .odt, .ods, .odp, .rtf if LibreOffice is installed
  • Merge multiple PDFs
  • Split one PDF into one-page PDFs returned as a ZIP
  • Compress PDF with low/medium/high compression
  • Admin-gated /admin
  • Privacy-first temp storage: uploads are deleted after processing by default

Configuration

Copy .env.example to .env and edit:

BOT_TOKEN=put-your-bot-token-here
ADMIN_IDS=519613720
DELETE_UPLOADS_AFTER_PROCESSING=true
DELETE_OUTPUTS_AFTER_SENDING=true
KEEP_FAILED_UPLOADS=false
TEMP_DIR=data/tmp
MAX_FILE_MB=20
JOB_TIMEOUT_SECONDS=120
DATABASE_ENABLED=true
DATABASE_FAIL_OPEN=true
PUBLIC_SUPABASE_URL=https://your-project-ref.supabase.co
PUBLIC_SUPABASE_PUBLISHABLE_KEY=your-publishable-key

Storage policy config:

  • DELETE_UPLOADS_AFTER_PROCESSING=true: removes uploaded files after the job is done.
  • DELETE_OUTPUTS_AFTER_SENDING=true: removes generated output after Telegram send completes.
  • KEEP_FAILED_UPLOADS=false: failed jobs are also cleaned. Set true only for debugging.

Per-user daily limits are stored in the database on users.daily_job_limit. Set a userโ€™s value to 0 to make that account unlimited.

Admin config:

  • ADMIN_IDS is a comma-separated allowlist of Telegram user IDs.
  • Only IDs in this list can access /admin.

Local run

python3 -m venv .venv
. .venv/bin/activate
pip install -e '.[dev]'
python -m pdf_toolbox_bot.bot

Optional system dependencies

For Office to PDF:

sudo apt-get update
sudo apt-get install -y libreoffice ghostscript fonts-dejavu fonts-noto fonts-noto-cjk

Without LibreOffice, image/text/PDF tools still work, but DOCX/XLSX/PPTX conversion returns a clear error.

Production notes

  • Rotate the bot token before production if it was ever pasted in a chat or logs.
  • Use Docker/systemd to keep the process running.
  • Add a worker queue before supporting large files or OCR.
  • Keep file size limits and cleanup enabled.

About

๐Ÿ“„ PDF Telegram Bot โ€” Convert, merge, split, compress, OCR, watermark & more. Python/aiogram.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors