Skip to main content
Skip table of contents

iText DITO Java API

Every iText DITO workflow starts with the creation of a template, exported to an iText DITO template package. This file will be at the center of the rest of the workflow. You’ll probably want to create output PDFs using the input data, following the output template.

Loading the License Key

Before you can use the SDK, you need to install the license key. iText DITO SDK for Docker users should refer to https://hub.docker.com/r/itext/dito-sdk, but for Java SDK users this is easily managed by using the following commands:


File licenseKeyFile = ”...”; DitoLicense.loadLicenseFile(licenseKeyFile);


Setting up Proxy for Volume License AWS Calls

The proxy parameters for AWS calls can be configured with the environment variables HTTPS_PROXY(https_proxy) HTTP_PROXY(http_proxy) e.g:

HTTPS_PROXY=https://127.0.0.1:8888;HTTP_PROXY=http://127.0.0.1:8888

Checking the Remaining Volume on your Subscription

We advise querying your remaining volume frequently and sending a warning message to your own application/system before the limit is reached and stops working.

For customers using the native Java iText DITO SDK you can call getRemainingProducePagesEvents using the API and this function will return the number of pages remaining on your volume license key. If you have a perpetual license, this call will return null.

For iText DITO API for Docker users it is even simpler. Simply call /api/license to display the expirationDate of your license key as well as the remaining volume.

PDF creation

One of the primary functions of iText DITO is the automatic creation of stylish and useful PDFs based on JSON data. If the template package contains an output template, all you need is the PdfProducer class from the com.itextpdf.dito.sdk. output package. Creating a PDF using an output template and JSON data might look like this:


File templatePackageFile = new File(templatePackagePath); String templateName = "output";
 
FileOutputStream fos = new FileOutputStream(new File(outFilePath)) String json = "{...}";
 
 
 
PdfProducer.convertTemplateFromPackage(templatePackageFile, templateName, fos, new JsonData(json));

Setting Properties for the PDF Producer

Apart from properties that can be configured in the iText DITO Editor, such as page setup, a number of additional properties con be set on the API level

PdfProducerPropertiessetCustomLocales(Map<String,CustomLocale> customLocales)
Sets name to CustomLocale map of custom locales
PdfProducerPropertiessetEncryptionProperties(PdfEncryptionProperties encryptionProperties)
Sets PdfEncryptionProperties detailing PDF encryption
PdfProducerPropertiessetVersion(PdfVersion version)
Sets PdfVersion of the documents to be produced


Target PDF Version

iText DITO supports version 1.7 and 2.0 of the PDF specification.

Encryption

With encryption properties you can password protect the PDF files iText DITO generates. You can set a user password, an owner password,or both. You can specify protection levels in further detail.

PdfEncryptionPropertiessetContentCopyingAllowed(boolean contentCopyingAllowed)
Sets whether it is possible to copy content from PDF when it is opened with user permissions
PdfEncryptionPropertiessetEditingAllowed(boolean editingAllowed)
Sets whether it is possible to edit content in PDF (including annotations) when it is opened with user permissions
PdfEncryptionPropertiessetOwnerPassword(byte[] ownerPassword)
Sets owner password from raw bytes
PdfEncryptionPropertiessetOwnerPassword(String ownerPassword)
Sets owner password from String
PdfEncryptionPropertiessetPrintingAllowed(boolean printingAllowed)
Sets whether it is possible to print PDF when it is opened with user permissions
PdfEncryptionPropertiessetScreenReaderAccessAllowed(boolean screenReaderAccessAllowed)
Sets whether it is possible for screen reader to access content in PDF when it is opened with user permissions
PdfEncryptionPropertiessetUserPassword(byte[] userPassword)
Sets user password from raw bytes
PdfEncryptionPropertiessetUserPassword(String userPassword)
Sets user password from String


Reporting Options

When the pdfProducer class is called, iText DITO reports on it.


PdfProductionResult

getPageCount

public long getPageCount()
Gets number of pages in created PDF
Returns:number of pages
PdfProductionResultgetTemplateRepairReport
public com.itextpdf.dito.sdk.report.ProcessingReport getTemplateRepairReport()
Gets the template repair report that for now contains only entries for normalized attributes in template. Note that report created during PDF production in PdfProducer is already logged under the hood.
Returns: template repair report

PdfProductionResultgetPdfProductionReport

Gets the PDF production report that contains information indicating potential problems during PDF production and other informative messages. Please note that those messages have different severity levels, ProcessingReportEntry.getSeverity() shows the severity of an issue. Also note that report created during PDF production in PdfProducer is already logged under the hood.
Returns: pdf production report

JavaScript errors detected

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

If this problem persists, please contact our support.