Publishing Engine Programmer's Guide > The Arbortext Publishing Engine Sub-Process > Writing Arbortext PE Applications in JavaScript > Calling the Conversion Processor from a JavaScript Arbortext PE Application
  
Calling the Conversion Processor from a JavaScript Arbortext PE Application
You can write a JavaScript application that can call the conversion processor (explained in Arbortext Publishing Engine Document Conversion). The Arbortext PE sub-processes use the Rhino package to allow JavaScript to access Java objects. Refer to the Calling the Conversion Processor From a Java Arbortext PE Application for an explanation of the Java objects used to invoke the conversion processor. Each parameter entry must correspond to a valid conversion parameter (see Document Conversion Parameters for a list and descriptions).
The following is an example of JavaScript code that calls com.arbortext.e3.DocumentConverter.doConvert:
var inFile = "c:\absolute\path\to\input\file.xml";
var outFile = "c:\absolute\path\to\output\file.pdf";
var params = new java.util.HashMap();
params.put( "type", "pdf" );
params.put( "stylesheet" , "d:\absolute\path\to\stylessheet.style" );
try {
com.arbortext.e3.subprocess.DocumentConverter.doConvert(
inFile, outFile, params );
// Conversion succeeded
}
catch( e ) {
var reason = e.getReason();
var page = e.getPage();
// Log the failure and exit.
}