Araxis Merge automation API in JavaScript

Araxis Merge is a file comparison tool that supports many file formats, even formats such as MSWord and PDF. That makes this tool ideal for regression testing of application output in the form of, for instance, generated PDF files. Araxis Merge comes with an automation API which helps us speeding up the file comparison process easily.

Several programming and scripting languages are supported from which you can control Araxis Merge, such as VBA, c#, C++ and Windows Scripting host (VBScript, JavaScript).

Recently I needed to call the automation API from within AutoIt in order to compare two pdf files and to generate the comparison report. As AutoIt is not in the list of supported scripting/programming languages, I wrote a script with JavaScript to perform this action. Following script can be run from command line, so it can be called from any other scripting language, such as AutoIt.

The comparison JavaScript

I have foreseen three different input parameters for the script:

  • baseFile: the complete path + filename of the first file. This is the base line file which the newly generated file will be compared with
  • newFile: the complete path + filename of the second file to compare against the base line file
  • report: the complete path + filename of the comparison report to generate

If all mandatory arguments were specified, the file comparison starts; otherwise directions on how to call the compare script are shown.

if (WScript.Arguments.length != 3) {
else {
Create an Araxis Merge application object and retrieve the command line parameters. Perform the comparison between the base file and new file. Create a merge report only if there is at least 1 difference between the two files. Note that I wrote down > 1 as a value of 1 of property NumberOfChanges means that there are no differences.

function compare() {

var app = WScript.CreateObject("Merge70.Application");
var tc = app.TextComparison;

baseFile = WScript.Arguments.Item(0);
newFile = WScript.Arguments.Item(1);
report = WScript.Arguments.Item(2);

tc.Compare(baseFile, newFile)

if ( tc.NumberOfChanges > 1) {
tc.Report("html", 0/*lesCRLF*/, report); //report

This function displays the correct comment line syntax to use when calling the compare script.

function directions() {
WScript.Echo("Command line syntax:\ncompare.js baseFile newFile report");
Put above code all together in one JavaScript file, for instance "compare.js". From the command prompt window, navigate to the script folder location and run the script by typing the command below. Don't forget to replace normal "\" by "\\" in each of the three arguments.
compare.js baseFileLocation newFileLocation reportCompleteLocation

When running this command Araxis Merge should start comparing the two input files, and to write down the report to the location of your choice if any changes exist.

I chose not to implement any error handling in the script, to make it as simple as possible. Any error handling and validation is handled by the caller script in AutoIt in my case.

Related Posts by Categories


5 Responses to "Araxis Merge automation API in JavaScript"

MightyMouse said... April 12, 2009 at 1:51 PM

Hi steven, I used to work with Araxis Merge too, but since some time I'm a big fan of Beyond Compare instead ( Some nice features of BC: comare zip files, compare jar files (with automatic decompilation!), good compare methods for folder comparision, and of course it can do most of what araxis could do. Nice integration with svn is of course also possible. You might check it out someday ;)

Steven Machtelinckx said... April 12, 2009 at 10:38 PM

Thanks for the suggestion! BC seems to be a really powerful tool. I will add it to my tool list, or even better, I will bookmark your blog which has all best tools in a nutshell :-)

On my current project we opted for Araxis Merge as our pdf compare tool. I'm not sure why we didn't choose BC, maybe the price? I will try to find out why we chose Araxis Merge.

Sil said... April 14, 2009 at 12:30 AM

A nice comparison of comparing tools: They compare Araxis Merge, WinMerge and BeyondCompare. They conclude no other tool comes even close to BeyondCompare in terms of total user experience. And this was based on an older version of BC.

Steven Machtelinckx said... April 14, 2009 at 7:29 AM

That's a really detailed article, thanks for sharing it!

The reason why we didn't opt for this comparison tool is as simple as this: we didn't include it in our own comparison of comparison tools.

TestWithUs said... May 7, 2013 at 6:25 AM

SWIFT Interview questions on

For selenium solution visit

For QTP interview questions

Post a Comment

Recent Articles

Top Commenters

Recent Comments