Java Interface

A java API is provided to allow Servlets and other server side components to use Xinc to dynamically generate PDF documents. Please see the JavaDocs for the API.

Setting up the environment

You will need to have the following jar files in your class path:

We also recommend that you set the following system properties:

-Djava.awt.headless=true
-Djava.endorsed.dirs=<installDir>/lib/xalan-j_2_5_1

Specifying a Configuration

By default, Configuration information is loaded from a file in your user.home directory called .xincconfig.xml. You can choose to override this location by specifying -Dxinc.config.home=someDirectoryName. Configuration's are implemented using the DOM API.

Xinc also allows you to load or build your own Configuration and pass it to the formatter. The following code fragment can be use to load a custom Configuration:

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
...
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document config = builder.parse(new File("/tmp/CustomConfig.xml"));

This configuration can be set on the formatter before invoking one of the format(...) methods. You may want to look at the documentation for the DOM API.

Sample Servlet

All of the sample code can be found in your Xinc installation at '\Program Files\Xinc\examplecode\'. The Servlet example is located in the 'servlet' subdirectory. The Servlet example is intended to demonstrate basic use of the API and may need to be modified if you intend to use it in a production environment.

You may need to modify the Ant script, build.xml, to reflect your environment. The Ant script can be used to build the servlet for a Tomcat Server or a BEA Weblogics 8 server. If you want to build for Weblogics, you need to uncomment the two weblogics sections and comment out the Tomcat sections.

View XincSampleServlet.java

Sample Code

All of the sample code can be found in your Xinc installation at 'xinc/examplecode'. The Java API examples are located in the 'java' subdirectory. ApiDemo1 illustrates the use of the XincFormatter API. ApiDemo2 illustrates the use of the lower-level XincEngine API.

View ApiDemo1.java

View ApiDemo2.java