Skip to content

Allows to generate PDFs based on given template and placeholder data

License

Notifications You must be signed in to change notification settings

hmcts/rpe-pdf-service

Repository files navigation

PDF service

codecov

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.

Getting started

Prerequisites

diagram

Building

The project usesGradleas a build tool but you don't have to install it locally since there is a ./gradlewwrapper script.

To build project please execute the following command:

./gradlew build

Running

First you need to create distribution by executing following command:

./gradlew installDist

When the distribution has been created inbuild/install/pdf-servicedirectory, 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 port5500

API documentation

API documentation is provided with Swagger:

  • http://localhost:5500/swagger-ui.html- UI to interact with the API resources

NOTE: Swagger scans classes in theuk.gov.hmcts.reform.pdfservice.controllerspackage.

Consuming

There is a client library provided for javahttps://github /hmcts/cmc-pdf-service-client

Docker

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

Non ASCII Characters Support

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>

Developing

Unit tests

To run all unit tests please execute following command:

./gradlewtest

Coding style tests

To run all checks (including unit tests) please execute following command:

./gradlew check

Versioning

We useSemVerfor versioning. For the versions available, see the tags on this repository.

Standard API

We followRESTful API standards.

License

This project is licensed under the MIT License - see theLICENSE.mdfile for details.