Publishing Engine Programmer's Guide > The Arbortext Publishing Engine Sub-Process > Writing Arbortext PE Applications in ACL > Calling the Conversion Processor from an ACL Arbortext PE Application
  
Calling the Conversion Processor from an ACL Arbortext PE Application
You can write an ACL application that can call the conversion processor (explained in Arbortext Publishing Engine Document Conversion) by invoking the following function:
e3::convert2( inFile, outFile, parameter[] )
inFile must specify the absolute path to a document to be converted. The e3::convert2 function can not process open documents. If your application creates or modifies a document that will be converted, you must save the document to disk and close it before invoking e3::convert2. After e3::convert2 returns, you can open your document again if you need to make further modifications.
outFile must specify the absolute path to the output file that e3::convert2 will produce. If this file already exists, it will be overwritten during conversion processing.
parameter must be an ACL associative array. Each array entry must correspond to a valid conversion parameter (see Document Conversion Parameters for a list and descriptions).
For example, to specify a stylesheet:
parameter[ "stylesheet"] = "d:\absolute\path\to\stylesheet.style";
The e3::convert2 function returns an associative array encoded as a string. Extract the array content by invoking the function e3::string_to_array( inString, outArray ). The resulting array will contain three elements:
result: will be either ok or error
reason: HTTP reason code (400, 500, or some other valid code)
page: an XHTML page describing the error (the same page an f=convert request would return to an HTTP client)
Example of ACL code that calls the e3::convert2 function:
local inFile = "c:\absolute\path\to\input\file.xml";
local outFile = "c:\absolute\path\to\output\file.pdf";
local parameters[];
local resultArray[];
parameters[ "type"] = "pdf";
parameters[ "stylesheet"] = "d:\absolute\path\to\stylesheet.style";
local resultString = e3::convert2( inFile, outFile, parameters );
e3::stringToArray( resultString, resultArray );
if ( resultArray[ "result"] == "ok" ) {
# conversion succeeded: continue processing
}
else {
# conversion failed: error page is in resultArray[ "page"]
}