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

[JS] Table RowTypes.BODY_ROW

$
0
0

Hello,

Is itpossible tosimpliedthisloop?

And she'll ask meif I havea problemSEVERALlinefeet...I'll have tobe moreprésit


thank you

// -----

Bonjour,

 

Est-il possible de simplié cet boucle?

Et elle vas me poser un problème si j'ai plusieur ligne de pieds ... je vais devoir être plus présit

Merci

 

 

for (y = (monTableau.rows.length-1); y >= 0; y--) {

   if (monTableau.rows[y].rowType != RowTypes.BODY_ROW) {   

        monTableau.rows[y].rowType = RowTypes.BODY_ROW; // OK  convertion ligne d'en-tete

    }

}


How to find index marks

$
0
0

Hi

 

I'm trying to managed "index" for my simple Indesign to html conversion tool and I'm totaly confused on how to do it and with the extendscript managment of that "index". So here are (alot of) questions about it:

 

  1. When I'm looping through all the characters of a paragraph, how can I identify "index marks" ? RegExp, specialCharacter...? ** Reply to myself ** Work with Grep search of "\~I"
  2. After finding an "index mark" how can if find the associated "topic" ?
  3. If there can be only one "index" in a document, why is there an "indexes" property ?
  4. What is an "indexSection" ?

 

Hope there will be somebody to clear my mind

 

Thanks alot

convert text to footnote

$
0
0

8.      de chercher plus de véritables [1] partenariats avec la société civile afin que les défenseurs des droits de l'homme se sentent pleinement [2] soutenus par l'UE;

[1]HRW:Central Asia : Five Years of EU engagement

[2]http://www.senat.fr/rap/r96-2013,1054/r96-374.html.

 

This is a little sample of xml-text we get from external sources. There's no link between the false "footnote-ref [1]" in de text and the false "endnote text".

Is there a possibility to convert those "notes" to real notes in de text, but not to end-notes? Sometimes these kind of notes extend to more than 100.

 

thnkx

Getting undefined error for current document in script

$
0
0

I'm getting a "Error Number: 2" "Error String: myDoc is undefined" in my script.

 

I tweaked some scripts so they traverse my entire book, and open up every section (document) in my book and run the code for each section.ext

 

The code runs great and opens and closes sections where it doesn't find text to add links to, but once it opens a document and finds text that it CAN add links to, it throws that error.  Below is my code:

 

 

