Quantcast
Channel: Adobe Community : All Content - InDesign Scripting
Viewing all 8771 articles
Browse latest View live

Reveal in finder set label

$
0
0

I'm trying to set up a script that takes the selected image and changes the color label to red in the finder. Is this even possible? I can set the finder label to red using applescript but only on selected images in the finder. Perhaps I could reveal the image in the finder and then run the applescript. How do I access the Reveal selected image in finder through script? Any help would be much appreciated.

 

tell application "Finder"

  set thisItem to selection as alias

  if label index of thisItem = 0 then

    set the label index of thisItem to 2 -- 2 = red

  else

    set label index of thisItem to 0 -- 0 = no label

  end if

end tell


Find cyan value

$
0
0

Hi forum,

 

I need a great help from you.

 

There are number of filled items on a page.

 

And i do want to get Alert,  the value of Cyan inside a swatch.

 

Any possible to get this.

 

thanks...forum....

Its possible to change text frame contents inside group...???

$
0
0

Hi Everyone,

 

I'm newbibe to Indesign forums.

 

I had grouped image placed on rectangle and text frame. now i need change text frame content using indesign Javascript

 

Its possible to change text frame contents inside group..?

 

 

-yajiv

how to recognize page of a selected item

$
0
0

Hello to all

 

 

I would like to know how to recognize page of a selected item in javascript

 

 

thanks

extract paragraph style name with formating

$
0
0

All

 

kindly help me How to extract ParagraphStyle name with formating to Sample.txt:

 

EG:

 

Style Name: "Body"

Font = "15"

leading = '"18"

Aligh = "Left"

 

etc...

 

Regards

Hurix

 

Edit by Dave Saunders: Something is preventing the Reply button from working. I'm hoping this edit will reactivate it.

Find untag contents in XML workflow

$
0
0

Hi All,

 

Is it possible to find the untag contents in the xml workflow??

 

untag.png

(i.e.,) I need to alert the paragraph start with "Feria vendaepudae........" having untag contents.

 

Kindly help to find the solution.

 

Regards

Siraj

Existing Applescripts CS6/CC wont compile

$
0
0

I have some applescripts that i've been using in Indd that wont compile anymore.

I've been using these scripts for years now, but now need to make minor edits.

I can run the scripts and they work ok, but even after opening right away, I cant compile.

my first  2 lines are

tellapplication "Adobe InDesign CS6"

          setmyDocumentto active document

 

Even if I just open and right away compile, it highlights "document" in "active document"

and I get "Syntax Error Expected end of line but found class name. (OK)"

 

I recent upgraded to maverics is that anything to do with it?

I'm still pretty much a beginner when it comes to applescript.

 

I originally created these is CS5 also, which I no longer have, if that is anything to do with it.

AS Replace OpenType All Small Caps with Normal Small Caps

$
0
0

Forgive me, but AppleScript (and JavaScript for that matter) is confounding me at every turn. This is a very simple thing, but I can't for the life of me find anything online or in documentation to give me even the slightest clue how to code it. There's nothing in the AppleScript dictionary for InDesign CS6 that shows anything for "all small caps".

 

I want AppleScript code that looks for OpenType All Small Caps and changes it to normal Small Caps.

 

Period. Simple. But I'm at a loss.


Loop Page Style Sheet to set file name.

$
0
0

I am exporting pages to jpgs and pngs using a script that pulls the name from an applied style sheet.

 

http://forums.adobe.com/message/5913479#5913479

 

the above works perfectly if I only want to specify one style sheet as the file name.

the challenge may need to use different style sheets on each page to create the name.

 

I am not sure how to loop through each page and grab the style in play.

or if I need to loop at all.

 

This is where I am...

 

function MakePNGfile()


