- GhostScript is used to convert PDF to PDF/A format but but has a bug that results in slow conversion, poor rendering and large resulting files.
- using gif format files instead of png avoids this issue
Please read this page if you would like to consume this service on MDTP
POST /pdf-generator-service/pdf-generator/generate
All requests use the HTTP POST
method
* Generates a PDF based on the submitted html
* Generated PDF must be PDF/A 1 or PDF/A 2 compliant
* Generated PDF must match the HTML page from which it was generated
* html-www-urlencoded-form with a single field 'html' that contains the html to be converted
* HTTP 200 OK with a generated and downloadable PDF
* HTTP 400 Bad Request for invalid/error scenarios
- Install wktohtml https://wkhtmltopdf.org/downloads.html version 0.12.3
- Install Ghostscript https://ghostscript.com/
- Check alias for ghostscript is ```gs
- Check parameters in application.conf after "PdfGenerator Service config - use these values for local running only"
To run the application execute
sbt ~run 9852
The endpoints can then be accessed with the base url http://localhost:9000/pdf-generator-service/pdf-generator/generate
This command will install ghostscript:
sudo apt-get install ghostscript
This command will install wkhtmltopdf:
sudo apt-get install wkhtmltopdf
We then need to add this symbolic link so that the service finds the program:
sudo ln -s /usr/bin/wkhtmltopdf /usr/local/bin
If you need to check the logs of the generator service, you may find it useful to use this command to remove the graphite warnings:
sm --start PDF_GENERATOR_SERVICE --appendArgs '{"PDF_GENERATOR_SERVICE":["-Dmicroservice.metrics.graphite.enabled=false"]}' -f
This command will bring up the logs of the pdf-generator-service:
sm --logs PDF_GENERATOR_SERVICE
This code is open source software licensed under the Apache 2.0 License