Copy link to clipboard
Copied
Hi,
I have been modifying an existing script to customize for my application. I am running into an error I don't understand:
"Not Enough Label Parameters have been selected"
See red text in code below for where this occurs. Thanks for your help.
///////////////////////////////////////////////////////////////
//
// Document Numbering (i.e. Labeling) Batch Processing (Actions) script
// by Thom Parker, WindJack Solutions, Inc. October 2010
// www.windjack.com, www.pdfscripting.com
// For Adobe Systems Inc., www.adobe.com
//
// NOTE: This JavaScript code is intended soley for use in an
// Action (Batch Sequence)script. It will not operate
// within a document/form field script or as a folder level script.
//
// This script displays a custom popup dialog for each file operated on by the Action
// The user enters information on the how the Document numbers should be applied to the
// document pages, i.e., position, content, etc. As well as information on whether or not
// the script should save the file and/or extract the labeled pages into a separte document
// These parameters are maintained for the entire Acrobat Session.
//
// Included in the parameters is a document number. This number is incremented each time
// a file is operated on.
//
// Options are included for skipping the current document and for aborting the Action sequence
//
// Custom dialog created with AcroDialogs from WindJack Solutions, Inc.
//
// Version 1.4 - 7/1/16
//Modified by SCS
// Width of label
var nLabWidth = 2000; //
// Line Height
var nLabLineHeight = 8; //
if(typeof(global.DocNumAction) == "undefined")
{
//Acrobat JavaScript Dialog
//Created by DialogDesigner from WindJack Solutions
//<CodeAbove>
var oDocNumTypes = {
"Exhibit":{Prefix:"[FIRM NAME]\r\[FEI #]\r\[DATE RANGE]\r\EXHIBIT [INITIALS] ", UseDocNum:true,UsePgNum:true,PagePrefix:" - Page "},
"Attachment":{Prefix:"[FIRM NAME]\r\[FEI #]\r\[DATE RANGE]\r\ATTACHMENT [INITIALS] ", UseDocNum:true,UsePgNum:true,PagePrefix:" - Page "},
"Memo":{Prefix:"[FIRM NAME]\r\[FEI #]\r\[INV/SUPV + MEMO DATE]\r\EXHIBIT [INITIALS] ", UseDocNum:true,UsePgNum:true,PagePrefix:" - Page "},
"Sample ":{Prefix:"[SAMPLE #]\r\[COLLECTION DATE]\r\doc # ", UseDocNum:true,UsePgNum:true,PagePrefix:" - Page "},
};
function DoSetDocNumberFn(dialog, oDlg)
{
var oRslt = dialog.store();
var strExample = oRslt["LPfx"];
if(oRslt["DocN"])
strExample += oRslt["DNum"];
if(oRslt["PgNm"])
{
strExample += eval("'" + oRslt["PPfx"] + "'") + (oDlg.nCurPage + 1).toString();
if(oRslt["PPsf"])
strExample += " of " + oDlg.nNumPages;
}
dialog.load({"Exmp":strExample});
DoSetFileName(dialog,oDlg);
}
function DoSetFileName(dialog, oDlg)
{
var oRslt = dialog.store();
var strFileName = "";
if(oRslt["SPst"])
{
// Add Prefix
strFileName += oRslt["SvPr"];
// Add Document Number
if(oRslt["DnPr"])
{
strFileName += oRslt["DNum"];
if(oRslt["DocN"])
strFileName += "_";
}
// Add File Name
strFileName += oDlg.strFileName.replace(/\.pdf/,"");
// Add Document Number
if(oRslt["DnFx"])
{
strFileName += oRslt["Dnum"];
if(oRslt["DocN"])
strFileName;
}
strFileName += ".pdf";
}
dialog.load({"SvFl":strFileName});
}
//</CodeAbove>
global.DocNumAction =
{
result:"cancel",
DoDialog: function(){return app.execDialog(this);},
strHorzPos:"PosR",
nMarginX:"0.5",
strVertPos:"PosT",
nMarginY:"0.5",
strLTyp:"",
strBackgroundCol:["Transparent"],
strExmp:"",
strLabelPrefix:"\r",
bIncludeDocNum:true,
strInitDocNum:"1",
bIncludePageNum:true,
strPageNumPrefix:"",
bPageNumPostfix:true,
strBoxStateSel:"Fltn",
strPgRangeSel:"rAll",
strStrtPg:"",
strEndPg:"",
bSaveWPostFx:true,
strSavePrefix:"",
strDocNumInName:"None",
strSavePostfix:"",
strSvFl:"",
GetRadioSel:function(oRslts,aCtrls){
for(var strRtn=aCtrls[0];aCtrls.length>0;strRtn=aCtrls.pop()){
if(oRslts[strRtn] == true)
return strRtn;
}
return "";
},
SetListSel:function(list,path){if(path.length == 0) return;
eval("list[\""+ ((typeof path.join != "function")?path:path.join("\"][\"")) + "\"] = 1")},
GetListSel:function(oLstRslts,path){
for(var item in oLstRslts){
if( ((typeof oLstRslts[item]=="number")&&(oLstRslts[item]>0))
|| this.GetListSel(oLstRslts[item],path) )
{path.push(item);return true;}
}
return false;
},
nCurPage:0,
nNumPages:1,
bHidden:true,
SetDocNumber:DoSetDocNumberFn,
SetFileName:DoSetFileName,
strFileName:"Test.pdf",
oDocNumParams:oDocNumTypes,
initialize: function(dialog)
{
var listLTyp = new Object();
this.SetListSel(listLTyp, this.strLTyp);
var listBkgd =
{
"Transparent": -1,
"Yellow": -1,
"Green": -1,
"Blue": -1,
"Grey": -1,
};
this.SetListSel(listBkgd, this.strBackgroundCol);
var dlgInit =
{
"MrgH": this.nMarginX,
"MrgV": this.nMarginY,
"Bkgd": listBkgd,
"DNum": this.strInitDocNum,
"SPst": this.bSaveWPostFx,
"Exmp": this.strExmp,
"LPfx": this.strLabelPrefix,
"DocN": this.bIncludeDocNum,
"PgNm": this.bIncludePageNum,
"PPfx": this.strPageNumPrefix,
"PPsf": this.bPageNumPostfix,
"tFPg": this.strStrtPg,
"tTPg": this.strEndPg,
"SvPr": this.strSavePrefix,
"SvPs": this.strSavePostfix,
"SvFl": this.strSvFl,
};
dlgInit[this.strHorzPos] = true;
dlgInit[this.strVertPos] = true;
dlgInit[this.strBoxStateSel] = true;
dlgInit[this.strPgRangeSel] = true;
dlgInit[this.strDocNumInName] = true;
dialog.load(dlgInit);
dialog.enable(
{
"tTPg": false,
"tFPg": false,
"PPfx": false,
"DNum": false,
}
);
var typeInit = {};
for(xx in this.oDocNumParams)
typeInit[xx] = -1;
if( (this.strStrtPg == "")|| isNaN(this.strStrtPg) || (Number(this.strStrtPg) > this.nNumPages) )
{
if(this.bHidden)
this.strStrtPg = "1";
else
this.strStrtPg = (this.nCurPage+1).toString();
}
if((this.strEndPg == "") || isNaN(this.strEndPg) || (Number(this.strEndPg) > this.nNumPages) )
this.strEndPg = this.nNumPages.toString();
var exInit ={"LTyp":typeInit,"tFPg": this.strStrtPg,"tTPg":this.strEndPg, "sOfN":"of (" + this.nNumPages+")",
"FlNm":"Current File: " + this.strFileName};
if(this.bHidden && this.strPgRangeSel == "rCur")
{
this.strPgRangeSel = "rAll";
exInit["rCur"] = false;
exInit[this.strPgRangeSel] = true;
}
dialog.load(exInit);
var exInit = {"ExPg":this.strPgRangeSel =="rFro", "DNum":this.bIncludeDocNum, "PPfx":this.bIncludePageNum,
"PPsf":this.bIncludePageNum, "MrgH":this.strHorzPos!="PosC", "MrgV":this.strVertPos!="PosM",
"SvPs":this.bSaveWPostFx ,"SvDn":this.bSaveWPostFx,
"tFPg":this.strPgRangeSel =="rFro", "tTPg":this.strPgRangeSel == "rFro", "rCur":!this.bHidden};
dialog.enable(exInit);
this.SetDocNumber(dialog, this);
},
validate: function(dialog)
{
var oRslt = dialog.store();
if(oRslt["DocN"] && ( (oRslt["DNum"] == null) || (oRslt["DNum"] == "") || isNaN(oRslt["DNum"]) ) )
{
app.alert("If selected, the initial Value for Doc Number must be filled out with a valid integer");
return false;
}
if( ( /^\s*$/).test(oRslt["LPfx"]) && !oRslt["DocN"] && !oRslt["PgNm"])
{
app.alert("Not Enough Label Parameters have been selected");
return false;
}
if(oRslt["rFro"])
{
if( (oRslt["tFPg"] == "") || isNaN(oRslt["tFPg"]) || (oRslt["tTPg"] == "") || isNaN(oRslt["tTPg"]) )
{
app.alert("If selected, the Page range values must be filled out with valid integers");
return false;
}
if(Number(oRslt["tFPg"]) > Number(oRslt["tTPg"]) )
{
app.alert("If selected, the From page number must be less than the To page Number");
return false;
}
if( (Number(oRslt["tFPg"]) > this.nNumPages) || (Number(oRslt["tTPg"]) > this.nNumPages) )
{
app.alert("If selected, the From and To page numbers must be less than the number of pages");
return false;
}
}
return true;
},
commit: function(dialog)
{
var oRslt = dialog.store();
this.strHorzPos = this.GetRadioSel(oRslt,["PosL","PosC","PosR"]);
this.nMarginX = oRslt["MrgH"];
this.strVertPos = this.GetRadioSel(oRslt,["PosT","PosM","PosB"]);
this.nMarginY = oRslt["MrgV"];
var path = new Array();
this.strLTyp = (this.GetListSel(oRslt["LTyp"],path))?path.reverse():"";
var path = new Array();
this.strBackgroundCol = (this.GetListSel(oRslt["Bkgd"],path))?path.reverse():"";
this.strExmp = oRslt["Exmp"];
this.strLabelPrefix = oRslt["LPfx"];
this.bIncludeDocNum = oRslt["DocN"];
this.strInitDocNum = oRslt["DNum"];
this.bIncludePageNum = oRslt["PgNm"];
this.strPageNumPrefix = oRslt["PPfx"];
this.bPageNumPostfix = oRslt["PPsf"];
this.strBoxStateSel = "Fltn"
this.strPgRangeSel = this.GetRadioSel(oRslt,["rAll","rCur","rFro"]);
this.strStrtPg = oRslt["tFPg"];
this.strEndPg = oRslt["tTPg"];
this.bSaveWPostFx = oRslt["SPst"];
this.strSavePrefix = oRslt["SvPr"];
this.strDocNumInName = this.GetRadioSel(oRslt,["None","DnPr","DnFx"]);
this.strSavePostfix = oRslt["SvPs"];
this.strSvFl = oRslt["SvFl"];
},
"Abrt": function(dialog)
{
dialog.end("Abrt");
},
"Skip": function(dialog)
{
dialog.end("Skip");
},
"SvPs": function(dialog)
{
this.SetFileName(dialog,this);
},
"DnFx": function(dialog)
{
this.SetFileName(dialog,this);
},
"DnPr": function(dialog)
{
this.SetFileName(dialog,this);
},
"None": function(dialog)
{
this.SetFileName(dialog,this);
},
"SvPr": function(dialog)
{
this.SetFileName(dialog,this);
},
"SPst": function(dialog)
{
var bOn = dialog.store()["SPst"];
dialog.enable({"SvPs":bOn ,"SvDn":bOn });
this.SetFileName(dialog,this);
},
"tTPg": function(dialog)
{
var x;
},
"rFro": function(dialog)
{
dialog.enable({tFPg:true, tTPg:true, "ExPg":true});
},
"rCur": function(dialog)
{
dialog.enable({tFPg:false, tTPg:false,"ExPg":false});
},
"rAll": function(dialog)
{
dialog.enable({tFPg:false, tTPg:false, "ExPg":false});
},
"PPsf": function(dialog)
{
this.SetDocNumber(dialog,this);
},
"PPfx": function(dialog)
{
this.SetDocNumber(dialog,this);
},
"PgNm": function(dialog)
{
var bIsOn = dialog.store()["PgNm"];
dialog.enable({"PPfx":bIsOn,"PPsf":bIsOn});
this.SetDocNumber(dialog,this);
},
"DNum": function(dialog)
{
this.SetDocNumber(dialog,this);
},
"DocN": function(dialog)
{
dialog.enable({"DNum":dialog.store()["DocN"]});
this.SetDocNumber(dialog,this);
},
"LPfx": function(dialog)
{
this.SetDocNumber(dialog,this);
},
"LTyp": function(dialog)
{
var oRslt = dialog.store();
var path = [];
var cSel = ((this.GetListSel(oRslt["LTyp"],path))?path.reverse():"").toString();
var oLabInfo = this.oDocNumParams[cSel];
if(!oRslt["DNum"] || (oRslt["DNum"] == "") || isNaN(oRslt["DNum"]))
dialog.load({"DNum":"1"});
if(oLabInfo)
{
dialog.load({"LPfx":oLabInfo.Prefix, "DocN":oLabInfo.UseDocNum, "PgNm":oLabInfo.UsePgNum, "PPfx":oLabInfo.PagePrefix});
dialog.enable({"DNum":oLabInfo.UseDocNum, "PPfx":oLabInfo.UsePgNum, "PPsf":oLabInfo.UsePgNum});
this.SetDocNumber(dialog,this);
}
},
"PosB": function(dialog)
{
dialog.enable({"MrgV":true});
},
"PosM": function(dialog)
{
dialog.enable({"MrgV":false});
},
"PosT": function(dialog)
{
dialog.enable({"MrgV":true});
},
"PosR": function(dialog)
{
dialog.enable({"MrgH":true});
},
"PosC": function(dialog)
{
dialog.enable({"MrgH":false});
},
"PosL": function(dialog)
{
dialog.enable({"MrgH":true});
},
description:
{
name: "Automatic Batch Labeling Application",
elements:
[
{
type: "view",
elements:
[
{
type: "view",
alignment: "align_fill",
elements:
[
{
type: "view",
height: 14,
align_children: "align_top",
elements:
[
{
type: "static_text",
item_id: "FlNm",
name: "Please enter the information for applying document numbering labels to:",
height: 14,
font: "palette",
bold: true,
},
{
type: "static_text",
item_id: "sta1",
name: "Version 1.4 - 7/1/16 SCS/CA",
height: 14,
alignment: "align_right",
},
]
},
{
type: "cluster",
item_id: "cls2",
name: "ENTER LABEL INFORMATION",
font: "palette",
bold: true,
elements:
[
{
type: "view",
align_children: "align_row",
elements:
[
{
type: "static_text",
item_id: "sta3",
name: "1. Select Document Type:",
},
{
type: "popup",
item_id: "LTyp",
variable_Name: "strLTyp",
width: 93,
height: 23,
char_width: 8,
},
{
type: "gap",
item_id: "gap2",
char_width: 1,
char_height: 4,
},
{
type: "static_text",
item_id: "sta1",
name: "2. Select Background:",
},
{
type: "popup",
item_id: "Bkgd",
variable_Name: "strBackgroundCol",
width: 86,
height: 23,
char_width: 8,
},
]
},
{
type: "view",
align_children: "align_top",
elements:
[
{
type: "static_text",
item_id: "sta5",
name: "3. Add Label Information before selected Doc Type:",
height: 15,
},
{
type: "edit_text",
item_id: "LPfx",
variable_Name: "strLabelPrefix",
width: 200,
height: 75,
multiline:true,
char_width: 8,
},
]
},
{
type: "view",
align_children: "align_top",
elements:
[
{
type: "static_text",
item_id: "sta6",
name: "4. Enter Starting Doc # (defaults to 1):",
},
{
type: "edit_text",
item_id: "DNum",
variable_Name: "strInitDocNum",
char_width: 3,
},
]
},
{
type: "view",
align_children: "align_row",
elements:
[
{
type: "check_box",
item_id: "DocN",
name: "Include Doc # (default)",
variable_Name: "bIncludeDocNum",
alignment: "align_fill",
},
{
type: "static_text",
item_id: "sta7",
name: "Enter Page Prefix (or use default):",
},
{
type: "edit_text",
item_id: "PPfx",
variable_Name: "strPageNumPrefix",
char_width: 8,
},
{
type: "check_box",
item_id: "PgNm",
name: "Include Page # (default)",
variable_Name: "bIncludePageNum",
alignment: "align_fill",
},
{
type: "check_box",
item_id: "PPsf",
name: "Include \"of N\" pages",
variable_Name: "bPageNumPostfix",
alignment: "align_fill",
},
]
},
{
type: "view",
align_children: "align_top",
elements:
[
{
type: "static_text",
item_id: "sta8",
name: "Label Preview:",
font: "palette",
},
{
type: "edit_text",
item_id: "Exmp",
width: 250,
height: 75,
char_width: 8,
multiline: "true",
readonly: "true",
},
]
},
]
},
{
type: "cluster",
item_id: "cls3",
name: "SELECT PAGE RANGE",
font: "palette",
bold: true,
elements:
[
{
type: "view",
align_children: "align_row",
elements:
[
{
type: "radio",
item_id: "rAll",
group_id: "GRP1",
name: "All",
variable_Name: "strPgRangeSel",
height: 20,
},
{
type: "radio",
item_id: "rCur",
group_id: "GRP1",
name: "Current (Applies only to Open Document)",
variable_Name: "strRange",
height: 20,
},
{
type: "radio",
item_id: "rFro",
group_id: "GRP1",
name: "From:",
width: 12,
height: 24,
},
{
type: "edit_text",
item_id: "tFPg",
variable_Name: "strStrtPg",
height: 24,
char_width: 6,
},
{
type: "static_text",
item_id: "sta1",
name: "To:",
height: 24,
},
{
type: "edit_text",
item_id: "tTPg",
variable_Name: "strEndPg",
height: 24,
char_width: 6,
},
{
type: "static_text",
item_id: "sOfN",
name: "of (N) ",
height: 24,
},
]
},
]
},
]
},
{
type: "cluster",
item_id: "cls1",
name: "SELECT POSITION",
width: 188,
height: 80,
font: "palette",
bold: true,
char_width: 8,
char_height: 8,
elements:
[
{
type: "view",
align_children: "align_top",
elements:
[
{
type: "radio",
item_id: "PosL",
group_id: "PosH",
name: "Left",
variable_Name: "strHorzPos",
},
{
type: "radio",
item_id: "PosC",
group_id: "PosH",
name: "Center",
},
{
type: "radio",
item_id: "PosR",
group_id: "PosH",
name: "Right ",
},
{
type: "static_text",
item_id: "sta2",
name: " Margin (inches):",
},
{
type: "edit_text",
item_id: "MrgH",
variable_Name: "nMarginX",
char_width: 8,
},
]
},
{
type: "view",
align_children: "align_top",
elements:
[
{
type: "radio",
item_id: "PosT",
group_id: "PosV",
name: "Top ",
variable_Name: "strVertPos",
},
{
type: "radio",
item_id: "PosM",
group_id: "PosV",
name: "Middle",
},
{
type: "radio",
item_id: "PosB",
group_id: "PosV",
name: "Bottom",
},
{
type: "static_text",
item_id: "sta1",
name: "Margin (inches):",
},
{
type: "edit_text",
item_id: "MrgV",
variable_Name: "nMarginY",
char_width: 8,
},
]
},
]
},
{
type: "cluster",
item_id: "cls1",
name: "SAVE OPTIONS",
font: "palette",
bold: true,
alignment: "align_fill",
elements:
[
{
type: "view",
align_children: "align_top",
elements:
[
{
type: "check_box",
item_id: "SPst",
name: "Save File",
variable_Name: "bSaveWPostFx",
},
{
type: "static_text",
item_id: "sta9",
name: "Enter Doc Type to saved File Name (optional):",
},
{
type: "edit_text",
item_id: "SvPr",
variable_Name: "strSavePrefix",
width: 73,
height: 23,
char_width: 8,
alignment: "align_fill",
},
{
type: "static_text",
item_id: "sta3",
name: "Include Doc # in saved File Name (optional):",
},
{
type: "radio",
item_id: "None",
group_id: "SvDN",
name: "No",
variable_Name: "strDocNumInName",
},
{
type: "radio",
item_id: "DnPr",
group_id: "SvDN",
name: "Yes",
},
]
},
{
type: "view",
align_children: "align_top",
alignment: "align_top",
elements:
[
{
type: "ok",
ok_name: "Apply Label and Save",
},
{
type: "button",
item_id: "Skip",
name: "Skip this Doc",
},
{
type: "button",
item_id: "Abrt",
name: "Cancel",
},
{
type: "static_text",
item_id: "sta1",
name: " File Name:",
alignment: "align_right",
},
{
type: "edit_text",
item_id: "SvFl",
width: 295,
height: 23,
char_width: 8,
readonly: "true",
},
]
},
]
},
]
},
]
}
};
global.DoPlaceDocNumbers = app.trustedFunction(function(oOrigDoc)
{
app.beginPriv();
// Setup starting parameters
var oTrgDoc = oOrigDoc;
var nPgStart, nPgEnd, nPgTrgStart;
var cBkCol = ["T"];
switch(global.DocNumAction.strBackgroundCol.toString())
{
case "Transparent":
cBkCol = ["T"];
break;
case "Yellow":
cBkCol = ["RGB",1,1,0];
break;
case "Green":
cBkCol = ["RGB",0,1,0];
break;
case "Blue":
cBkCol = ["RGB",0,0,1];
break;
case "Grey":
cBkCol = ["RGB",.7,.7,.7];
break;
case "White":
cBkCol = ["RGB",1,1,1];
break;
}
switch(global.DocNumAction.strPgRangeSel)
{
case "rAll":
nPgTrgStart = nPgStart = 0;
nPgEnd = oOrigDoc.numPages -1;
break;
case "rCur":
nPgTrgStart = nPgEnd = nPgStart = oOrigDoc.hidden?0:oOrigDoc.pageNum;
break;
case "rFro":
nPgTrgStart = nPgStart = Number(global.DocNumAction.strStrtPg)-1;
if(nPgTrgStart > (oOrigDoc.numPages -1))
nPgTrgStart = oOrigDoc.numPages -1;
nPgEnd = Number(global.DocNumAction.strEndPg)-1;
if(nPgEnd > (oOrigDoc.numPages -1))
nPgEnd = oOrigDoc.numPages -1;
break;
}
// Start Labeling Loop
var nNumPages = nPgEnd - nPgStart + 1;
var nCurPgNum = nPgStart;
for(var nPg=0;nPg<nNumPages;nPg++,nCurPgNum++,nPgTrgStart++)
{
// Create text Label
var strExample = global.DocNumAction.strLabelPrefix;
if(global.DocNumAction.bIncludeDocNum)
strExample += global.DocNumAction.nCurrentDocNum;
if(global.DocNumAction.bIncludePageNum)
{
strExample += eval("'" + global.DocNumAction.strPageNumPrefix + "'") + (nCurPgNum + 1).toString();
if(global.DocNumAction.bPageNumPostfix)
strExample += " of " + oOrigDoc.numPages;
}
// Find Placement location on Page
// get basic params
var rcPage = oOrigDoc.getPageBox("Crop",nCurPgNum);
var mxToDefaultCoords = (new Matrix2D()).fromRotated(oOrigDoc,nCurPgNum);
var nPgRot = oOrigDoc.getPageRotation(nCurPgNum);
var rcRot = [];
var nAlign;
var nMargX = Number(global.DocNumAction.nMarginX) * 72;
switch(global.DocNumAction.strHorzPos)
{
case"PosL":
strAlign = "left"; // Left Aligned Text
rcRot[0] = nMargX;
rcRot[2] = nMargX + nLabWidth;
break;
case"PosC":
strAlign = "center"; // Left Aligned Text
rcRot[0] = rcPage[2]/2 - nLabWidth/2;
rcRot[2] = rcPage[2]/2 + nLabWidth/2;
break;
case"PosR":
strAlign = "right"; // Left Aligned Text
rcRot[0] = rcPage[2] - nMargX - nLabWidth;
rcRot[2] = rcPage[2] - nMargX;
break;
}
// Find number of lines
var nMargY = Number(global.DocNumAction.nMarginY) * 72;
var nLines = 1;
var oMtch = strExample.match(/(\n)/g);
if(oMtch)
nLines += oMtch.length;
var bxHght = nLines * (nLabLineHeight + 1);
switch(global.DocNumAction.strVertPos)
{
case"PosT":
rcRot[1] = rcPage[1] - nMargY - bxHght;
rcRot[3] = rcPage[1] - nMargY;
break;
case"PosM":
rcRot[1] = (rcPage[1] - bxHght)/2;
rcRot[3] = (rcPage[1] + bxHght)/2;
break;
case"PosB":
rcRot[1] = nMargY;
rcRot[3] = nMargY + bxHght;
break;
}
var rectAnnot = mxToDefaultCoords.transform(rcRot);
// Look for an existing annot and delete if it exists
var annot = oTrgDoc.getAnnot(nPgTrgStart,"DocNumberLabel");
if(annot)
annot.destroy();
// Create annotation
strExample = strExample.replace(/\r\n/g,"\r");
oTrgDoc.addAnnot({type:"FreeText",page:nPgTrgStart, rect:rectAnnot,
rotate:nPgRot, width:0, fillColor:cBkCol,
readOnly:global.DocNumAction.strBoxStateSel == "Lckd",
richContents:[{textColor:["RGB",0,0,0],textSize:nLabLineHeight,
alignment:strAlign, text:strExample}],
name:"DocNumberLabel"
});
}
// If selected then Flatten
if(global.DocNumAction.strBoxStateSel == "Fltn")
oTrgDoc.flattenPages();
// Save File
if(global.DocNumAction.bSaveWPostFx)
{
var cSavePath = oOrigDoc.path.replace(/\/[^\/]+$/,"/");
var cDocPrefix;
cDocPrefix = global.DocNumAction.strLabelPrefix;
// Document number as prefix
cSavePath += global.DocNumAction.strSavePrefix;
if(global.DocNumAction.strDocNumInName == "DnPr")
{
if(global.DocNumAction.bIncludeDocNum)
cSavePath += global.DocNumAction.nCurrentDocNum += "_";
}
cSavePath += oOrigDoc.documentFileName.replace(/\.pdf/,"");
//Document number as prostfix
if(global.DocNumAction.strDocNumInName == "DnFx")
{
if(global.DocNumAction.bIncludeDocNum)
cSavePath += global.DocNumAction.nCurrentDocNum;
}
cSavePath += ".pdf";
oTrgDoc.saveAs(cSavePath);
}
app.endPriv();
});
}
var DoNumActionDlg = app.trustedFunction(function()
{
app.beginPriv();
return app.execDialog(global.DocNumAction);
app.endPriv();
});
// Setup
var oDoc = event.target;
if(oDoc.xfa)
{
if(3 == app.alert(oDoc.documentFileName + ": is a LiveCycle Form, which cannot be labeled\n\n Do you want to continue processing files? (Pressing No will Abort the file processing)",1,2))
event.rc = false;
}
else
{
global.DocNumAction.bHidden = oDoc.hidden;
if(!oDoc.hidden)
global.DocNumAction.nCurPage = oDoc.pageNum;
else
global.DocNumAction.nCurPage = 0;
global.DocNumAction.nNumPages = oDoc.numPages;
global.DocNumAction.strFileName = oDoc.documentFileName;
var cRtn = DoNumActionDlg();
if("ok" == cRtn)
{
// Setup Initial Doc Number
if(global.DocNumAction.bIncludePageNum)
global.DocNumAction.nCurrentDocNum = Number(global.DocNumAction.strInitDocNum);
console.println("Do " + oDoc.documentFileName);
global.DoPlaceDocNumbers(oDoc);
// Increment Doc Number if applicable
if(global.DocNumAction.bIncludeDocNum)
{
global.DocNumAction.nCurrentDocNum++;
global.DocNumAction.strInitDocNum = global.DocNumAction.nCurrentDocNum.toString();
}
}
else if("Abrt" == cRtn)
event.rc = false;
}
I assume this comes from the Actions Exchange on AcrobatUsers.com. Are you getting the error with the unmodified script as well? If not, what have you changed in the code (and for what purpose)?
Your subject line refers to a NaN error - how does that factor into this problem?
A "NaN" error is thrown when a "Not a Number" condition occurs, that can for example be that you are trying to perform an operation that can only be done with a number on a string, or if you try to divide by zero.
Copy link to clipboard
Copied
Sorry, the actual error I get is:
"If selected, the initial Value for Doc Number must be filled out with a valid integer")
Not the one documented in the initial post.
validate: function(dialog)
{
var oRslt = dialog.store();
if(oRslt["DocN"] && ( (oRslt["DNum"] == null) || (oRslt["DNum"] == "") || isNaN(oRslt["DNum"]) ) )
{
app.alert("If selected, the initial Value for Doc Number must be filled out with a valid integer");
return false;
}
Copy link to clipboard
Copied
I assume this comes from the Actions Exchange on AcrobatUsers.com. Are you getting the error with the unmodified script as well? If not, what have you changed in the code (and for what purpose)?
Your subject line refers to a NaN error - how does that factor into this problem?
A "NaN" error is thrown when a "Not a Number" condition occurs, that can for example be that you are trying to perform an operation that can only be done with a number on a string, or if you try to divide by zero.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now