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:
|
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:
|
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:
|
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
PdfProducerProperties | setCustomLocales(Map<String,CustomLocale> customLocales) Sets name to CustomLocale map of custom locales |
PdfProducerProperties | setEncryptionProperties(PdfEncryptionProperties encryptionProperties) Sets PdfEncryptionProperties detailing PDF encryption |
PdfProducerProperties | setVersion(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.
PdfEncryptionProperties | setContentCopyingAllowed(boolean contentCopyingAllowed) Sets whether it is possible to copy content from PDF when it is opened with user permissions |
PdfEncryptionProperties | setEditingAllowed(boolean editingAllowed) Sets whether it is possible to edit content in PDF (including annotations) when it is opened with user permissions |
PdfEncryptionProperties | setOwnerPassword(byte[] ownerPassword) Sets owner password from raw bytes |
PdfEncryptionProperties | setOwnerPassword(String ownerPassword) Sets owner password from String |
PdfEncryptionProperties | setPrintingAllowed(boolean printingAllowed) Sets whether it is possible to print PDF when it is opened with user permissions |
PdfEncryptionProperties | setScreenReaderAccessAllowed(boolean screenReaderAccessAllowed) Sets whether it is possible for screen reader to access content in PDF when it is opened with user permissions |
PdfEncryptionProperties | setUserPassword(byte[] userPassword) Sets user password from raw bytes |
PdfEncryptionProperties | setUserPassword(String userPassword) Sets user password from String |
Reporting Options
When the pdfProducer class is called, iText DITO reports on it.
PdfProductionResult |
public long getPageCount() |
PdfProductionResult | getTemplateRepairReport 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 |
PdfProductionResult | getPdfProductionReport 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, |