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

Indesign Script Opening Flex App / Tab Handling

$
0
0

Hi,

 

I am working on a  FlashBuilder 4 application that is opened from, and interacts with, an  Indesign CS4 .jsx script. I have added a TitleWindow that  provides for login processing (there is a backend database) to the Flex application. The login  window is opened from the method that is registered as the  initialization method for the Flex application. The flow works nicely.  The application, with its presentation of a TabNavigator holding the  core panels, visually appears then the login TitleWindow opens modally.  The id / password is entered, then the web service is called that  handles verifying login. The event handlers that receive the callback  from this then populate the controls on the application if the user is  verified.

 

The problem I am having is with tabbing on the  TitleWindow. No matter what I do (tabEnabled / tabIndex settings, etc.) within Flex,  the TitleWindow will not receive tab presses and react to them. Tabbing  seems to cycle through the Indesign application in the background.

 

From a  ScriptUI perspective the Flex application is opened as a Window (I've  tried Palette with similar results. I need it to be non-modal). Not only does the first tabbable  field not get focus, even when explicitly coded to do so, if you try to  tab off of it, which doesn't work, then click on the  second field on the TitleWindow to force focus, the first keystroke you type into the text field is ignored.

 

If  I test the application from FlashBuilder directly, without being invoked  as a ScriptUI Window / FlashPlayer, the first field gets focus, tabbing  works, etc.

Can anyone tell me how to make the login window behave such that I can set focus on field 1 and have it respond to tab  presses to cycle to the second field? Is there something I should do in the FlashBuilder application's invocation within the .jsx?

 

Here are the operative lines from the script:

 

var res =
"window {        \
    fp: FlashPlayer { preferredSize: [1100,650], minimumSize:[800,450], maximumSize:[1200, 850] },    \
}";


var importFlashWindow = new Window (res,"Import Stories", undefined, {resizeable:true, independent:true});


importFlashWindow.onShow = function(){

 

    var movieToPlay = new File (mySWFFile);
   
    try {

 

        //This function must be declared before the swf file is loaded as the flex panel calls it
        //from its init method.
        this.fp.getBaseUrl = getBaseUrl;

        this.fp.loadMovie(mySWFFile);


        //etc.

 

I have posted the same basic question in the Flex / FlashBuilder forum with no response. I'm hoping someone here might know what I need to do to get the FlashBuilder application to receive the tab presses instead of the Indesign application behind it.

 

Any help appreciated.

 

Thanks,

 

David


Panel for holding text (not notes panel) and a search internet contextual menu option

$
0
0

I often get text sent to me via email which I then copy and paste to a frame in the pasteboard, but sometimes the document is hundreds of pages long and the changes are throughout.

 

Would really love a Panel for just Holding Text - I use Notepad at the moment but have to switch back and forth.

The notes panel doesn't work for me because you have ot be active within the Notes for the Panel to be available, and when you are in the Notes Panel the other Tools are not available.

 

 

The other thing I think would be very nifty is a "Serach Internet" and it would look up that word(s) in your browser... not sure if that's possible. But would be neat.

Indesign Interrogation d'une base de données

$
0
0

Bonjour,

 

Je ne sais pas s'il y a beaucoup de monde qui parle français ici... mais je tente ma chance.


Je dois ajouter, pour un catalogue existant, le prix de chaque produit.


Pour le moment, j'ai ajouté le prix (avec une valeur bidon) après chaque référence, et j'ai balisé <reference> et <prix>. Jusqu'ici pas de soucis.

Ensuite j'importe ma base XML, mais là Indesign ne fait que me placer les références et prix dans l'ordre du XML. Du coup mes références ne correspondent plus au produit d'en face.


Ce que je souhaite, c'est continuer ma mise en page, bouger mes blocs et qu'Indesign interroge la base de données lorsque je le souhaite pour mettre les prix à jour, en correspondance à la référence.


Je ne pense pas vraiment être sur la bonne piste.

Je sais que l'on peut faire pas mal de chose en javascript, et là je bloque car je suis vraiment novice et mes recherches ne mènent nul part.


Si quelqu'un avait une solution.

Merci.

Specified font need to be changed in all paragraph styles

$
0
0

Hi All,

 

Is there any option to change a font which is used in many paragarph styles to some other font.

 

Thanks in advance,

free transform the image

$
0
0

Hi Forum!,

 

Im new to scripting. Thanks to forum for sharing the knowledge to entire world..

 

I have a small request to do with the scripting.

 

I have grouped all the pageItems.... as G.

and then selected the Group (G),

 

i have choosen the free transform tool using the command;

app.menuActions.itemByID(45569).invoke(); //to choose free transform tool.

 

all that i need to do is.. to enlarge the height of group (G) proportionally between top margin and bottom margin.


(which we do it manually by selecting the grouped item holding Shift+Alt key, and dragging untill we reach the desire size).

 

 

g = app.activeDocument.allPageItems;

gr = app.activeDocument.groups.add(g);

app.menuActions.itemByID(45569).invoke();

//then i need to increase the height of the group g between top margin and bottom margin.

 

Can anybody help on this free transformation of the selected group.

 

please..

Dhinak...

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.

EventListener afterOpen, delay

$
0
0

Hello,

 

i'm using Dave Saunders script for saving the window-position, which works fine. http://forums.adobe.com/message/1113471#1113471

A while ago i stumbled upon a script to set metaData to my documents, which works great too. I discovered InD's startup scripts folder. Now I want to merge them together, that the window-pos will be applied after open of every document.

But not being  firm with javascript at all, i can't solve much issues, which I have now: it seems that the afterOpen handler doesnt wait for the document-window to open. Can anyone help me out choosing the right handler to achieve this, or delay the afterOpen to wait for the window to open?

 

#targetengine "session"

main();

 

     function main()

{

var myEventListener1 = app.addEventListener("afterOpen", setWindowPos, false);

}

         

function setWindowPos()

    {

  // the script from the link obove will go here, but really dont know if i can do this this way because lack of js-skills

    }

Hyperlink Naming Convention

$
0
0

Hi All,

 

I hope following question is very simple for you.....

 

I want to change all the URL Hyperlink source name as like as Hyperlink destination contents.

 

Please refer the screenshot....

 

 

Hyperlink_naming.png

 

In the above screenshot I need to change  "yaho" into "yahoo.com".

 

Kindly give solution for me.

 

Trying Code is below:

 

var myHyperlinks = app.activeDocument.hyperlinks;

 

for (k = 0; k < myHyperlinks.length; k++) {

    var myHyperlinkText = myHyperlinks[k].source.sourceText.contents

     var myTemp = app.activeDocument.hyperlinks.add(myHyperlinkText, {name: myHyperlinkText.contents})

    }

    }

 

Thanks in advance

Beginner


FindChangeByList.jsx - help with text file list of commands

$
0
0

I have been working on a scrip using the FindChangeByList.jsx script. I'm having issues coding the text file that the script calls in.

I have a feeling this is a simple fix that someone with any aptitude for coding would easily figure out quickly. This is obviously not my forte.

 

I'm using the format below to set up my search/replace commands within the text file. The one below is what I figured out for replacing " x " to "x" (hence, taking out the spaces before and after the "x")

 

 

text{findWhat:" x "}{changeTo:"x"}{includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}Find all space-x-space and replace with an x.

 

I can't figure out these:

 

1) Find Double Quotation marks and convert them to Inch marks.

 

What I have:

text     {findWhat:"\"'}     {changeTo:"-- I don't know what should go here I've tried ^_" } (after this is the include Footnotes:true etc, etc part that I don't tweak at all since it doesn't apply)

 

2) Italicize any instance of the word "Signature"

text     {findWhat:"Signature'}     {appliedCharacterStyle:"Italic"} - this throws up an error message??

 

3) Change the style of the cents amount of a price to the SuperScript character style I've defined. So for a number like 199.99 - the last two 9's become superscripted

text     {findWhat:"^9^9^9.^9^9'}     {changeTo "I don't know what I should do here"} - this throws up an error message??

 

4a) After changing the cents to superscript - delete the decimal point that separates the dollar amount from the cents amount. (Hence 199.99 becomes 19999 where the last two 9's become superscript).

 

text     {findWhat:"^9^9^9.^9^9'}     {changeTo "I can't use ^9^9^9^9^9, because it changes the number to "^9^9^9^9^9" ?? "}

 

 

Any help would be greatly appreciated!

 

Thanks in advance -

 

Drew

Which of 2 numbers are closest to 0

$
0
0

Hello,

Although this might be a general question, I would like to seek some help from the forum.

 

I am running a script and I have a function which receives 2 numbers (variables)

I would like to know which of the 2 is closest to 0

I.e., if the numbers are 5, -2 = -2 is closer etc.

 

Is there someone who can offer some method or function that can help me with this.

(I made 2 loops that counts how many times it took the number to get to 0

but I believe there is a better way.)

 

Thanks,

Davey

Grep script: Search for "€.+" and apply character style?

$
0
0

Having spent hours on this I almost give up. I guess it is not a big problem for everyone, but I am kind of new on scripting.

 

My problem:

I have a Indesign table (500 + pages) and need to apply character styles to all the content. To make things easier I have inserted a special character eg. "€", "‰" before every pargraph.

 

What I need to do:

1. A search for every paragraph beginning with "€" and applying paragraph style named "APPLE"

2. A search for every paragraph beginning with "‰" and applying paragraph style named "BANANA"

3. Deleting the characters "€" and "‰".

 

Any suggestions?

 

example.png

Modification Needed to Jongware's CopyCutter

$
0
0

Hi all,

 

I've tried and failed to do this myself so I'm hoping that someone or even Jongware himself can help me out. I'd previously asked this question: http://forums.adobe.com/message/2865783#2865783 and I ended up with a modified version of Jongware's CopyCutter.

 

Unfortunately the formatting of my document has changed so I need to modify the script to take these changes in to account. Could someone please help me?

 

 

 

Here is how my copy currently looks:

 

Screen Shot 2013-06-13 at 10.39.13.png

 

This is what I want to select and apply the script to:

 

Screen Shot 2013-06-13 at 10.34.17.png

 

 

And this is the result I'm hoping to get (Note the missing \n\n at the beginning too):

 

Screen Shot 2013-06-13 at 10.36.17.png

 

Bonus points: I'd quite like the resulting text boxes to be given an object style that I could define.

 

 

 

And for reference here is the script that I currently have (link at beginning of post my provide more context):

 

 

if (app.selection.length == 1 && app.selection[0].hasOwnProperty("baseline") && app.selection[0].length > 1){
 app.selection[0].insertionPoints[0].contents = "\r";
 app.selection[0].insertionPoints[-1].contents = "\r";
 app.findGrepPreferences = null;
 app.changeGrepPreferences = null;
 app.findGrepPreferences.findWhat = " +";
 app.changeGrepPreferences.changeTo = "\\r";
 app.selection[0].changeGrep();
 p = app.selection[0].parentTextFrames[0];
 lh = (p.lines[-1].baseline - p.lines[0].baseline) / (p.lines.length-1);
 top = app.selection[0].lines[0].baseline - lh;while (app.selection[0].length > 0){  f = app.activeDocument.layoutWindows[0].activePage.textFrames.add ({geometricBounds:[top, p.geometricBounds[3]+2*lh, top+lh, 2*(lh+p.geometricBounds[3])-p.geometricBounds[1] ]});  app.selection[0].lines[0].move (LocationOptions.AFTER, f.texts[0]);  top += lh;}
 app.selection[0].insertionPoints[-1].contents = "";}else
 alert ("please select some text to shred"); 

Where are my styles applied?

$
0
0

Hi there,

 

Is it possible to write a script that will identify where a specific style is used throughout a document?

 

I've inherited a large project with about 1500 pages and I'd like to clean up the styles used throughout. By the looks of it, there are duplicate styles used in many of the individual files that make my book. I'd like to find those and consolidate the many styles stored in each file to just unique and used styles.

 

The "list unused styles" feature is a great help with this but I'd like to go to the next level with this effort.

 

Thanks,

Pete H.

selecting ConstrainProportions for scaling

$
0
0

Hi forum,

 

Is it possible to select the Constrain proportions for scaling link button in Control panel, using script.

trns.png

 

Could forum help on this request.

 

regrds,

@ chand.

ScriptUI : edittext live modifications problem

$
0
0

Hi,

I set a scriptUI interface.

 

http://i.imagehost.org/0754/Image_1.png

I have two buttons :

     - one has to add a carriage return on the edittext field

     - one has to add tab.

I am using textselection property of the edittext object.

On Mac it works very fine.

On Windows, it just go crazy. Sometimes, it just ignores the click, other times, it adds the element unexpectingly.

ie tab or carriage return are placed everywhere but where I want it.

What do I do wrong ?

TIA Loic


[JS][CS5] rounding decimals in swatch values

$
0
0

Hello again,

I recently made this script to round decimals in the swatch values if there were any. I'm pretty new to JS so this probably isn't the prettiest code so I was wondering if someone had a better way of doing it.  This works, but sometimes it takes a while and I'm pretty sure it is looking at the [paper], [black], and other swatches that can't be changed.  That is why I made it skip the errors during the script...

 

 

function round(color) {    try{ color.space = ColorSpace.cmyk;    var vals = color.colorValue;    for (var j = vals.length - 1; j >= 0; j--) {        vals[j] = Math.round(vals[j]);    }    color.colorValue = vals;}catch (err) {}}if (app.documents.length > 0) {        var target = app.documents[0];    }else{        var target = app;    }      
var myColors = target.colors.everyItem().getElements();for (var j = myColors.length - 1; j >= 0; j--) {    round(myColors[j]);}  
alert("Swatches Rounded"); 

 

Any help is appreciated.

File extensions on Mac

$
0
0

Hi there,

 

Using a line like this on a Windows machine:

 

     myFile= File.saveDialog("Save Settings", "Super script extension:

*.sse");

 

this makes sure that whatever name the user chooses for their file, the

correct .ccpp extension will be added.

 

From the documentation, it looks like the Mac will ignore the second

string in the brackets.

 

If this is so, how would you open save dialog on a Mac and make sure the

file gets saved with the correct extension?

 

Many thanks,

Ariel

 

batch-find-and-replace.jsx

$
0
0

Hi there, I wrote a batch-processing script for find change queries and thought I share it with you. You can get it over here 

You can process GREP, TEXT, GLYPH and OBJECT searches. 

Purpouse

While creating books in InDesign with several documents we always come across some find change queries that need to be used again, and again, and again. To make this process easier you can just grab their names and put them into a list. The script will than try to process all your queries in one click. 

prerequisites

  1. make sure you have a toml file.
  2. make sure the toml file is next to the script.
  3. make sure the toml file has the right formatting (see below in section TOML)
  4. if you want the script to autoexecute (without toml file selection), make sure the .toml file has the right name: "batch-find-and-replace.toml"
  5. make sure your fcqueries work right

Usage

  • Place the script and the toml file into your Scripts Panel Folder 
  • define some find and change queries and save them via the InDesign dialogue.
  • get the xml file names and add them to the "batch-find-and-replace.toml" file in the right spot. text search goes into text.files = [], grep search goes into grep.files = [] and so on. Make shure to remove the .xml from the filename. You can find these files on:
    • Mac OS Users[username]\Library\Preferences\Adobe InDesign[Version][Language]\Find-Change Queries[query type] 
    • Windows XP Documents and Settings[username]\Application Data\Adobe\InDesign[Version][Language]\Find-Change Queries[query type] 
    • Windows Vista and Windows 7 Users[username]\AppData\Roaming\Adobe\InDesign[Version][Language]\Fin d-Change Queries[query type] 
  • the .toml file should be located next to the script file and have the  appropriate name (batch-find-and-replace.toml). If so the script wont ask for the toml file and process the data right away. If not the script will ask you to select the .toml file.
  • Thats it. Watch the magick happen.

TOML

Tom's Obvious, Minimal Language is a simple markup language that makes settings human readable. It is still in development and may change a lot. But still. It is a pretty easy language and can be learned by anyone.
The basic toml filer looks like this: 

# these are the basic settings
# the MUST be there
do_text = true
do_grep = true
do_glyph = true
do_object = false
# now the file names
# they have to be in one line
# the toml specs say you can break lines in arrays
# but the toml.js does not allow that at the moment
[text]
files = ["my_first_text_find_and_change","another one"]
[grep]
files = ["somegrepsearch", "find tabs", "something else"]
[glyph]
files = []
[objects]
files = []

MUST HAVE Settings

With the do_text, do_object, do_grep and do_glyph you can define if the script should do the corresponding find and replace. Set them to true or false.

CAN HAVE Settings


In the [text],[grep],[glyph] and [objects] areas you can define the filenames that should be processed. Make sure the filenames are written right. If there is a file mentioned that does not exist the script will throw an error. It will try to process all the .xml files it can find.
!IMPORTANT! you MUST remove the .xml from the filename in the list as shown above.

 

The Script is here --> https://raw.github.com/...find-and-replace.jsx

The basic .toml file here --> https://raw.github.com/...ind-and-replace.toml

The Readme here --> https://github.com/...lob/master/README.md

And the whole package here --> https://github.com/...e/archive/master.zip

How do I print specific spot color(s) in separations?

$
0
0

I am still a beginner to ExtendScript & JavaScript, but I am learning fast. Right now, I need to figure out how to tell InDesign to print specific pages of the active document using a printer preset and—here's the kicker—only using certain spot colors.  (The preset already enables separations.)

Now I have followed both the Adobe InDesign CS6 JavaScript Scripting Guide on pages 47–51 as well as Jongware's guide on the subject. However, both only refer to turning on or off the Cyan, Magenta, Yellow, and/or Black channels (using the methods .printCyan, .printMagenta, etc.); there is no mention of doing so for any spot colors that exist in the document.

When using the Print dialog normally, you just select the Output tab and click the little printer boxes (basically checkboxes) next to each color separation that you want printed. Surely this can be replicated in ExtendScript, but how?

Applescript hyperlink URL, not shared destination

$
0
0

Hi everyone,

i'm trying to write an applescript that will apply a hyperlink to some selected text (a product number). Where I am running into trouble is that the hyperlinks cannot be "shared destination".

After poaching what I could from some other scripts, I have this:

 

tell application "Adobe InDesign CS5"

   

    tell document 1

        set mySelection to selection

       

        set prodNo to contents of mySelection as string

        set prodNoURL to "http://www.webaddress.com/address/" & prodNo as string

       

        try

            set TheH to make hyperlink URL destination with properties {name:prodNo, destination URL:prodNoURL}

        on error

            set TheH to hyperlink URL destination prodNo

        end try

        set TheHS to make hyperlink text source with properties {source text:(item 1 of mySelection), hidden:false}

        set myHyperlink to make new hyperlink with properties {destination:TheH, source:TheHS, visible:false}

               

    end tell

end tell

end

 

This works, except that the resulting hyperlinks are linking to Shared Destination, which they cannot do (I don't know why, actually; my little script is just one step in a bigger process.)

Screen Shot 2013-02-25 at 4.11.18 PM.png

How do I create a hyperlink that will link to URL, with the "Shared Destination" checkbox OFF:

Screen Shot 2013-02-25 at 4.13.41 PM.png

 

Thanks for your help!

(Mac OS 10.7, ID CS5)

Viewing all 15932 articles
Browse latest View live


Latest Images

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