This is a PDF service which allows to generate read-only PDFs based on given template in HTML/Twig format and placeholder data in JSON format. The service provides a single RESTful endpoint that merges both template and placeholder data together and returns the PDF as a binary stream.
The template, besides containing ordinary HTML markup, can also contain inline CSS styling and embedded images.
The project uses Gradle as a build tool but you don't have to install it locally since there is a
./gradlew
wrapper script.
To build project please execute the following command:
./gradlew build
First you need to create distribution by executing following command:
./gradlew installDist
When the distribution has been created in build/install/pdf-service
directory,
you can run the application by executing following command:
docker-compose up
As a result the following container(s) will get created and started:
- long living container for API application exposing port
5500
API documentation is provided with Swagger:
http://localhost:5500/swagger-ui.html
- UI to interact with the API resources
NOTE: Swagger scans classes in the uk.gov.hmcts.reform.pdfservice.controllers
package.
There is a client library provided for java https://github.com/hmcts/cmc-pdf-service-client
Image is available in the HMCTS azure container registry (currently private) @ hmcts.azurecr.io/hmcts/rpe/pdf-service
. See usage example in: docker-compose.yml
To render PDF with non ASCII characters, please use the 'Open Sans' font-family.
font-family: 'Open Sans';
Example:
<head>
<style>
html {
font-family: 'Open Sans';
}
</style>
</head>
To run all unit tests please execute following command:
./gradlew test
To run all checks (including unit tests) please execute following command:
./gradlew check
We use SemVer for versioning. For the versions available, see the tags on this repository.
We follow RESTful API standards.
This project is licensed under the MIT License - see the LICENSE.md file for details.