main();
exit(); 
function main() {    var myBook = app.activeBook,            myDocs = myBook.bookContents.everyItem().getElements(),            myDoc,            myHyperlinkStyle,            myCount = 0;     for (var i=0; i< myDocs.length; i++) {        myDoc = app.open(File("\\\\computerOnNetwork\\c$\\Folder\\" + myDocs[i].name));        myHyperlinkStyle = myDoc.characterStyles.item("linkstyle");         try{            var script = app.activeScript;        }catch(err) {            var script = File(err.fileName);        }        var myScriptFolderPath = script.path;        var myFindChangeFile = new File(myScriptFolderPath + "/SearchTextAndUrls.txt"); //mac path for users desktop //File.openDialog("Choose the file containing the tab separated list");         //alert(myFindChangeFile)        myFindChangeFile = File(myFindChangeFile);        var myResult = myFindChangeFile.open("r", undefined, undefined);        if(myResult == true){            app.findTextPreferences = NothingEnum.nothing;            app.changeTextPreferences = NothingEnum.nothing;            //Loop through the find/change operations.            do{                //read 1 line into myLine                myLine = myFindChangeFile.readln();                myFindChangeArray = myLine.split("\t");                 //The first field in the line is the value to find                 myFindVal = myFindChangeArray[0];                 // second is the url                myFindUrl = myFindChangeArray[1];                 doSearchAndReplace(myFindVal, myFindUrl, app.activeDocument);             }while(myFindChangeFile.eof == false);                myFindChangeFile.close();                // reset search                app.findTextPreferences = NothingEnum.nothing;                app.changeTextPreferences = NothingEnum.nothing;        }        alert("Done! " + myCount + " hyperlinks have been added.");         myDoc.close();    }} 
function doSearchAndReplace(stringfind, urlstring, searchin) {    app.findTextPreferences.findWhat = stringfind;     //Set the find options.    app.findChangeTextOptions.caseSensitive = false;    app.findChangeTextOptions.includeFootnotes = false;    app.findChangeTextOptions.includeHiddenLayers = false;    app.findChangeTextOptions.includeLockedLayersForFind = false;    app.findChangeTextOptions.includeLockedStoriesForFind = false;    app.findChangeTextOptions.includeMasterPages = false;    app.findChangeTextOptions.wholeWord = false;     var myFoundItems = searchin.findText();     for (i = 0; i < myFoundItems.length; i++) {        var myHyperlinkDestination = myMakeURLHyperlinkDestination(urlstring);        myMakeHyperlink(myFoundItems[i], myHyperlinkDestination);        myFoundItems[i].applyCharacterStyle(myHyperlinkStyle, false);        myCount++    }} 
function myMakeHyperlink(myFoundItem, myHyperlinkDestination){    try{        var myHyperlinkTextSource = myDoc.hyperlinkTextSources.add(myFoundItem);        var myHyperlink = myDoc.hyperlinks.add(myHyperlinkTextSource, myHyperlinkDestination);        myHyperlink.visible = false;    }    catch(myError){    }} 
function myMakeURLHyperlinkDestination(myURL){    //If the hyperlink destination already exists, use it;    //if it doesn't, then create it.    try{        var myHyperlinkDestination = myDoc.hyperlinkURLDestinations.item(myURL);        myHyperlinkDestination.name;    }    catch(myError){        myHyperlinkDestination = myDoc.hyperlinkURLDestinations.add(myURL);    }    myHyperlinkDestination.name = myURL;     //Set other hyperlink properties here, if necessary.    return myHyperlinkDestination;}

 

Any and all help is greatly appreciated!

EventListener in Book

$
0
0

I have a login script, i just put a part of it, i add an eventListener in a document, that can beforePrint will update the user id, but I found that can't work in booklet, it is eventListener can't active in book?

funEventListener();

 

function funEventListener() {

          var myEventNames = ["beforeQuit", "beforeOpen", "afterNew", "afterOpen", "beforeClose", "afterSave", "afterSaveAs", "afterSaveACopy", "afterPrint", "afterExport", "beforeSave", "beforeSaveAs", "beforeSaveACopy", "beforePrint", "beforeExport"];

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

                    app.addEventListener(myEventNames[i], funEvent);

          }

 

 

          if (myLog_status == "undefined" && myEvent.eventType != "beforeQuit") {

                    myEvent.stopPropagation();

                    myEvent.preventDefault();

                    return;

          }

          var myString = "";

          if (myEvent.target.constructor.name == "Document") {

                    myDocument = myEvent.target;

                    if (myEvent.eventType == "afterNew") myString = "Opened a New Document.";

                    if (myEvent.eventType == "afterOpen") myString = "Opened File " + (myDocument.saved ? myDocument.fullName : myDocument.name + " [Converted]");

                    if (myEvent.eventType == "beforeClose") myString = myDocument.saved ? "Closed File " + myDocument.fullName : "Closed New Document without saving.";

                    if (myEvent.eventType == "afterSave") myString = "Saved File " + myDocument.fullName;

                    if (myEvent.eventType == "afterSaveAs") myString = "Saved File (Save As) " + myDocument.fullName;

                    if (myEvent.eventType == "afterSaveACopy") myString = "Saved File (Save A Copy) " + myDocument.fullName;

                    if (myEvent.eventType == "afterPrint") myString = myDocument.saved ? "Printed " + myDocument.fullName : "Printed New Document.";

         if (myEvent.eventType == "afterExport") myString = myDocument.saved ? "Exported " + myDocument.fullName : "Exported New Document.";

         if (myEvent.eventType == "beforeSave" || myEvent.eventType == "beforeSaveAs" || myEvent.eventType == "beforeSaveACopy" || myEvent.eventType == "beforePrint" || myEvent.eventType == "beforeExport") {

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

                                        if (app.documents[i].undoHistory.length > 0) {

                                                  if (app.documents[i].textVariables.item("User_id") != null) {

                                                            app.documents[i].textVariables.item("Us er_id").variableOptions.contents = myLog_status;

                                                  }

                                        }

                              }

                    }

          } else if (myEvent.target.constructor.name == "LayoutWindow") {

                    if (myEvent.eventType == "afterOpen") {

                              app.activeDocument.stories.everyItem().trackChanges = true;

                    }

          }

          if (myString) funWriteLogFile(myLog_status, myString);

 

 

          function funGetPhaseName(myPhase) {

                    switch (myPhase) {

                    case EventPhases.atTarget:

                              myPhaseName = "At Target";

                              break;

                    case EventPhases.bubblingPhase:

                              myPhaseName = "Bubbling";

                              break;

                    case EventPhases.done:

                              myPhaseName = "Done";

                              break;

                    case EventPhases.notDispatching:

                              myPhaseName = "Not Dispatching";

                              break;

                    }

                    return myPhaseName;

          }

}

dropdownlist used onchange of an another dropdownlist

$
0
0

Hi everyody,

 

I try to select my way by using two dropdownlist.

Each item on the first list change the second dropdownlist

 

example

 

List A                              List B               List C               List D  etc..

ItemA1  -> call ListB     ItemB1               ItemC1

ItemA2  -> call ListC     ItemB2               ItemC2

itemA3  -> call ListD     ItemB3               ItemC3

itemA4  -> call ListE     ItemB4               ItemC4              

 

I scripted like this :

 

var myList0= ["ItemA1", "ItemA2", "ItemA3", "ItemA4"];

var myListA = ["ItemB1", "ItemB2", "ItemB3", "ItemB4"];

var myListB = etc ....

 

var columns = myOption2.add("group");

var dimC = [0, 0, 100, 50];

var col1 = columns .add('dropdownlist', dimC , myList0);

col1.onChange = function()

{

     if (col1.selection == 0)

          {

               var col2 = columns .add('dropdownlist', dimC, myListA);

               return col2;

          }

     else if (col1.selection == 1)

          {

               var col2 = columns .add('dropdownlist', dimC, myListB);

          }

     etc ....

}

 

finally, it happens that my second dropdownlist overlap the first, and i want it separately.

 

Please, if anyone have an idea ?

 

best regards

 

Américo

Problem installing ScriptBay extension

$
0
0

Adobe Extension Manager CS5.5 (Version 5.5.163) refuses to install the ScriptBay extension, with the following message:

 

"The extension 'ScriptBay' does not contain valid signature. The extension will not be installed."

 

It then goes on to informs me, one by one, that it will not install the extension in each of the CS applications.

 

I have checked and unchecked the warning options in the Preferences panel with no change.

 

Is ScriptBay no longer installable? Am I missing a trick here?

 

Thanks in advance for any advice.

Print(false)

$
0
0

my script showm below, if I use myDoc.print(false) will have R6025 Run time Error, but If I use myDoc.print(true) or myDoc.print() that will be ok, can anyone fix it?

 

#targetengine "myHandler";

 

if(app.documents.length > 0){

var myDoc = app.activeDocument;

var myPrintPrefs = myDoc.printPreferences;

 

 

if (app.printerPresets.item("PDF_fit on paper") == null) {

   alert("Printer preset \"PDF_fit on paper\" is not installed.");

   exit();

}

else {

   myPrintPrefs.activePrinterPreset = app.printerPresets.item("PDF_fit on paper"); 

}

 

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

{

                              if(app.documents[i].undoHistory.length > 0)

{

                                        if(app.documents[i].textVariables.item("User_id") != null)

                                        {

                                                  app.documents[i].textVariables.item("User_id ").variableOptions.contents = myLog_status;

                                        }

                              }

                    }

 

 

var myDocProof = myDoc.textVariables.item('proof').variableOptions.contents;

var currentYear = new Date().getFullYear();

var currentMonth = new Date ().getMonth()+1;

var currentDate = new Date().getDate();

var currentHours = new Date().getHours();

var currentMinutes = new Date().getMinutes();

var PreMon = ((currentMonth < 10) ? "0" : "")+currentMonth;

var PreDate = ((currentDate < 10) ? "0" : "")+currentDate;

var PreHours = ((currentHours < 10) ? "0" : "")+currentHours;

var PreMinutes = ((currentMinutes < 10) ? "0" : "")+currentMinutes;

 

 

var myFileName = myDoc.name.replace(/\.indd$/i, "") + "_" + myDocProof.replace(/st Proof|nd Proof|rd Proof|th Proof| Proof/i, "P") + "_" + currentYear + PreMon + PreDate + "_" + PreHours + PreMinutes +".ps";

var myPsFolder = new Folder("~desktop/" + "/LowRes/In");

var myFile = new File(myPsFolder + "/" + myFileName);

myPrintPrefs.printFile = myFile;

myDoc.print(false);

alert(myFileName.replace(/\.ps$/i, ".pdf").replace(/%20/g, " ")+"\rSmallest File Size PDF Done!");

                    }

 

 

below is my part of login script:

 

funEventListener();

 

function funEventListener() {

          var myEventNames = ["beforeQuit", "beforeOpen", "afterNew", "afterOpen", "beforeClose", "afterSave", "afterSaveAs", "afterSaveACopy", "afterPrint", "afterExport", "beforeSave", "beforeSaveAs", "beforeSaveACopy", "beforePrint", "beforeExport"];

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

                    app.addEventListener(myEventNames[i], funEvent);

          }

 

 

          if (myLog_status == "undefined" && myEvent.eventType != "beforeQuit") {

                    myEvent.stopPropagation();

                    myEvent.preventDefault();

                    return;

          }

          var myString = "";

          if (myEvent.target.constructor.name == "Document") {

                    myDocument = myEvent.target;

                    if (myEvent.eventType == "afterNew") myString = "Opened a New Document.";

                    if (myEvent.eventType == "afterOpen") myString = "Opened File " + (myDocument.saved ? myDocument.fullName : myDocument.name + " [Converted]");

                    if (myEvent.eventType == "beforeClose") myString = myDocument.saved ? "Closed File " + myDocument.fullName : "Closed New Document without saving.";

                    if (myEvent.eventType == "afterSave") myString = "Saved File " + myDocument.fullName;

                    if (myEvent.eventType == "afterSaveAs") myString = "Saved File (Save As) " + myDocument.fullName;

                    if (myEvent.eventType == "afterSaveACopy") myString = "Saved File (Save A Copy) " + myDocument.fullName;

                    if (myEvent.eventType == "afterPrint") myString = myDocument.saved ? "Printed " + myDocument.fullName : "Printed New Document.";

         if (myEvent.eventType == "afterExport") myString = myDocument.saved ? "Exported " + myDocument.fullName : "Exported New Document.";

         if (myEvent.eventType == "beforeSave" || myEvent.eventType == "beforeSaveAs" || myEvent.eventType == "beforeSaveACopy" || myEvent.eventType == "beforePrint" || myEvent.eventType == "beforeExport") {

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

                                        if (app.documents[i].undoHistory.length > 0) {

                                                  if (app.documents[i].textVariables.item("User_id") != null) {

                                                            app.documents[i].textVariables.item("Us er_id").variableOptions.contents = myLog_status;

                                                  }

                                        }

                              }

                    }

          } else if (myEvent.target.constructor.name == "LayoutWindow") {

                    if (myEvent.eventType == "afterOpen") {

                              app.activeDocument.stories.everyItem().trackChanges = true;

                    }

          }

          if (myString) funWriteLogFile(myLog_status, myString);

 

 

          function funGetPhaseName(myPhase) {

                    switch (myPhase) {

                    case EventPhases.atTarget:

                              myPhaseName = "At Target";

                              break;

                    case EventPhases.bubblingPhase:

                              myPhaseName = "Bubbling";

                              break;

                    case EventPhases.done:

                              myPhaseName = "Done";

                              break;

                    case EventPhases.notDispatching:

                              myPhaseName = "Not Dispatching";

                              break;

                    }

                    return myPhaseName;

          }

}


