

You actually do not need to build this image and can instead use the one I made available.
Linux pdf merge install#
There is no way with Jib to add linux packages so I replaced the default Jib base image in my pom.xml with a simple image based on openjdk:11-jre-slim and added the pdfunite binary ( apt-get install poppler-utils). The key thing here though is to make sure the containerized app will indeed be able to make the call to the pdfunite binary. In my case I used the Maven plugin and executed mvn compile jib:build (gradle is also supported). The one nice thing about Java is its vibrant ecosystem and in my case this means using Jib, an open source tool to build and push an optimized container image without having to write a Dockerfile or even install docker. Packaging this in a Container (without a Dockerfile) Note here that you really don’t have to use Java - since we’ll be packaging this as a container in the next step we really could have used any combination of language and framework here. There’s huge room for improvement as discussed in this README. The front-end is dead simple it supports four file uploads and preserves the order of files being merged (the limit of four was chosen arbitrarily the back-end imposes no such limit). I went for SpringBoot and used a single controller to manage the MultipartFile upload and delegated all PDF file storage and manipulation to a dedicated service which takes care of removing from the filesystem every file it uses or generates. Popular Java web frameworks include Spring Boot, Micronaut, Spark, etc. This obviously requires that pdfunite is installed on the underlying OS, but more on that as we package the app in a container. I used ProcessBuilder, starting it with inheritIO() and Process.waitFor() completion. The first step to making this available as a web app is to be able to invoke the command-line tool from your language of choice, in my case Java.
Linux pdf merge free#
I ended up using pdfunite but feel free to use something else here as the change would probably be a single liner. There’s a pretty good discussion on StackOverflow comparing different approaches and results (speed, document size, etc…).

The magic Linux command to merge PDF files
Linux pdf merge full#
Full code is in this GitHub repo and live service is here. You can then make it available to your friends and family or even within your enterprise via a simple browser or as an internal API to merge PDFs. This post walks you through packaging an efficient Linux command to merge PDF files into a web app and hosting it on Cloud Run.
