I need to add in a page size text variable to my already working .jsx script
Hi all,
I was wondering if any of you scripters would know how to add in a piece of code that would allow me to generate a page size variable,
I have already found a script that adds in a user name to my slug but i dont know how to add one for page size as im not fluent in JavaScript.
Any help would be much appreciated!! see current script below:
----------------------------------------------------------------------------------
#targetengine 'usernameVariable'
//This function adds static text variables in InDesign
//They won't be dynamically updated though.
//That's why we need the updating function below
function addVariables(openEvent){
var doc = openEvent.parent;
while ( doc.constructor.name != "Document" )
{
if ( doc.constructor.name == "Application" ){ return; }
doc = doc.parent;
}
//Adding User name to text variables
createTextVariable(doc, "User name", (Folder.myDocuments).parent.displayName );
//Adding Computer name to text variables
createTextVariable(doc, "HD Name", (Folder.system).parent.displayName );
//Adding Computer name to text variables
createTextVariable(doc, "Computer Name", getComputerName() );
//Adding a link to my website ![]()
createTextVariable(doc, "_About Loic Aigon", "Feel free to visit my website: http://www.loicaigon.com !" );
}
//Generic function to add static custom text variables
function createTextVariable(target, variableName, variableContents){
var usernameVariable = target.textVariables.itemByName(variableName);
if(!usernameVariable.isValid){
usernameVariable = target.textVariables.add();
usernameVariable.variableType = VariableTypes.CUSTOM_TEXT_TYPE;
usernameVariable.name = variableName;
}
usernameVariable.variableOptions.contents = variableContents;
}
//Snippet for grabbing the deep name of the computer
function getComputerName(){
var APLScript = "get computer name of (system info)";
var VBScript = "Dim wshShell\
Set wshShell = CreateObject( \"WScript.Shell\" )\
strComputerName = wshShell.ExpandEnvironmentStrings( \"%COMPUTERNAME%\" )\
app.scriptArgs.SetValue \"computerName\", strComputerName";
var scpt = (File.fs=="Windows")? VBScript : APLScript;
var language = (File.fs=="Windows")? ScriptLanguage.visualBasic : ScriptLanguage.APPLESCRIPT_LANGUAGE;
var scriptResult = app.doScript(scpt, language);
var computerName = (File.fs=="Windows")? app.scriptArgs.getValue("computerName") : scriptResult;
return computerName;
}
//Add listeners to update file when opened.
app.addEventListener('afterOpen', addVariables);
