'use strict';

const path          = require('path')
    , spawn         = require('child_process').spawn
    , _             = require('lodash');

module.exports = TabulaCommand;

function TabulaCommand(pdfPath, commandArgs){
  if (!(this instanceof TabulaCommand)) return new TabulaCommand(pdfPath, commandArgs);
  this._build(pdfPath, commandArgs);
}

TabulaCommand.prototype.run = function () {
  return spawn('java', this.args);
};

TabulaCommand.prototype._build = function (pdfPath, commandArgs) {
  this.args = ['-jar', path.join(__dirname, 'tabula-java.jar')];
  this.args = this.args.concat(_.toPairs(_.mapKeys(commandArgs, (value, key) => `--${_.kebabCase(key)}`)));
  this.args = this.args.concat([pdfPath]);
  this.args = _.flatten(this.args);
  return this;
};
@@ -563,16 +563,171 @@
 jar')%5D;%0A
+  if (commandArgs%5B%22area%22%5D.constructor === Array)%7B%0A    var array = commandArgs%5B%22area%22%5D.map((item)=%3E%7B%0A      this.args.push(%5B'-a', item%5D);%0A    %7D);%0A  %7Delse%7B%0A  
   this.a
@@ -826,16 +826,20 @@
 )%7D%60)));%0A
+  %7D%0A
   this.a
@@ -924,10 +924,11 @@
 n this;%0A
-
 %7D;
+%0A

Allow multiple areas