ExtendScript - Waiting Message?

$
0
0

I'm having a bit of an issue when trying to select my target in the ExtendScript ToolKit. When I select InDesign as the target, it launches the application but ESTK sits there with a message box saying "Waiting; press ESC to abort..." It appears that it's not able to communicate with the process at all, and I'd love a little help debugging this. Anyone have any ideas?

 

 

Thanks!

Recent files list

$
0
0

Hi all,

 

I highly doubt that this can be done but....

Any chance of creating and saving a file without it being added to the recent files list.

 

Trevor

How do I create a save button to hide a dropdown and pass on the dropdown data to a label?

$
0
0

Hi InDesign Scripting Experts!

 

I'm desparetly looking for some help to get this issue resolved.

 

Essentially I've a lot of PDF forms that've been designed by using InDesign CS4 and then converted to an interactive PDF via Adobe Lifecycle. The final 2 page PDF form has multiple textfields, a drop down and a save button. The users partially fill-in the form, select their name from the dropdown and then hit the save button prior to sending the PDF form to the client.

 

The Save button does the following:

 

- Passes on the data from the drop down to a label

- Hides the drop down and

- finally, hides itself ('Save' button)

 

I understand InDesign CC has a lot of the Livecycle capability built-it. Hence I'm trying to design the inteactive PDF within InDesign CC. The textfields, dropdown etc. are easily done. The part that I'm stuck on is to get the 'Save' button to perform the above listed tasks.

 

