Deploying

ECS Task Definition

Create a new ECS Task Definition with the following properties:

 

EC2 Compatibility


In container definitions, fill in the correct container image address (e.g. 709825985650.dkr.ecr.us-east-1.amazonaws.com/itext-software/itext7suite:1.0.2). Please make sure you are using the latest version.

Use the desired port mapping 8080(host): 8080 (container).

Enable AWS CloudWatch logs to gain visibility over the container output.

And finally, very importantly, this is where you will set your iText 7 License key.


The way you do it is by setting up an Environment Variable called ENCODED_LICENSE, where its value is a Base64 encoded string of a zip of the license key. So:

  1. zip your .XML license file
  2. get the Base64 encoding
  3. set it as the value for the ENCODED_LICENSE Environment variable

Starting the ECS Service

Create a new ECS service based on the newly created task definition. If everything is properly configured, a new ECS task will start and your iText 7 Suite service will be up and running.

 

ECS Task Running

Using the iText 7 Suite HTTP API


After the iText 7 Suite REST API has been deployed, you can access the Swagger documentation from /api/swagger-ui.html which should look something like this:

Generally speaking, all of the available requests operate in a similar fashion:

  1. you upload a file and specify what you want to do with it,
  2. you query the system to see if the process has already been completed,
  3. you download the end result.

Examples

Converting PDF to Image

job key payload (request on /api/job/)

{"request": {
"type":"PDF_TO_IMAGES",
"imageType":"JPEG",
"pageNumbers":"1",
"defaultPageScaling":1
},
"sourceFiles":
[{
"checksum":"0f96c60805d8df8d57b8411f17d03925",
"fileType":"application/pdf",
"fileSize":76478,
"fileName":"Demo invoice.pdf"}]
}

would get the reply:

{
    "id": "7a970947-9e44-4e20-956d-be9d42cecea5",
    "status": "PROCESSING",
    "sourceFiles": [
        {
            "id": "cdb3f514-219b-443e-8869-0671281ac753",
            "checksum": "0f96c60805d8df8d57b8411f17d03925",
            "fileType": "application/pdf",
            "fileSize": 76478,
            "fileName": "Demo invoice.pdf"
        }
    ],
    "request": {
        "type": "PDF_TO_IMAGES",
        "imageType": "JPEG",
        "pageNumbers": "1",
        "pageScaling": 1.0
    }
}

check the job status on (/api/job/{id}) until it has FINISHED:

{
    "id": "7a970947-9e44-4e20-956d-be9d42cecea5",
    "status": "FINISHED",
    "resultFile": {
        "id": "23269d9f-9282-4d3b-90de-7725c8f1741e",
        "checksum": "2499414f1b25ea19519af713bbfbd2ec",
        "fileType": "application/zip",
        "fileSize": 39287
    },
    "request": {
        "type": "PDF_TO_IMAGES",
        "imageType": "JPEG",
        "pageNumbers": "1",
        "pageScaling": 1.0
    }
}

and then you can get the actual file (/api/job/{id}/file/result)


If you use Postman, you can also load this collection for some examples.