{
     for(var myCounter = 0; myCounter < myDoc.pages.length; myCounter++)     {          if (myDoc.pages.item(myCounter).appliedSection.name != "")         {               myDoc.pages.item(myCounter).appliedSection.name = "";         }      var myStyle1 = "sheetlabel-text";      var myStyle2 = "sheetlabel-text-2";      var myParagraphs = myDoc.pages.item(0).textFrames.item(0).parentStory.paragraphs;           var myPageName = myDoc.pages.item(myCounter).name;      var myPNGPrefix = "";     {     for( i = 0; i < myParagraphs.length; i++)     {         var paragraph = myParagraphs.item(i);


if (paragraph = myStyle1)


{
    (myPNGPrefix = getParagraphContent(myDoc.paragraphStyles.item("sheetlabel-text"),  myDoc.pages.item(myCounter))+ '-0' + myPageName)
}
else
{    (myPNGPrefix = getParagraphContent(myDoc.paragraphStyles.item("sheetlabel-text-2"),  myDoc.pages.item(myCounter))+ '-0' + myPageName)
};     }          


}

 

Thanks for your help!

Change Color of single Character

$
0
0

Hi everyone,

 

I'm new to AppleScript. Been trying to figger out how to write the script I need, but I've beeb trying in vain.

 

I have a InDesign of around 40 pages and I would like to change the color from black to white of all the found "a"

on the first page, of all the found "b" on the second page etc.

 

So actually find one letter (a or b or c etc.) and change the color to white.

 

Can anybody help me?

 

Thanks in advance

Sarah

HELP! InDesign CC got an error: The property is not applicable in the current state." number 30615

$
0
0

HELP! Was working perfectly now it is giving me this error and doesn't seem to be going past the printing option. Code is below.

 

 

 

main.scpt

 

setposixIdPathto "/Applications/Adobe InDesign CC/Adobe InDesign CC.app"

do shell script "/Users/cdapice/Desktop/cryptoquip/getquip.sh"

delay 8

tellapplicationposixIdPath

activate

endtell

delay 8

setscripttoRunto ":Users:cdapice:Desktop:cryptoquip:Script.jsx" asalias

tellapplication "Adobe InDesign CC"

do scriptscripttoRunlanguagejavascript

endtell

delay 5

 

Adobe InDesign CC got an error: The property is not applicable in the current state." number 30615

 

 

 

Script.jsx

 

var myDocument = app.open(File("/Users/cdapice/Desktop/cryptoquip/NewCryptoquip.indt"), true);

//var myDocument = app.activeDocument;

 

 

var myPage = myDocument.pages.item(0);

var myTextFrame = myPage.textFrames.add();

//Place a text file in the text frame.

//Parameters for TextFrame.place():

//File as File object,

//[ShowingOptions as Boolean = False]

//You'll have to fill in your own file path.

myTextFrame.place(File("/Users/cdapice/Desktop/cryptoquip/quips.txt"));

 

 

//var myTextFrame = app.selection[0];

myTextFrame.parentStory.pointSize = 10;

var brkStory = myTextFrame.parentStory.contents;

var myPIs = myDocument.pageItems;

 

 

var  destTextFrame = myPIs[6];

 

 

destTextFrame.parentStory.contents = brkStory;

 

 

firstChange();

 

 

myTextFrame.remove();

 

 

app.select(destTextFrame);

 

 

splitStory();

 

 

for (i = 0; i < myPIs.length; i++) {

          if (myPIs[i].appliedObjectStyle.name == "puzzleBox") {

                    var newBoxStyle = myPIs[i].appliedObjectStyle;

                    secondChange(myPIs[i]);

        myPIs[i].applyObjectStyle(newBoxStyle,true);

          }

    if(myPIs[i].appliedObjectStyle.name == "otherBox"){

        var newBoxStyle = myPIs[i].appliedObjectStyle;

        myPIs[i].applyObjectStyle(newBoxStyle,true);

        }

}

 

 

 

 

Date.prototype.getMonthFormatted = function() {

    var month = this.getMonth() + 1;

    var formMonth = month < 10 ? '0' + month : month; // ('' + month) for string result

          return formMonth.toString();

}

Date.prototype.getDayFormatted = function() {

    var day = this.getDate();

    var formDay = day < 10 ? '0' + day : day; // ('' + day) for string result

          return formDay.toString();

}

 

 

var newdate = new Date();

var laterdate = new Date();

 

 

var dayofweek = newdate.getDay();

var offsetdays = 0;

 

 

switch(dayofweek) {

    case 2:

        offsetdays = 6;

        break;

    case 3:

        offsetdays = 5;

        break;

    case 4:

        offsetdays = 4;

        break;

    case 5:

        offsetdays = 3;

        break;

}

 

 

 

 

app.epsExportPreferences.appliedFlattenerPreset.convertAllStrokesToOutlines = true;

app.epsExportPreferences.appliedFlattenerPreset.convertAllTextToOutlines = true;

app.epsExportPreferences.appliedFlattenerPreset.rasterVectorBalance = 100;

 

 

//app.activeDocument.exportFile(ExportFormat.epsType, newFile, false);

 

 

for (i = 1; i < 7; i++) {

    var curPage = i + "";

    var x = i + (offsetdays - 1);

    laterdate.setMonth(newdate.getMonth());

    laterdate.setDate(newdate.getDate());

   

    //alert(newdate);

    //alert(x);

    //alert(laterdate);

   

    laterdate.setDate(newdate.getDate() + x);

   

    //alert(laterdate);

    var nameDate = laterdate.getMonthFormatted() + laterdate.getDayFormatted() + ".eps"

    //alert(nameDate);

   

    app.epsExportPreferences.pageRange = curPage;

    var curFile = new File("/Users/cdapice/Desktop/cryptoquip/" + nameDate);

    app.activeDocument.exportFile(ExportFormat.epsType, curFile, false);

}

 

 

var endDate = laterdate.getMonthFormatted() + laterdate.getDayFormatted();

var firstDate = new Date();

firstDate.setDate(newdate.getDate() + offsetdays);

var startDate = firstDate.getMonthFormatted() + firstDate.getDayFormatted();

 

 

var idFile = "cryptoquip_" + startDate + "_" + endDate + ".indd";

 

 

app.activeDocument.save(new File("/Users/cdapice/Desktop/cryptoquip/" + idFile));

 

 

 

 

with (app.activeDocument.printPreferences){

       

        printer = "Advertising - Creative - Color Xerox";

        copies = 1;

        pageRange = "1-6";

        paperSize = "US Letter";

        paperHeight = "11 in";

        paperWidth = "8.5 in";

        printPageOrientation = PrintPageOrientation.landscape;

        pagePosition = PagePositions.centered;

       scaleHeight = 100;

       scaleWidth = 100;

        scaleMode = ScaleModes.scaleWidthHeight;

        scaleProportional = true;

        pageInformationMarks = true;

        colorOutput = ColorOutputModes.COMPOSITE_CMYK;

}

 

 

 

 

app.activeDocument.print(false);

 

 

for(myCounter = app.documents.length; myCounter > 0; myCounter--){

app.documents.item(myCounter-1).close(SaveOptions.no);

}

 

 

function firstChange() {

          app.findTextPreferences = NothingEnum.NOTHING;

          app.changeTextPreferences = NothingEnum.NOTHING;

          app.findChangeTextOptions.caseSensitive = false;

 

 

    app.findTextPreferences.findWhat = "^t";

          app.changeTextPreferences.changeTo = "";

          myDocument.changeText();

 

 

          app.findTextPreferences = NothingEnum.NOTHING;

          app.changeTextPreferences = NothingEnum.NOTHING;

   

     app.findTextPreferences.findWhat = "^p^p";

          app.changeTextPreferences.changeTo = "^p";

          myDocument.changeText();

 

 

          app.findTextPreferences = NothingEnum.NOTHING;

          app.changeTextPreferences = NothingEnum.NOTHING;

   

          app.findTextPreferences.findWhat = "^p";

          app.changeTextPreferences.changeTo = "^R";

          myDocument.changeText();

 

 

          app.findTextPreferences = NothingEnum.NOTHING;

          app.changeTextPreferences = NothingEnum.NOTHING;

}

 

 

 

 

function secondChange(curFrame) {

          app.findTextPreferences = NothingEnum.NOTHING;

          app.changeTextPreferences = NothingEnum.NOTHING;

          app.findChangeTextOptions.caseSensitive = false;

 

 

    app.findTextPreferences.findWhat = "    ";

          app.changeTextPreferences.changeTo = "|";

          curFrame.changeText();

 

 

          app.findTextPreferences = NothingEnum.NOTHING;

          app.changeTextPreferences = NothingEnum.NOTHING;

   

     app.findTextPreferences.findWhat = " ";

          app.changeTextPreferences.changeTo = "";

          curFrame.changeText();

 

 

          app.findTextPreferences = NothingEnum.NOTHING;

          app.changeTextPreferences = NothingEnum.NOTHING;

   

          app.findTextPreferences.findWhat = "|";

          app.changeTextPreferences.changeTo = " ";

          curFrame.changeText();

 

 

          app.findTextPreferences = NothingEnum.NOTHING;

          app.changeTextPreferences = NothingEnum.NOTHING;

}

 

 

function splitStory(){

          //Make certain that user interaction (display of dialogs, etc.) is turned on.

          app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;

          if(app.documents.length != 0){

                    if(app.selection.length != 0){

                              //Get the first item in the selection.

                              var mySelection = app.selection[0];

                              //Process the selection. If text or a text frame is

                              //selected, do something; otherwise, do nothing.

                              switch(mySelection.constructor.name){

                                        case "Text":

                                        case "InsertionPoint":

                                        case "Character":

                                        case "Word":

                                        case "Line":

                                        case "TextStyleRange":

                                        case "Paragraph":

                                        case "TextColumn":

                                        case "TextFrame":

                                                  //If the text frame is the only text frame in the story, do nothing.

                                                  if(mySelection.parentStory.textContainers.length > 1){

                                                            //Splitting the story is a two-step process: first, duplicate

                                                            //the text frames, second, delete the original text frames.

                                                            mySplitStory(mySelection.parentStory);

                                                            myRemoveFrames(mySelection.parentStory);

                                                  }

                                                  else{

                                                            alert("Please select a story containing more than one text frame and try again.");

                                                  }

                                                  break;

                                        default:

                                                  alert("Please select some text or a text frame and try again.");

                              }

                    }

                    else{

                              alert("Please select some text or a text frame and try again.");

                    }

          }

          else{

                    alert("Please open a document and try again.");

          }

}

function mySplitStory(myStory){

          var myTextFrame;

          //Duplicate each text frame in the story.

          for(var myCounter = myStory.textContainers.length-1; myCounter >= 0; myCounter --){

                    myTextFrame = myStory.textContainers[myCounter];

                    myTextFrame.duplicate();

          }

}

function myRemoveFrames(myStory){

          //Remove each text frame in the story. Iterate backwards to avoid invalid references.

          for(var myCounter = myStory.textContainers.length-1; myCounter >= 0; myCounter --){

                    myStory.textContainers[myCounter].remove();

          }

}

Linked Image file path cleanup

$
0
0

Regex frustrates me, especially with trying to work with slashes... I just haven't got it yet. I'm looking just for a code snippet to thrown in another clean up script I use. To standardize to UNC, as some templates were created on workstaions (also Mac vs PC) that were incositently mapped (i.e. W:/ or X:/ etc.). Blown a day messing with this so far, maybe reaching out for help would work... Thanks in advanced!

 

var gDoc = app.activeDocument;

var gLinks = gDoc.links;

var gCounter = 0;

 

     for (var i = gLinks.length-1; i >= 0 ; i--) {

          var currentLink = gLinks[i];

          var oldPath = currentLink.filePath;

          oldPath = oldPath.replace(/:|\\/g, "\/");

 

// Intention

// IF the drive letter W:/ or X:/ is used

// IF case is \\OHFILE02\Personalization\

// THEN

// REPLACE with \\ohfile02\Personalization\ (string replace: would be case sensitive, not just all to lowerCase)

// ALSO above would be for all linked images as it looks like it's looping through currentLink, is that correct?

 

Thanks again!

Screen Mode Option

$
0
0

For one document is ok

app.activeDocument.layoutWindows[0].screenMode = ScreenModeOptions.PREVIEW_OFF;

 

but for all opened document, it alert error

app.documents.layoutWindows[0].screenMode = ScreenModeOptions.PREVIEW_OFF;

exportFile for multiple selection

$
0
0

CS5.5 - Javascript, I would like to know the exportFile method for multiple selection, for example if i have selected 4 rectangles and want to export these four objects as single jpg without grouping it. Thanks in advance.

A Script for Conditional Text Batch Export

$
0
0

Hi, I was directed into this subforum with this question:

 

I have a document with nearly 200 versions of conditional text that has to be individually swapped out and exported to pdf. I genearlly just do this one at a time all the way though.

 

Is there a way to batch the export of these pdfs? I've been scouring the internet for a soultion but can't seem to find one. I am on CS4 still if it matters. Thanks!


Sum of All Opened Documents Pages

$
0
0

I want to alert all opened documents pages, but is undefined, can anyone fix?

 


var pageAlert = "";

for (var i = 0; i < app.documents.length; i++) {


var myDoc = app.documents[i];

                var width = myDoc.documentPreferences.pageWidth;

                var height = myDoc.documentPreferences.pageHeight;

                var size = Math.round (width) + "mm x " + Math.round (height)+ "mm";

                var eachDocPages = myDoc.pages.length;

for (var j = 0; j < eachDocPages.length; j++) {

      var  totalPages = Math.max(eachDocPages[j]);

}

                if(size == size){

                         pageAlert += "\n" + myDoc.name + " : " + size;

                }

                else {

                           pageAlert = size;

                 }


}

if (pageAlert.length) {


alert("Paper Size: " + pageAlert + "\rTotal Pages: " + totalPages);

}

Stript to run multiple find/change presets

$
0
0

I've a number of find/change presets and was trying ot figure out how to run them all automatically - I've ound various resources on scripts that do multiple custom searches but nothing about preset queries.

validate nextTextFrame availability

$
0
0

InDesign V5.5, Javascript. Do we have any method to validate textframe has a thread or not? i want to remove all following threads..I tried with nextTextFrame, but if textframe doesnot have next thread, it shows error, instead of that, can we have any other method to validate, it has a following thread or not. Thanks in advance.

Tables inside overset text frames

$
0
0

Hi everybody!

 

Im trying to write a script to set the width of all tables in a document equal to its parent text frame, I was succesful, but

the tables that are overflowed do not get resized. I have only come up with a way to find if there is an overflowed text frame

but not to find and overflowed text frame contents. PLS HELP!

 

heres my code:

 

//resizes tables

 

var myTextFrames = app.activeDocument.textFrames.everyItem();

var myTables = myTextFrames.tables.everyItem().getElements();

for (var i = 0; i < myTables.length; i++){

         var myTextFrame =  myTables[i].parent;

                    var myWidth = myTextFrame.visibleBounds[3] - myTextFrame.visibleBounds[1];

            myTables[i].width = myWidth;

         };

 

//finds a textframe with overset text

 

var myOverset = app.activeDocument.textFrames.everyItem().getElements();

                for(var x = 0; x < myOverset.length; x++){

                    if(myOverset[x].overflows == true){   

                    alert("There is overset text")

                    }

                };

Dynamic Indesign pages ?

$
0
0

Is that possible to make a indesign page to dynamic field ? and can i able to import data from excel sheet ?

 

Or any good suggesstion that would help me to create those pages faster... ?

Viewing all 8771 articles
Browse latest View live


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