Docmosis-Java Config Files

This example shows how to configure Docmosis using properties and config files.

The ZIP contains:

  • DocmosisConfigFiles.java
  • docmosis.properties
  • converterPoolConfig.xml
  • WelcomeTemplate.doc
  • readme.txt (instructions on setup)

The licence key, OpenOffice/LibreOffice install location and other settings will be read from the docmosis.properties file.

The converterPoolConfig.xml file explains how to set up one embedded converter.

The extras directory contains more detailed examples of the docmosis.properties and converterPoolConfig.xml files.

You will need a Free Trial to run Docmosis-Java.

import java.io.File;

import com.docmosis.SystemManager;
import com.docmosis.document.DocumentProcessor;
import com.docmosis.template.population.DataProviderBuilder;

/**
 * A simple example showing Docmosis creating a PDF with dynamic data from a DOC
 * template.
 */
public class DocmosisConfigFiles {
	public static void main(String[] args) {

		// Use the DataProviderBuilder to build the data provider from Strings
		DataProviderBuilder dpb = new DataProviderBuilder();

		dpb.add("date", "12 Jun 2016");
		dpb.add("message", "This Docmosis Document Engine is working!");

		try {
			// Initialize the system using the "docmosis.properties" file
			SystemManager.initialise();

			File templateFile = new File("WelcomeTemplate.doc");
			File outputFile = new File("newDocument.pdf");

			if (!templateFile.canRead()) {
				System.err.println("\nCannot find '" + templateFile + "' in: " + new File("").getCanonicalPath());
			} else {

				// Create the document
				DocumentProcessor.renderDoc(templateFile, outputFile, dpb.getDataProvider());

				System.out.println("\nCreated: " + outputFile.getCanonicalPath());
			}
		} catch (Exception e) {
			System.err.println("\nPlease check the following: " + e.getMessage());
		} finally {

			// Shutdown the system
			SystemManager.release();
		}
	}
}

Feedback

Invalid Input

Sorry, this field will only accept letters and numbers, and not special characters, to limit spam. Please also consider contacting support@docmosis.com if you need help with this article.

Sorry, this field will only accept letters and numbers, and not special characters, to limit spam.

Invalid Input

Applies To

Docmosis-Java Tornado Cloud
Version(s) ALL - -