Skip to main content
Skip table of contents

.Deploying iText DITO SDK/API on Amazon Web Services viText_DITO_2.0

Using iText DITO in AWS ECS

Prerequisites 

  1. An EC2-based ECS cluster up and running
  2. IAM ECS Task Role with a policy to allow MeterUsage

In addition to the typical Cloudwatch and ECR access (e.g. AmazonECSTaskExecutionRolePolicy) please make sure the role has a policy that allows AWS Marketplace Meter Usage

{

    "Version": "2012-10-17",

    "Statement": [

        {

            "Action": [

                "aws-marketplace:MeterUsage"

            ],

            "Effect": "Allow",

            "Resource": "*"

        }

    ]

}

DITO ECS Task Definition

Create a new ECS Task Definition with the following properties

 

EC2 Compatibility

EC2 Compatibility


In container definitions, fill in the correct container image address  (e.g. 709825985650.dkr.ecr.us-east-1.amazonaws.com/itext-software/itext-dito-sdk:itext-dito-sdk-2.0.1.6 ).

Use the port mapping 49157 (host): 8080 (container). Create a new volume (local or EFS) and mount it under the container path /var/opt/dito.

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

Important Note: additional detailed logs are currently written locally under /var/log/dito. If you wish to access those you can mount an additional container volume in that location.

Container Definitions

Container Definitions 

Starting a DITO 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 DITO service will be up and running.

ECS Task Running
 

ECS Task Running

Adding DITO Templates

Before starting to use the service, you will need to add DITO templates to the service. These templates are placed inside the container volume we defined in the ECS task definition.

Start a SSH interactive session with the EC2 host where the ECS Task is running, and navigate to the volume /var/lib/docker/volumes/itext-dito-metering-volume/_data folder. Place the template (e.g. invoice.dito) inside that folder.

Container Volume
 

Container Volume

Using the DITO HTTP API

In the ECS Task that is running, you will be able to fetch the external link information that gives you the ability to interact with the DITO service.

External Link in ECS Task

External Link in ECS Task

From your local machine, you can use the command curl ( curl -H "Content-Type: application/json" --data @request.json http://18.232.157.250:49157/api/pdf-producer )  to send a request to the DITO API. This request will use the template we previously added to the service, invoice.dito, to produce a PDF.

Using the API
 Using the API

The result PDF file will be available alongside the template in the container volume.

Result PDF Output

Result PDF Output

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.