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

[AS] How to test the presence of at least one table?

$
0
0

Hello everyone,

 

 

I would like to test for the presence of at least one table in a document before starting a process (on edge strokes). 

 

I found this, but I do not know if this is really effective:

                              setCountOfTables1tocountoftablesofeverystory

                              setCountOfTables2toeverytableofeverystory

 

The first gives me a list of the number of table in each story; the second gives me the objects reference of every table.

 

Is there another way?

 

TIA.

 

Oli.


Call another InDesign script with doScript in InDesign CS4 js

$
0
0

Hi, I need to call a separate InDesign script from an active script. Could I do it through java script, or do I need to call applescript to run the InDesign script.

 

var myJavaScript = "myOtherScript";
app.doScript(myJavaScript, ScriptLanguage.javascript);

 

 

Thank you.

Yulia

InDesign 7.0 breaks Visual Basic reference

$
0
0

I've previously posted this to the Indesign SDK & Scripting forums, but haven't gotten a reply.
I thought I'd try again, rephrasing it a bit.
When I installed Creative Suite 4, InDesign 6.0 installed a COM typelib for Visual Basic.
C:\ProgramData\Adobe\InDesign\Version 6.0\en_US\Scripting Support\6.0\Resources for Visual Basic.tlb

I am able to reference this from VB.NET Visual Studio 2010 and program against the InDesign scritping API like a charm - with full IntelliSense.

With Creative Suite 5 InDesign 7.0 I am unable to establish this reference from Visual Studio.
Visual Studio can't find the reference.

Any ideas?

Refresh dialog window

$
0
0

Hi,

 

I am stuck with a dialog refresh!!!

I am trying to refresh my dialog in order to switch from one language to another

any idea?

Thank you,

 

here is my portion of code:

 

Is it possible to create our own panel through Vbscript/Javascript in Indesign?

$
0
0

Hi,

    We are new in indesign plugins I want to confirm that is there any possibility  to create own panel in indesign?

if it is possible kindly let me know ?

 

Thanks in advance.

How can I get my Indesign script to apply to all pages in the document?

$
0
0

My script (java) shown below will only apply to the first page of the document. How can i get it to apply to all pages of my document? What am I missing? Thanks.

 

scirpt:

 

myDocument = app.activeDocument

with (myDocument.pages.item(0).marginPreferences){

columnCount = 1;

//columnGutter can be a number or a measurement string.

columnGutter = "0";

bottom = "0"

//When document.documentPreferences.facingPages == true,

//"left" means inside; "right" means outside.

left = "0"

right = "0"

top = "0"

inside = "0"

}

Suggestions for changing tab with underline leader

$
0
0

I frequently create forms where I'll use a tab with the underline for the leader, e.g., Name_________________  Age___________, etc.

I like the line to be thinner than the text, say the text is 10pt I'll change the line to 8pt. I can do a Find/Change to change the Tab character to a smaller size, but that changes every tab whether it has a leader or not. I can't find a way to "Find every tab with a leader that's the underline and reduce the point size".

 

Any suggestions appreciated.

 

Geoff

get swatches in dropdown list with color preview...

$
0
0

Hi experts,

 

I am creating one gui for swatches related automation task in CS4 using javascript. Is it possible to get swatches in dropdown list with its color preview? Same like colors in Swatches palette.

 

Your help will be much appreciated. Thanks in advance.

 

Thiyagu


any indesign / javascript knowledgeable person in New York City?

$
0
0

i have a huge project and i need helping hands ASAP.

Clean up custom menu on app close in CS4

$
0
0

Hi,

 

I currently have an issue which I've been banging my head against the wall for too long and would like some expert advice. I have an ExtendScript setup to run on InDesign startup and I create a custom menu when the script is initialized. What I'm finding is, after I close InDesign and "uninstall" my script (remove from startup for instance) and re-open InDesign, my custom menu is still there! What gives?

 

