name: pdfapps
title: PDFApps
base: core22
version: '1.13.1'
summary: Fast, offline, subscription-free PDF editor
description: |
  PDFApps is an all-in-one PDF editor with 13 built-in tools: split, merge,
  rotate, extract, reorder, compress, encrypt, watermark, OCR, convert
  (PNG/JPG/DOCX/TXT), visual editor (redact, text, images, signatures,
  highlights, notes), import (TXT/images/Markdown), and metadata viewer.

  Features include continuous-scroll viewer, presentation mode (F5),
  fullscreen (F11), tabbed viewing, dark/light themes, drag and drop,
  multi-select PDF open, and 8-language interface (EN, PT, ES, FR, DE,
  ZH, IT, NL).

  100% offline. No subscriptions, no cloud uploads, no account required.

grade: stable
confinement: strict
license: MIT
website: https://nelsonduarte.github.io/PDFApps/
source-code: https://github.com/nelsonduarte/PDFApps
issues: https://github.com/nelsonduarte/PDFApps/issues
contact: https://github.com/nelsonduarte/PDFApps/issues
donation: https://github.com/sponsors/nelsonduarte
icon: snap/gui/pdfapps.png

architectures:
  - build-on: amd64

apps:
  pdfapps:
    command: bin/pdfapps
    common-id: io.github.nelsonduarte.PDFApps
    desktop: usr/share/applications/io.github.nelsonduarte.PDFApps.desktop
    plugs:
      - home
      - removable-media
      - network
      - cups
      - desktop
      - desktop-legacy
      - x11
      - wayland
      - opengl
      - audio-playback
    environment:
      PYTHONPATH: "$SNAP/lib/python3.10/site-packages:$SNAP/usr/lib/python3/dist-packages"
      QT_PLUGIN_PATH: "$SNAP/lib/python3.10/site-packages/PySide6/Qt/plugins"
      QT_QPA_PLATFORM_PLUGIN_PATH: "$SNAP/lib/python3.10/site-packages/PySide6/Qt/plugins/platforms"
      QT_QPA_PLATFORM: "xcb;wayland"
      LD_LIBRARY_PATH: "$SNAP/lib/python3.10/site-packages/PySide6/Qt/lib:$LD_LIBRARY_PATH"
      FONTCONFIG_PATH: "$SNAP/etc/fonts"

parts:
  pdfapps:
    plugin: python
    source: .
    python-requirements:
      - requirements.txt
    build-packages:
      - python3-dev
      - libgl1-mesa-dev
    stage-packages:
      - libxkbcommon0
      - libegl1
      - libgl1
      - libglib2.0-0
      - libxcb1
      - libxcb-cursor0
      - libxcb-icccm4
      - libxcb-image0
      - libxcb-keysyms1
      - libxcb-randr0
      - libxcb-render0
      - libxcb-render-util0
      - libxcb-shape0
      - libxcb-shm0
      - libxcb-sync1
      - libxcb-xfixes0
      - libxcb-xinerama0
      - libxcb-xkb1
      - libxkbcommon-x11-0
      - libdbus-1-3
      - libfontconfig1
      - libfreetype6
      - libxrender1
      - libxext6
      - libxi6
      - libxrandr2
      - libxss1
      - libxtst6
      - libwayland-client0
      - libwayland-cursor0
      - libwayland-egl1
      - tesseract-ocr
      - tesseract-ocr-eng
      - tesseract-ocr-por
      - tesseract-ocr-spa
      - tesseract-ocr-fra
      - tesseract-ocr-deu
      - ghostscript
    override-build: |
      craftctl default
      install -d $CRAFT_PART_INSTALL/usr/lib/pdfapps
      cp -r app pdfapps.py icon.ico icon_512.png pdfapps.svg \
        $CRAFT_PART_INSTALL/usr/lib/pdfapps/
      install -d $CRAFT_PART_INSTALL/bin
      cat > $CRAFT_PART_INSTALL/bin/pdfapps <<'EOF'
      #!/bin/sh
      cd $SNAP/usr/lib/pdfapps
      exec python3 pdfapps.py "$@"
      EOF
      chmod +x $CRAFT_PART_INSTALL/bin/pdfapps
      install -d $CRAFT_PART_INSTALL/usr/share/applications
      cp flatpak/io.github.nelsonduarte.PDFApps.desktop \
        $CRAFT_PART_INSTALL/usr/share/applications/
      install -d $CRAFT_PART_INSTALL/usr/share/metainfo
      cp flatpak/io.github.nelsonduarte.PDFApps.metainfo.xml \
        $CRAFT_PART_INSTALL/usr/share/metainfo/
      install -Dm644 icon_512.png \
        $CRAFT_PART_INSTALL/usr/share/icons/hicolor/512x512/apps/io.github.nelsonduarte.PDFApps.png
      install -Dm644 pdfapps.svg \
        $CRAFT_PART_INSTALL/usr/share/icons/hicolor/scalable/apps/io.github.nelsonduarte.PDFApps.svg
