Quantcast
Channel: Adobe Community : Popular Discussions - InDesign Scripting
Viewing all articles
Browse latest Browse all 15932

Modifying an old script from Dave Saunders

$
0
0

I've gotten permission from Dave Saunders to ask someone here to help modify a script he wrote way back when.

 

The script is posted at:

 

http://pdsassoc.com/downloads/PDFimportCropPref.jsx.zip

 

The purpose of the script is to change the Crop options of an already placed PDF (includes AI and INDD) file.

 

The script was written in 2006 for CS2 and so it doesn't work in today's environment.

 

I'm posting a copy of the text in the hope it doesn't get garbled.

 

//DESCRIPTION: Allows user to change PDF-import cropping preference

/*
©Copyright 2006 PDS Associates

This script must not be distributed without first obtaining written permission of:

Dave Saunders, proprietor
PDS Associates
P.O. Box 127
Allenhurst, NJ 07711-0127

e-mail: davesaunders@pdsassoc.com
*/

// Destroy any existing dialogs
if (app.dialogs.length > 0) app.dialogs.everyItem().destroy();
interactWithAll();
curSetting = app.pdfPlacePreferences.pdfCrop;
userChooses = askUser(curSetting);
app.pdfPlacePreferences.pdfCrop = userChooses

// +++++++ Functions Start Here +++++++++++++++++++++++

function interactWithAll() {
if (app.version == 3) {
app.userInteractionLevel = UserInteractionLevels.interactWithAll;
} else {
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
}
}

function askUser(curValue){
var cropChoices = ["Art", "Bleed", "Content", "Media", "PDF", "Trim"];
var cropValues = [1131573313, 1131573314, 1131573315, 1131573325, 1131573328, 1131573332];
cv = -1;
for (var j = cropValues.length – 1; j >= 0; j–) {
if (curValue == cropValues[j]) {
cv = j;
continue
}
}
if (cv == -1) errorExit(“Current value of crop preference not recognized”);
with (app.dialogs.add({name:”Place PDF Crop Preference”})) {
with (dialogColumns.add()) {
with (dialogRows.add()) {
staticTexts.add({staticLabel:”Choose preference:”});
uchoose = dropdowns.add({stringList:cropChoices, selectedIndex:cv})
}
}
app.activate();
if (!show()) {
// User canceled;
destroy();
exit()
} else {
value = cropValues[uchoose.selectedIndex];
destroy();
}
return value
}
}

function errorExit(message) {
if (arguments.length > 0) {
if (app.version != 3) { beep() } // CS2 includes beep() function.
alert(message);
}
exit(); // CS exits with a beep; CS2 exits silently.
}

 

If you are interested in this challenge, your modified script will be mentioned at InDesignSecrets.com where we can link to your download page as well as extoll the brilliance of your scripting abilities. Sorry, no money, just glory.

 

Send me a message at Sandee at mac dot com if you want to tackle the script.

 

Thanks


Viewing all articles
Browse latest Browse all 15932

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>