So, I started by scripting in CS5.5 and solved this lack of clean up by adding a beforeQuit event on the application and manually removed my custom menu. This works great, in CS5.5. I need to make this script CS4 compatible, and it appears there are no events/ways to handle when the application closes. My menu is not document specific, so I can't leverage document close events.

 

So I've boiled it down to the following code snippet that represents the problem:

 

#target indesign

#targetengine "MyEngine"

 

function setupMenu()

{

app.menus.item('$ID/Main').submenus.add('Test Menu');

}

 

setupMenu();

 

If you put the code above in a startup script, you get the menu. If you then remove the startup script, you still get the menu. I find it hard to believe that once you create a menu item in InDesign, you can't get rid of it unless you manually remove it yourself. Am I misguided/mistaken?

 

Ultimately, is there a way I can, when the application closes, remove any custom menu I created so that on next launch, if the script was removed, the menu is no longer present in CS4?

 

Thanks for any help!

script to hyphenate footnotes

$
0
0

hi,
I have text importaded in indesign cs6 (mac os x yosemite) from word with hundreds offootnotes.

In the paragraph style "notes" thehyphenation is turned on but the footnotes are not hyphenated.
I tried solution with "find-change": find "paragraph style notes" -change "hyphenation on",butin the field change option to choosehyphenation does not exist.
Is there any wayto solvethis problem(with grep, script...) orI will have toapply hyphenationtoeach footnoteindividually?


Thanks in advance
oscar

Resizing TextFrame Centre Position

$
0
0

Hi All,

 

I need to increase all specified text frame (50mm x 100 mm) height vertically in centre position. If my Textframe height is 100mm then now I increase 100+50mm. In that 50 mm(Top is 25 and bottom is 25 mm). Please advice and also see my incomplete coding.

 

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


for (i=0; i < myframe.length; i++)
{
if (myframe[i].geometricBounds == 0, 1, 100, 50)  {        myframe[i].geometricBounds = 0, 1, 150, 50;        }
}
alert ("Done")


"

 

Regards,

Vetha

script to Import and Export xml file to book

$
0
0

Is there a script that would Import and Export .xml or .txt files on save separate .InDD file (the script shows files location based on input path and template lociaotn)

InDesign is crashing when opening a file from the book

$
0
0

Sorry if it was asked before, I did try to google it first. Also, this is my first post on this forum, so apologies if I do not follow some rules and do tell me if it is the case.

 

The original post with more details is here: extendscript - InDesign crashing when opening a file from the book - Stack Overflow

 

In short, I am creating a book and creating and adding chapters. After saving the book, any attempt to touch the files through the script results on InDesign crash.

 

Environment: Mac OSX 10.9.5 InDesign CS5.5, ExtendScript

 

If I run this code:

 

myBook.close();
alert("Book closed");

 

I can see the alert pops up and the book on the background is still open. When I OK the alert box, the book starts closing. If I add any following script steps after the alert, they seems to be done before the book is saved/closed.

 

I tried so far:

 

  • added a pause with $.sleep()
  • tried to set userInteractionLevel to Never_Interact
  • tried to open and close all added files in the book
  • tried to trash InDesign preferences / computer restart
  • tried to use while(){} and check it the book is still open - this results on eternal loop
  • disabled book-wide toc styles and auto numbering

 

Extract from crash report:

 

Thread 0 crashed with X86 Thread State (32-bit):
  eax: 0x00000040 ebx: 0x00000040 ecx: 0x00000040 edx: 0x00000000
  edi: 0xbfffac54 esi: 0x00000040 ebp: 0xbfffab88 esp: 0xbfffab70
  ss: 0x00000023 efl: 0x00010282 eip: 0x947d6bd5 cs: 0x0000001b
  ds: 0x00000023 es: 0x00000023 fs: 0x00000000 gs: 0x0000000f
  cr2: 0x00000040

Logical CPU: 0
Error Code: 0x00000004
Trap Number: 14

 