Any help will be greatly appreciated.

 

Cheers

How to add a column at the end of table in already designed document..?

$
0
0

Hi,

 

I am writing a javascript for adding a column at the end of table in Indesign document. using our plug-in we have created the Indesign document.

Each table i want to add one extra column at the end. Is it possible..? please help me if anyone has idea regarding this.

 

Thanks,

Vimala L

Script to collect all fonts throw an assert in CS5 Debug. Have someone an idea to find the solution?

$
0
0

Hello forum members,

 

Sorry for my english, this is not my native language.

 

I use a Script from http://www.typomedia.org/adobe/indesign/fontcatalog/ to get all fonts from %Systemroot%/Fonts and the font folder of InDesign and write a simple text with these fonts. To test the script I run it under CS5 and CS5 Debug. It found only 6 of over 900 fonts. In CS5 Debug any time I run the Script, I collect two times the assert:

 

 

JavaScriptDataConverter::ScriptDataToVariant - Untranslated key string: System Font
Eng: Script providers must return untranslated strings to INX and translated strings to scripting clients.
QE: Please report this assert as a 2/2 bug

 

..\..\..\source\components\script\javascript\JavaScriptDataConverter.c pp (101)

 

 

In my first step I consult the developer of the script, but he has no idea why I get the assert. He also test his script under InDesign CC but he has no problems.

