Java Azure Function that exposes REST API to generate a PDFA/2a document based on the provided data and HTML template.
See the OpenApi 3 here.
- Java 11
- IText7
- Handlebars
- Zip4j
- docker
docker build -t pagopa-pdf-engine .
docker run -p 7071:80 pagopa-pdf-engine
- maven
mvn clean package
mvn azure-functions:run
curl --location 'http://localhost:7071/generate-pdf' \
--header 'Ocp-Apim-Subscription-Key;' \
--form 'template=@"template.zip"' \
--form 'data="{
\"transaction\": {
\"id\": \"F57E2F8E-25FF-4183-AB7B-4A5EC1A96644\",
\"timestamp\": \"2020-07-10 15:00:00.000\",
\"amount\": 300.00,
\"psp\": {
\"name\": \"Nexi\",
\"fee\": {
\"amount\": 2.00
}
},
\"rrn\": \"1234567890\",
\"paymentMethod\": {
\"name\": \"Visa *1234\",
\"logo\": \"https://...\",
\"accountHolder\": \"Marzia Roccaraso\",
\"extraFee\": false
},
\"authCode\": \"9999999999\"
},
\"user\": {
\"data\": {
\"firstName\": \"Marzia\",
\"lastName\": \"Roccaraso\",
\"taxCode\": \"RCCMRZ88A52C409A\"
},
\"email\": \"[email protected]\"
},
\"cart\": {
\"items\": [{
\"refNumber\": {
\"type\": \"codiceAvviso\",
\"value\": \"123456789012345678\"
},
\"debtor\": {
\"fullName\": \"Giuseppe Bianchi\",
\"taxCode\": \"BNCGSP70A12F205X\"
},
\"payee\": {
\"name\": \"Comune di Controguerra\",
\"taxCode\": \"82001760675\"
},
\"subject\": \"TARI 2022\",
\"amount\": 150.00
}],
\"amountPartial\": 300.00
},
\"noticeCode\": \"noticeCodeTest\",
\"amount\": 100
}"' \
--form 'applySignature="false"' \
--form 'generateZipped="false"'
As you can see in the provided curl the first field template
hold a zip file. The zip file contains the HTML template
file and other optional attachments, such as CSS files, that will be used to generate the PDF document.
Warning
The HTML template file must be named to match the value of theHTML_TEMPLATE_FILE_NAME
environment variable (default istemplate
) (example of HTML template file name:template.html
)
In order to use the newly introduced engine you may use the parameter
...
--form 'generatorType="PLAYWRIGHT"'
The two values available are PLAYWRIGHT and ITEXT (the value defaults to ITEXT currently)
- git
- maven
- jdk-11
To run the Junit tests:
mvn clean verify
From ./integration-test/src
yarn install
yarn test
Made with ❤️ by PagoPa S.p.A.
See CODEOWNERS
file