Could anyone push me into the right direction? Any thoughts will be appreciated.

Script to remove row if a cell is blank

$
0
0

Hello,

 

Im trying to find a script that will remove a row (shifting subsequent rows up) if one of the cells in the row (there are 2 columns) is blank.

 

Im creating table based docs using datamerge and there are rows with dataheadings (in column 2) and the datavalues (in column 1) for the rows are imported via the merge. Not every heading has a value so I want a script to remove the rows where no value is present.

 

I have found scripts that work however due to the end text # markers that are left after the merge I think they see the cell as being populated.

 

Thanks for you help


Save as copy

$
0
0
Is there a way to script save as copy. I want to preserve the open file in it's current location and manually perform save as there, would like to use save as copy on a setInterval so that once the first copy is saved subsequent copies will save in the background; not requiring user involvement.

I have the following for save as but I can't find save as copy. Should it be something like this or something else altogether?

Thanks!

if(app.activeDocument.modified == true){"
app.activeDocument.save();
}

Xpath

$
0
0

How to use more than one xpath using this.xpath

 

like  this.xpath = //FIGURE || //Para;

non-scripter attempting a metatagging script

$
0
0

my script is doing everything i want except it is converting all spaces and periods to semicolons in the final metatag and i cannot figure out why.

 

It will be VERY obvious that the attached script is nothing but a bunch of snippets clipped together to perform most of what i want...

 

I want to run this script at the end as i am completing a project to insert the needed metatags.

 

i want the project name

i want the copyright info

i want keywords to include all images used in the document

i want to be able to add keywords.

 

 

to run this script you will need a character style called    KeywordsCStyle

 

 

 

//-----document title and copyright---------

var myDocument = app.activeDocument;

with (myDocument.metadataPreferences){ 

    //author = "Adobe"; 

    copyrightInfoURL = "UPMC.com" 

    copyrightNotice = "© 2014 UPMC"; 

    copyrightStatus = CopyrightStatus.yes; 

    //description = "Example of xmp metadata scripting in InDesign CS"; 

    documentTitle = myDocument.name.split(".indd")[0];

    //jobName = "XMP_Example_2003"; 

    //var myNewContainer = createContainerItem("http://ns.adobe.com/xap/1.0/", "email"); 

    //setProperty("http://ns.adobe.com/xap/1.0/", "email/*[1]", "someone@adobe.com"); 

    }

//----------------------------------------------------

with (myDocument.metadataPreferences){

        //author = "scott rudy";

        documentTitle = myDocument.name.split(".indd")[0];

        }

//-------------------------------------------------//

//var curDocTitle = app.activeDocument.metadataPreferences.documentTitle;

//var curAuthor = app.activeDocument.metadataPreferences.author;

var curKeywords = app.activeDocument.metadataPreferences.keywords;

Array.prototype.unique = function (){

    var r = new Array();

    o:for(var i = 0, n = this.length; i < n; i++){

        for(var x = 0, y = r.length; x < y; x++){

            if(r[x]==this[i]) continue o;}

        r[r.length] = this[i];}

    return r;

}

function addXMP(/*find GREP*/findString, /*para style*/paraStyle, /*chr style*/chrStyle, /*insert to*/XMPdest){

  // reset search fields

  app.findGrepPreferences = NothingEnum.nothing;

  app.changeGrepPreferences = NothingEnum.nothing;

  // setting search parameters

  if(findString)app.findGrepPreferences.findWhat = findString;

  if(paraStyle)app.findGrepPreferences.appliedParagraphStyle = paraStyle;

  if(chrStyle)app.findGrepPreferences.appliedCharacterStyle = chrStyle;

 

  switch (XMPdest){

    // insert keywords

    case "Keywords":

      var myKeywords = app.activeDocument.findGrep();

      var myKeys = Array();

      // loop through keywords and get contents

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

        myKeys.push(myKeywords[i].contents);

      //myKeys.sort();

      // delete duplicates

      //myKeys = myKeys.unique();

      // insert Keywords to document XMP

      app.activeDocument.metadataPreferences.keywords = myKeys;

      break;

    // Heading search/insert

    case "Heading":

      var myHeading = app.activeDocument.findGrep();

      app.activeDocument.metadataPreferences.documentTitle = myHeading[0].contents;

      break;

    // Author search/insert

   // case "Author":

    //  var myAuthor = app.activeDocument.findGrep();

    //  app.activeDocument.metadataPreferences.author = myAuthor[0].contents;

   //   break;

  }

}