My InDesign CS5 and CS5 Debug versions are installed on the same system Windows Server 2008 R2 Standard SP 1.

 

I think the assert is the reason I get only 6 fonts in the normal CS5 Version.

 

Maybe the problem occur, because its a Server System or there are interdependency with other components because its an developer machine.

 

Have someone an idea or a similar issue, how I can clear my problem?

 

Thanks for your attention

 

m.gmaz

Creating a color in InDesign Javascript (CC)

$
0
0

Hello everyone:

 

I am using this code to try to create a color that can be used to fill a button:

function MakeButtonColor()

{

   var TheColor;

   var TheDocument = app.activeDocument;

   var myError;

  

   try

   {

      TheColor = TheDocument.colors.item("DPSButtonColor");

      var ColorName = TheColor.name;

   }

   catch(myError)

   {

       TheColor = TheDocument.colors.add({name: "DPSButtonColor", colorSpace:ColorSpace.RGB, model:ColorModel.process,colorValue:[0,137,208]});

   }

 

   var ButtonColor1 = TheColor;

   alert("ButtonColor is " + ButtonColor1.name);

     

}

 

I am taking this directly from the Scripting Guide with only a very few modifications.

 

But I never ever see the last two statements executed.   I've tried all sorts of things to make this work and it just doesn't want to work.

 

