HTTP service for generating a preview image from a PDF cover page using Ghostscript. See ImageService.php for Ghostscript command line parameters.
This example uses pdf2jpg as the image and container name and tcp port 36000 as the published port for the service.
-
Install Docker
-
Build Docker image:
cd <dir> docker build -t pdf2jpg .Use e.g. pdf2jpg as the service name.
-
Start service:
docker run -p 36000:80 pdf2jpg -
Or just create the container e.g. for starting via systemd (see accompanying pdf2jpg.service for systemd configuration):
docker create -p 36000:80 --name pdf2jpg pdf2jpg
-
To recreate the service, first stop the service:
docker stop pdf2jpgor if running with systemd:
systemctl stop pdf2jpgthen remove the old container and image:
docker rm pdf2jpg docker rmi pdf2jpgThen create the service just like when doing an initial installation.
-
All in one:
systemctl stop pdf2jpg && docker rm pdf2jpg && docker rmi pdf2jpg && docker build -t pdf2jpg . && docker create -p 36000:80 --name pdf2jpg pdf2jpg && systemctl start pdf2jpg
If the service fails to start, you may need to stop Docker, remove /var/lib/docker/network/files/local-kv.db (or wherever Docker stores its files, e.g. /data/docker/network/files/local-kv.db) and try again.
-
Basic conversion of a PDF-file
http://127.0.0.1:36000/convert?url=<PDF url> -
Other options are:
/clearblocks Empties blocked URLs directory /clearpdf Empties PDF directory /clearimg Empties generated images directory /clearall Empties all the directories -
For debug purposes:
/status Displays OK if everything is going fine /log Download a logfile, log files are saved for 4 days. usage = /log?file=log-yyyy-mm-dd.log /kill Useful for restarting the docker, if instanciated as a service.