Spring Boot application for converting supported files to PDF, compressing PDFs, and merging multiple PDFs.
convertx-app: Spring Boot web application for FileOperationsXXXpdf-compression: extracted Ghostscript-based PDF compression subproject
- Java 25
- Maven 3.9+
- Linux server with these commands available on the
PATH - LibreOffice installed and
sofficeavailable on thePATHfordocx,xlsx, andpptx - Ghostscript installed and
gsavailable on thePATHfor PDF compression - HEIC support installed through ImageMagick (
magickorconvert) orlibheif(heif-convert)
mvn -pl convertx-app -am spring-boot:runOpen http://localhost:8081 to use the web UI for convert, compress, and merge operations.
- Install JDK 25 and make sure both
javaandmvnuse it. - Verify with:
java -version
mvn -version- If Maven is using a different JDK than your shell, export
JAVA_HOMEbefore running Maven:
export JAVA_HOME=/path/to/jdk-25
export PATH="$JAVA_HOME/bin:$PATH"- Build from the project root:
mvn test- Run the app module:
mvn -pl convertx-app -am spring-boot:run- Confirm required native tools are available:
which magick || which convert || which heif-convert
which soffice
which gsOpenAPI docs:
- Swagger UI:
http://localhost:8081/swagger-ui.html - OpenAPI JSON:
http://localhost:8081/api/docs
Build the image from the project root:
docker build -t fileoperationsxxx .Run it locally:
docker run --rm -p 8081:8081 fileoperationsxxxRun it with an explicit platform port:
docker run --rm -e PORT=8081 -p 8081:8081 fileoperationsxxxThe container image includes the native Linux dependencies required by the application:
- LibreOffice for
docx,xlsx, andpptx - Ghostscript for PDF compression
- ImageMagick and
libheiftools for HEIC conversion and rotation
The repository now includes cloudbuild.yaml for Cloud Build based automatic deployment.
The intended GCP setup is:
- GitHub repository:
ThreeMangoTrees/AllFiles - Branch trigger:
^main$ - Build config file:
cloudbuild.yaml - Cloud Run service:
allfilesxxx - Region:
us-west1 - Artifact Registry image path:
us-west1-docker.pkg.dev/$PROJECT_ID/cloud-run-source-deploy/allfiles/allfilesxxx:$COMMIT_SHA
On each push to main, Cloud Build will:
- build the Docker image from the repo root
Dockerfile - run a
trivyvulnerability scan and fail the build onHIGHorCRITICALfindings - push the image to Artifact Registry
- update the Cloud Run service with the new image
The application now expects HTTP Basic authentication in deployed environments.
- Username env var:
APP_BASIC_AUTH_USERNAME - Password env var:
APP_BASIC_AUTH_PASSWORD - API docs are disabled by default in deployed environments unless explicitly re-enabled
- Per-client rate limiting is enabled by default for
/api/* - Optional malware scanning can be enabled with:
APP_ANTIVIRUS_ENABLED=trueAPP_ANTIVIRUS_COMMAND=clamscan
Cloud Run deployments from cloudbuild.yaml now also:
- set Cloud Run concurrency to
10 - inject the application password from Secret Manager secret
app-basic-auth-password - keep Swagger and OpenAPI disabled by default
Use this checklist before deploying the project to a Linux server.
- Install the required native packages.
sofficeis required fordocx,xlsx, andpptxgsis required for PDF compression- HEIC conversion requires one of:
- ImageMagick via
magickorconvert libheifviaheif-convert
- ImageMagick via
- HEIC rotation requires ImageMagick with HEIC delegate support
On Debian or Ubuntu, a typical install looks like:
sudo apt-get update
sudo apt-get install -y libreoffice ghostscript imagemagick libheif-examples- Use the
PORTenvironment variable when the server platform assigns ports dynamically.
- The application now reads
server.portfromPORTand falls back to8081. - This works for systemd services, VMs, containers, and platforms like Cloud Run.
- Verify the Linux runtime before launch.
java -version
mvn -version
which soffice
which gs
which magick || which convert || which heif-convert- Package and run the application.
mvn test
mvn -pl convertx-app -am package
java -jar convertx-app/target/convertx-app-0.0.1-SNAPSHOT.jar-
For systemd-managed Linux servers, set
PORT,JAVA_HOME, andPATHexplicitly in the unit file if they are not already present in the service environment. -
Size the server with enough memory for LibreOffice and Ghostscript, especially for large Office files and large PDF merge/compression requests.
-
If the server is container-based, prefer baking the native binaries into the image instead of installing them at container start.
-
The current file-based logs are configured in logback-spring.xml. Keep console logging enabled if your Linux environment ships logs through journald or a container runtime.
Convert a supported file to PDF:
curl -X POST \
-F "file=@/path/to/file.docx" \
http://localhost:8081/api/convert/to-pdf \
--output converted.pdfCompress a PDF with a 25%, 50%, or 75% profile:
curl -X POST \
-F "file=@/path/to/file.pdf" \
-F "targetPercentage=50" \
http://localhost:8081/api/pdf/compress \
--output compressed.pdfMerge two or more PDFs:
curl -X POST \
-F "files=@/path/to/part-1.pdf" \
-F "files=@/path/to/part-2.pdf" \
http://localhost:8081/api/pdf/merge \
--output merged.pdfdocx,xlsx,pptxjpg,jpeg,tiff,gif,bmp,heictxt,rtf,html,htm
docx,xlsx, andpptxare converted through LibreOffice in headless mode.heicconversion uses ImageMagick (magickorconvert) orheif-convert.heicrotation currently returns ajpgfile because HEIC encoding support is not reliably available in Linux deployments.TODO: implement native HEIC-to-HEIC rotation support so rotated HEIC uploads remain in HEIC format instead of being converted to JPG.- Image formats currently convert the first image frame/page into a single-page PDF.
- PDF compression uses Ghostscript profiles that roughly target 25%, 50%, or 75% size classes; exact output size depends on the source PDF, and the original PDF is returned if recompression would make it larger.
- PDF merge preserves the input order of the uploaded files.