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

How to replace a text element of XML structure with an image.

$
0
0

I need to replace specific elements within my XML structure with an image and I'm having problems using the existing XML structure for this.

I was hoping for something as simple as myDoc.xmlElements[0].xmlElements[0].xmlElements[0].contents = new File("MyImgPath.ext");

 

I can use GREP to find the text of each item in my XML structure I wish to replace, remove the text and place the image and the result is what I want.  However, in the rare situation where the same text as the header, is in one of the paragraphs it too would be replaced with the image and we can't have that.

 

My XML structure is slightly more complicated but this example has the necessary elements:

> Root

     > Group

          > Header

          > Item


Create and Link a TextFrame for each page

$
0
0

New to InDesign scripting I am trying to find a way to create a text frame in a document up at the top left of each page with text that will link in between a text frame using ExtendScript Toolkit.  I tried to reference class textframe but couldn't see where to be able to manipulate the anchor to the other textframe.

 

Such as:

 

Screen Shot.png

 

So textframe Lorem's anchor will be dropped at the beginning of Bacon.  Currently using InDesign CC-2014.  Any help would be great thanks!  I am aware how to could create a text frame in the master but at this time I do not want to do it that way.

Overflow text copy on next page with same anchore box by script

$
0
0

Hi,

 

Is there any possible to get this overflow text to next page. The overflow text must be flow on anchored box. Is this possible by script.

Here my Libray box name is 'BOX1'

 

 

FYI:

1.png

 

by

hasvi

changing path location of embedded links in Adobe InDesign

$
0
0

I have a query re changing path location of embedded links in Adobe InDesign.
I am working in CS 5.5 Version 7.5.3.

We have recently upgraded our fileserver, moving the location of the directory which holds our InDesign files
to the new server.  As a result our links are now broken.  Due to the volume of documents and links it will be impossible to manually update all links. Do Adobe have a solution which automates the process?

masterpages and content

$
0
0

Hello guys,

 

I need help to write a simple function that checks if there is content/no content on a master page,

 

if there is content on the master pages ("You got content on the masterpages")

if there is no content on the masterpages(" You have got no content on the masterpages")

 

 

Could someone help me out,

 

Thank you in advance

Script to replace small caps that are typed as capital letters with non-capital letters (A => a, B => b, etc...)

$
0
0

I'm looking for a way to replace small caps that are typed as capitals by their normal equivalent.

I've got a text that contains a lot of names which should all be set in small caps.

In fact they are, but because capital letters are used for first letters they don't scale.

 

Short: I would like to be able to look for A, B, C... (in small caps) and replace them with (a, b, c...) in small caps in one go.

 

(compare two arrays?? -> is this possible in indesign scripting)

open a file in photoshop from indesign

$
0
0

Hello,

I been trying to open a photo from indesign to photoshop.

I loop through the selected graphic boxes  which I get the path to the images.

I can get the path easy enough but opening them in photoshop is another matter. I been reading about Bridgetalk, but can't seem to figureout how to get bridgetalk to load the images into photoshop.

 

 

using CS3

 

code:


if (app.documents.length != 0){
   
    if (app.activeWindow.activeSpread.pageItems.length != 0){
       
     for (i = app.selection.length-1; i >= 0 ; i--) {
        
         try{ 
                        
         if(app.selection[i].graphics.length != 0)
               {
                      var  myGraphic =   app.selection[i].graphics.item(0) ;              
                      var myLink = myGraphic.itemLink;
                      var myLinkName = myLink.name;
                      var myLinkFile = File(myLink.filePath);
                      var bt = new BridgeTalk.launch("photoshop");
            ?????????????????

 

                   } //end if                
                 
              }
    catch(err)
       {
           //
        }  
        
    } //end for loop
       
       
    }//end first if
    else {
       
        alert("The active spread does not contain any page items.");
    }
}// end second if
else{
    alert("No documents are open. Please open a document and try again.");
}

Applescript application(Run only)/Password protected

$
0
0

Hi,

 

 

  I'm copying files from source to destination using input XL then relink the images in InDesign Files. Saved that Apple script as Application(Run Only).  When I run the application its throwing "0 doesn't understand the count message".  But Code is working fine for me. Don't know why. Can anyone help me...

 

 

And also I need to protect that apple script using password as manual.  Is it possible??

 

 

Thanks in Advance,

Sudha K


Looking for a script to automate renaming layer objects, not the layer itself!

$
0
0

Hey there everyone,

 

I was wondering if there is a possibility to create/have a script for an automated renaming of several named layer objects in Indesign (CS6).

