It’s a long script, however if it was the script would I not get the same text when running through mapper directly?
//add something in to extract doc type from 1st page
var DocType = data.extract(78.57066,132.75732,110.91334,4.9106674,“
”);
if (DocType == “PERIODIC STATEMENT”)
{
var AgreementNumPage1 = data.extract(106.341324,132.58798,121.24267,3.0479965,“
”).trim();
var Error = “”;
logger.info("AgreementNumPage1" + AgreementNumPage1);
//if more than a 1 page document then check inv number from subs pages matches the 1st page
if (steps.totalPages > 1)
{
for (var Pages = 1;Pages<=steps.totalPages-1;Pages++)
{
//move down to next page to extract field
yPos = 33.714+((Pages-1)*297);
//get inv number from next page
var Text = data.extract(18.796,35.559998,yPos,3.0480042,"<br />").trim();
var ReturnValue = "";
var InvNum;
AgreementNum = Text
//logger.info("AgreementNum" + AgreementNum);
if (Text.indexOf("<br />")>0)
{
var TextSplitbr = Text.split("<br />");
//go through each line and see if it contains "Invoice Number"
for (var i=0;i<TextSplitbr.length;i++)
{
var Line = TextSplitbr[i];
if (Line.indexOf("Invoice number:")== 0)
{
//if it does then extract the invoice number
var LineSplit = Line.split(":");
AgreementNum = LineSplit[1].trim();
}
}
//check if match found, if not then set as error
if (AgreementNum != AgreementNumPage1){
//logger.info(AgreementNum);
//logger.info(AgreementNumPage1);
Error = "Mismatch between pages in pack on invoice number - " + record.fields.Address_Add1;
}
}
//if (AgreementNum == "") Error = "Empty Inv Number for -" + record.fields.Address_Add1;
}
}
else{
var InvNumPage1 = data.extract(67.056,117.348,101.6,8.974663,“
”).trim();
var Error = “”;
// if not period statement then use the below
//if more than a 1 page document then check inv number from subs pages matches the 1st page
if (steps.totalPages > 1)
{
for (var Pages = 1;Pages<=steps.totalPages-1;Pages++)
{
if (Pages != 1)
{
//move down to next page to extract field
yPos = 33+((Pages-1)*297);
//get inv number from next page
var Text = data.extract(10,135,yPos,42,"<br />");;
var ReturnValue = "";
var InvNum;
logger.info("yPos " + yPos);
logger.info("Text " + Text);
if (Text.indexOf("<br />")>0)
{
var TextSplitbr = Text.split("<br />");
//go through each line and see if it contains "Invoice Number"
for (var i=0;i<TextSplitbr.length;i++)
{
var Line = TextSplitbr[i];
if (Line.indexOf("Invoice number:")== 0)
{
//if it does then extract the invoice number
var LineSplit = Line.split(":");
InvNum = LineSplit[1].trim();
}
}
//check if match found, if not then set as error
if (InvNum != InvNumPage1) Error = "Mismatch between pages in pack on invoice number - " + record.fields.Address_Add1;
logger.info("InvNumPage1 " + InvNumPage1);
logger.info("InvNum " + InvNum);
}
}
if (InvNum == "") Error = "Empty Inv Number for -" + record.fields.Address_Add1;
}
}
}
//return error value
Error;