Anyone have any ideas why it won't work and what I can do to fix it?

Help with index creation

$
0
0

Hello guys, I need a help.

 

I'm trying to make an index to my magazine, but I just don't know how to do it.

Look this image:

http://i.imgur.com/O2DhDg6.png

 

I have the "ID", that is the product ID, and the "GROUP".

 

Now, look this image:

http://i.imgur.com/gbumYdi.png

 

I want the index looks like that. How I get auto all id products, put ther, and the group and the page too?!

It's so many products, I can't put one by one.

 

 

Thanks in advanced.


BeforePrint

$
0
0

My Script is below:

 

#targetengine "session"

main();

function main(){

    var myApplicationEventListener = app.eventListeners.add("beforePrint",myEventInfo);

    }

function myEventInfo(myEvent){

    alert("Yes");

    }

 

 

I can popup the message box, while i'm print the doc, but when I get document into a book, then I use print book or print selected document, can't popup a message box, how can I even popup the message box even I print the book or print the selected document???

 

 

 

r1.jpg

Type Callout

$
0
0

Is there a script that will “call out” (with labels) the text attributes? Everything from character style to paragraph settings (like space after)?

I am looking for an automated solution that works like Colorbreaker (http://www.gluon.com/product-colorbreaker-id.html) for inDesign CC. I have a lot of documents that I need to specify the type and color for use in a Brand Guideline book.

Using Regexp Regular Expressions in the ESTK find window

$
0
0

The following concerns the ExtendScript Toolkit (ESTK) CS6.

 

I just tried to search in the ESTK (in a jsx file) using regular expressions, but failed.

I'd like to find all places where a certain word is written, no matter whether it's written as one or two words (with space between the words).

 

Take the following two lines of code as a sample javascript file:

 

test word

testword

 

I'd like to find both of the words, so I enter "test ?word" in the Find & Replace window, check "Match Regular Expressions", and press the OK button. The question mark meaning zero or one occurrence of the preceding character (the space). The result from the ESTK is "No matches found".

 

Instead of using the question mark I tried to set the number of allowed spaces using the {n,m} notation:

test {0,1}word

...but to no avail.

 

Using \s{0,1} to indicate the space did not work either.

 

I also tried to add start and end markers for the search text, and adding .* for every other character that could start and end the lines (in my own longer code file).

^.*test ?word.*$

 

extendscript toolkit regexp.PNG

 

Since all of these searches works in "Expresso" (a test tool for regular expressions) I ended up pasting the code into expresso and pressed the "Run match" button there...

 

Was I doing something wrong in the ESTK, or does regular expressions just not work in the find window?

Plugin for flowing portraits into yearbook layout

$
0
0

Looking for a plugin to flow portraits into a yearbook layout

Delete Text Frame out of page

$
0
0

question.jpg

 

I want to delete text frame either is blank or have text that out of the page in all opened document, below script can delete all text frame in all opened document, but I want to keep the text frame inside the page, can anyone help me?

 

var myDoc = app.documents.length;
for (var k= myDoc -1; k >= 0; k--) {

var myStories = app.documents[k].stories.everyItem().getElements();

for (i = myStories.length - 1; i >= 0; i--){
    var myTextFrames = myStories[i].textContainers;
    for (j = myTextFrames.length - 1; j >= 0; j--)    {
            myTextFrames[j].remove();
    }
}
}

Viewing all 8771 articles
Browse latest View live


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