The situation, I'm facing is a document for a templating process with at least 80 layers and sometimes some special elements on each layer. The naming of the layers is kind of repeating for each page that is used. The only difference is some prefix change in the layer name and/or the name of an element itself. My problem is, that I need to rename most of those layers AND elements in a same way and I'm looking for a script that asks me for the name of a layer or element (perfect would be just a part of the name to have multiple steps at once) and I have the chance to type in the desired value. It affects frames, graphical elements and text boxes.

 

If anyone has an idea, how to simplify this process I would be very glad to get some informations or advices.

 

Thanks in advance

Ralf

InDesign CC: ScriptUI TreeView broken

$
0
0

Some troublesome news regarding the treeview in InDesign CC, ver. 9.0 (updated today through ).

 

Using the treeview in "InDesign Creative Cloud" trees can no longer be built dynamically, since there are no plus signs for expanding, until children are added (and then it's too late).

 

The onDoubleClick event also seems to be removed from the TreeView.

 

Regarding building the tree dynamically, by loadning new nodes when clicking "+":

In CS6 and before, the Node object always had a plus sign. If you clicked it, you could have an onExpand event hooked up, that added child nodes "on the run".

If the node was not to be expanded ever (no plus sign) you added an "item" instead of a "node".

 

In InDesign CC however, nodes without children are always shown without plus signs, making it impossible to load the children dynamically, since there is no way for the user to trigger an onExpand event. The nodes appear just as the items did in CS6. Here is a screen shot of a treeview, the same code running in CS6 (left) and InDesign Creative Cloud (right):

 

CS6-vs-CC-same-code-window.png

 

 

As you can see, the plus (or rather "turnable triangular things" in the dark and cool new super UI of CC) are missing in CC.

 

Here is the code (which also demonstrates that the onDoubleClick event no longer works, double click a node text in CS6, and the message "Doubleclick will appear", in CC no message appears when double clicking a node):

 

#targetengine 'testengine1'
var Window1 = new Window('palette','My window');
buildWindow();
Window1.show();

var nodeDoubleClickHandler = function(){
    alert('Doubleclick')
}
var nodeExpandHandler = function(item){        alert(item.text);
}

function buildWindow(){
       Window1.Treeview1 = Window1.add('treeview',undefined,undefined);    Window1.Treeview1.onExpand = nodeExpandHandler;    Window1.Treeview1.onExpand = nodeDoubleClickHandler;    Window1.Treeview1.Node1 = Window1.Treeview1.add('node',"Node 1 (node)");    Window1.Treeview1.Node2 = Window1.Treeview1.add('node',"Node 2 (node)");    Window1.Treeview1.Node3 = Window1.Treeview1.add('item',"Node 3 (item)");

}

How to change the order of two sets of words

$
0
0

Hi everyone:

 

I am translating a hundreds page of tables in indesign CS5, and need a coding that could help me to change the order of words in a phrase in all documents.

 

In the output language (Chinese), the order of words normally changes from the input language, e.g:

 

original: Construction of word1 word2 word3, Construction of word4 word5

output: word1 word2 word3 Construction, word4 word5 Construction

 

So, I kinda have a limited sets of words like "Construction", but thousands of "word", so a GREP coding that could change "A B", "A B C", "A B C D"... to "B A", "B C A", "B C D A" will greatly help me out.

 

An other example:

 

Input: Construction of Airport in San Francisco

Output: San Francisco 机场建设   


If this helps, I can also use an intermediate word for 机场建设, for example jichangjianshe, then change all then back.


Much appreciate any enlightenment!!

How do you use JS to open a Folder dialog

$
0
0

If you use this to open a dialog box to select a file:

     File.openDialog("Select your XML File", "*.xml")

 

The how do you open a dialog to select a folder.  I would think it would be something like

     Folder.openDialog

 

but alas, it is not, and I cannot find any reference on how to do it anywhere.  Does any one know?

 

Thanks

Exporting data in tables to an Excel spreadsheet?

$
0
0

Is there a script or another way to export or save a documents tables (multiple tables over several pages) to an excel spreadsheet? I have found a solution which involves exporting each spread as a html file which i can then open straight in excel but this is still quite long winded and i can only seem to do this a spread at a time. As the job I am working on involves many pages this is taking too long. Surely there must be a script which can automate this in some way. I am fairly new to scripting so any help will be grateful. I have searched in scripting but nothing has really come close to what i am trying to achieve. Indesign CS5.5 user.

Get word file and keep track change line?

$
0
0

Hi!

 

How can I get word file into indesign and keep those tracking line?

 

track change.jpg

Thanks

Extracting single pages out of InDesign documents

$
0
0

Is it possible to extract or export single pages from an InDesign document?

So far I've done it this way: I remove all the other pages, save to a new document and reopen the original document.

Here's my script https://gist.github.com/2964807

 

But obviously this is more of an hack. And the problem is that it's very obvious to the user, as the document is closed and re-opened. Is there a cleaner way of doing it?

 

Thanks in advance for your help.


Table height overrunning text frame

$
0
0

for(i=0;i<myTable.length;i++)

{

     currentheight=0;

     _tfheight=myTable[i].parent.geometricBounds[2]-myTable[i].parent.geometricBounds[0];

     TabCells=myTable[i].columns[0].cells;

     alert(TabCells.length);

     for(j=0;j<TabCells.length;j++)

     {

         currentheight+=TabCells[j].height;

      }

      alert(currentheight);

      alert(_tfheight);

      if(currentheight>_tfheight)

      {

          finalheightofcell=_tfheight/TabCells.length;

          alert(finalheightofcell);

          myTable.height=finalheightofcell*TabCells.length;

       }

   }

myTable: It is the table that I want to edit. I followed a link on the same forum where width of the table was overrunning the text frame but it does not help. Don't know what's wrong. Is the reason for "no effect" from this code is the greater text size and unformatted table?

ANN: automatic dialog after background export (exportPop.jsx)

$
0
0

A week or two ago, I wrote a script to pop up a dialog box after any background export, in response to the InDesign CS5 PDF export status thread. It doesn't seem like there's been feedback. I suspect it's sort of gotten lost in the noise in the general forum. So here we go again!

 

Don't make me post it to InDesign Secrets!

 

This script will automatically pop up a dialog box after every export finishes (PDF, IDML, whatever). It also makes sure that the Background Tasks window is turned on.

 

You can download the script from here, or just paste in what follows and save as exportPop.jsx. See How to Install InDesign Scripts for installation instructions. If you save it in the Startup Scripts folder, it will run automatically when InDesign is started. Running it a second time disables it, if for some reason it causes problems.

 

// exportPop.jsx -- pops up Background Tasks when you start an export
//   and a modal dialog when an export finishes.
// Beta version. Please post feedback at
//   http://forums.adobe.com/thread/830572
// John Hawkinson, 17 March 2011
// Save in STARTUP SCRIPTS folder to start automatically.

#targetengine session

(function() {
    var        old1 = app.eventListeners.itemByName("exportPop1"),        old2 = app.eventListeners.itemByName("exportPop2");           if (old1.isValid || old2.isValid) {        if (old1.isValid) { old1.remove(); }        if (old2.isValid) { old2.remove(); }        alert("Export pop up window removed.\n"+            "Indesign will behave as normal.");        return;    }       app.addEventListener("beforeExport", function() {        var            tasksPanel = app.panels.itemByName("Background Tasks");        if (tasksPanel) { tasksPanel.visible=true; }    }).name = "exportPop1";       app.addEventListener("afterExport", function(ev1) {        var task, listener;                   task = app.idleTasks.add({ name: "exportPop", sleep: 1000});        listener = task.addEventListener(IdleEvent.ON_IDLE,            function(ev2) {                listener.remove();                task.remove();                alert(ev1.format+" export complete of "                    +ev1.fullName+" at "+ev1.timeStamp);            });    }).name = "exportPop2";    alert("Export pop up window installed\n"+        "Background Tasks will appear the start of an export\n"+        "and a dialog will appear after each export complete.");
}());

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!

Export SVG in Indesign CS5?

$
0
0

hi,

 

i know that adobe canceled svg support for indesign at cs3. but it's really important that i find a way to export svg by scripting. has someone a tip? plugins for this are no solution.

 

thanks in advance!

Delete unused swatches in InDesign CS5, js

$
0
0

Hi,

 

I need to select and delete unused swatches in InDesign CS5. I looked through OMV in "Swatches" and "Swatch", but I could not find any function to select unused swatch and delete it.

Am I looking for it in the wrong place?

 

 

And I also need to read color values for used swatches. I got this in OMV and was hoping it would give me an array of the color values for all existing swatches, but I am only getting "Object color":

 


mySwatches = myDoc.swatches[1].getElements();


alert (mySwatches)

 

 

Thank you for your help.

Yulia

Viewing all 15932 articles
Browse latest View live