// copy all image names //----------------------------------------------//

f = app.activeDocument.textFrames.add({geometricBounds:[0,0,"20mm","20mm"]}); 

f.contents = app.activeDocument.links.everyItem().name.join("\r"); 

f.parentStory.texts[0].select(); 

//-----------change character style-------------------//

var cName = "KeywordsCStyle"; 

  var mCstyle = app.activeDocument.characterStyles.item(cName); 

  if (mCstyle.isValid) 

       app.selection[0].applyCharacterStyle(mCstyle);

//---------------------------------------//

app.copy(); 

 

 

 

 

//-----------------------------------------------------------------------//

 

 

// add Keywords

addXMP("\\w{1,}","","KeywordsCStyle","Keywords");

 

// add Heading

//addXMP("","HeadingPStyle","","Heading");

 

//add Author

addXMP("","AuthorPStyle","","Author");

//

//----delete image names textbox--------

f.remove();

Table rows affecting pageReference.add and insertion points

$
0
0

I've found a behavior I can't figure out. Hoping someone will have some idea about what to look at, if not an answer.

 

I have a script that inserts index entries (page references) at insertion points throughout a document. I have a function that returns an insertion point, and I can verify that it is returning what I'd expect (the locations are based on a find that looks for text of a particular paragraph or character style; but regardless of how it is found the function just returns a single insertion point).

 

The script works as expected, except in some cases the actual location of the page reference marker is offset by some number from the insertion point (I've verified as well that the index of the insertion point is correct immediately before pageReferences.add, but the value of the pageReference sourceText's insertion point does not match that starting index).

 

After some experimentation I've found that having tables before the text to be manipulated is at least one cause of this. A table with a header and one, two, or three empty rows seems to have no effect; the page reference appears where it should. With six rows, my page references are offset by 5. With 13 I get a variety of offsets (12, 11, 10 for my short sample). More rows creates more of an offset, but not one that seems predictable to me. The offsets do seem consistent, meaning every time I run the script I get the same result. I just don't see a pattern.

 

Is there something about table rows that could cause this? I've accounted for the placement of the text on the page just in case; I've created a 13 row table that has narrow rows and therefore takes up no more space than my 5 row table. I still get the same results. All of the table rows other than the header are empty, so it's nothing to do with the contents. The desired insertion points themselves are not within tables; they appear somewhere in the text following the table.

 

The code that inserts the page reference is minimal:

 

      var startIndex = fndText.index      var myPageRef = myFinalTopic.pageReferences.add(fndText, PageReferenceType.CURRENT_PAGE);      var endIndex = myPageRef.sourceText.index;

 

The startIndex and endIndex variables are just there for debugging purposes; they show the offset between the intended marker location and the actual one.

 

(Interesting, possibly relevant fact; the order in which I insert the markers seems irrelevant. Their location in the text appears to be what matters. So, when I move backwards through the document I get offsets of 12, then 11, then 10. But when I reverse it and move through the document in order I get offsets of 10, 11, 12. The same offsets for the same text.)

Path change

$
0
0

is there a way to make a script to change just a part of the path to all the links.

lets say all the docks links are in //server_1/ and i have //server_2/ with the same folder tree as server 1 so by just change the 1 to 2 the files would be there..can that be done at once with java script?

Viewing all 15932 articles
Browse latest View live


Latest Images

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