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

app.open() crashes InDesign after repeatedly opening a template

$
0
0

So I was writing a script that batch builds specialized books from a list of order files when I ran into an odd issue with InDesign crashing, (no exception is reported when run through ExtendScript toolkit, the program just crashes complete with a windows popup of "Adobe InDesign CC 2017 has stopped working" )

 

After an extensive debugging process, I determined that the crash always happens at app.open()

Further testing showed that it does not matter if its opened as a copy, or which template it is, just that it is opened many times in the same script.

I proceeded to test on several computers with windows 7 and 10, varying hardware, and varying versions of InDesign CC 2017 all with the same results save one that offered this error report:

 

Problem signature:

  Problem Event Name: APPCRASH

  Application Name: InDesign.exe

  Application Version: 12.0.0.81

  Application Timestamp: 57f545c7

  Fault Module Name: DV_WidgetBin.dll

  Fault Module Version: 12.0.0.81

  Fault Module Timestamp: 57f54502

  Exception Code: c0000005

  Exception Offset: 000000000003b755

  OS Version: 6.1.7601.2.1.0.256.48

  Locale ID: 1033

  Additional Information 1: 937c

  Additional Information 2: 937cd28da0d9cc614dbe2c8fd27dd239

  Additional Information 3: 2bc1

  Additional Information 4: 2bc19be4be45607293e6e95449d7f364

 

I have compressed the code down to 8 lines with the same result. If you want to test it,

you will also need an indt file with the name blank in the same directory. This can be as simple as a 1 blank page template

 

#target "Indesign"

var directoryRoot = (new File($.fileName)).parent;

var template = File(directoryRoot + "/blank.indt");

for (var m = 0; m < 100000; m++) // arbitrarily high number it never reaches

{

    var doc = app.open(template, true, OpenOptions.OPEN_COPY); // The program crashes on this line

    app.activeDocument.close(SaveOptions.NO);

}

 

This version tends to run for about an hour on my machines and the original batch script tended to make between 40 and 1500 books before crashing.

 

I could not find any similar reports in the forums but if anyone knows a solution I would really appreciate it as this bug is rather debilitating to my planned work flow.


cleaning up text frames

$
0
0

hello all you smart guys.

 

I get a big complex files from another designers every month for further processing. Among other not-so-good habits, they usually do not use layers.

To make layout a bit more organized, I move text to its own layer - simple task, have script for it. But it does the job straightforward - exactly 'as advertised' (Jongware's expression - I like it so )

 

Unfortunately, those designers didn't bother much with 'frame content' option. They can draw a frame with a text tool, fill it with color and use it as a background for some artwork or whatever...

my script 'text frames to separate layer' creates a mess on such pages, and locate it - not always is an easy task. Document usually has over 200 pages...

 

So, I'm dreaming about some magic script, which is able to "prepare" text for moving, I mean, to find and process:

 

case1: empty text frame with no fill/outline - remove (delete)

case2: empty text frame with any fill/outline - convert to 'unassigned'

case3: text frame with the same color applied to text and the frame itself (yes, it happens!) - well, maybe just 'select and stop'? I'm afraid it's too complicated to remove text from such a frame and then treat the frame as 'case2'?

 

any suggestions would be greatly appreciated...

InDesign Smart Stream Script

$
0
0

Im just a novice on JS in InDesign, may I ask if it is doable on script to automate SmartStream> CreateJob ( image below ) like exporting pdf.

 

2.JPG

 

thank you

Delete all character styles (used or unused).

$
0
0

I need a script that deletes all character styles and “Preserves Formatting” and “Apply to All” and “Replace with:[None]” (screenshot below) — whether it’s used or not.

 

Thanks in advance to anyone who can help.

 

 

 

Delete all character styles after “[None]”.

Screen Shot 2017-08-16 at 16.59.59.png

Apple Script continue script after certain keyword

$
0
0

Hello,

 

I've run a pretty heavy script on my document and it stopped around the middle. Now I would like to continue where it left off, because to run it again on the whole document from the beginning would take hours and I want to avoid that. How can I code it that way, that it let's say continues after "keyword".

 

That's my code I want to modify:

 

set theItem to 0

set theItem to choose file with prompt "Select a  InDesign document to modify..."

if theItem is not equal to 0 then

 

    tell application "Adobe InDesign CC 2017"   

        open theItem

        tell active document

            -- Determine how many text frames we need to change

            set myFrames to the number of text frame

            if myFrames is not equal to 0 then

                set theFrame to 1

                repeat until theFrame > myFrames

              

                    set myText to text frame theFrame

                    set myFont to applied font of character 1 of myText as string

                    if word 1 of myFont is "My Font" then

                        repeat with thisCharacter in (characters of myText)

                         

                              -- do something to every character

                         

                        end repeat

                    end if

                    set theFrame to (theFrame + 1)

                end repeat

            end if

        end tell

    end tell

    beep

    display dialog "Modifications finished!" buttons {"Groovy!"} default button 1

else

    display dialog "Operation cancelled" buttons {"OK"} default button 1

end if

 

That's what I thought would work but doesn't:

I would insert it in the above code before "repeat with thisCharacter in (characters of myText)" and it would continue with the new myText which starts after "keyword.

 

-- Continue after "keyword" --

set myTextz to words of myText

set var to 0

repeat with wordz in myTextz

     if wordz as string is equal to "keyword" then

          exit repeat

     end if

     set var to var + 1

end repeat

set var to var + 2

-- somehow var was always 2 words late so +2

set myText to words var thru end of myText

-- gives the error: error "„Adobe InDesign CC 2017“ has received an error: „words 936 thru end of text frame id 250 of spread id 199 of document id 2“ couldn't be read." number -1728 from words from word 936 to last insertion point of text frame id 250 of spread id 199 of document id 2

 

 

Btw. I have the whole text in only one frame, so unfortunately I can't just say continue after frame 5.

Select textframe on basis on textFrame.id

$
0
0

Dear All,

 

I want to assign a variable myFrame to one of the textFrame present in a page by textFrame.id.

 

var myDoc = app.documents.item(0);

var i;

 

for(i=0; i < myDoc.textFrames.length; i++)     // three text frames i have in myDoc (only one page)

     {

          var myFrame = myDoc.textFrame[i]

          alert(i + " " + myFrame.id);   // here I get number like 845, 869, 205

          if (myFrame.id == 845)

          {

              myFrame.select();

          }

     }

 

 

So now I knew three id of three textframes so how i can assign/select that frame to a variable, which has id 869.

 

myFrame1 = myDoc.textFrames.id(869);  // assign does not work here //need code for that

myFrame1.select()

 

 

Virender

addEventListener not working when there's loop

$
0
0

Hi there,

 

addEventListener seems not working when there's a loop in the program. Any way to solve this?

Thank you...

 

;---------------------------------------------------------------------------------------

var myWin = new Window ( "window", "LOOP TESTING.." );
var myTxt = myWin.add("statictext", undefined, "Testing.....................");
var cancel_button = myWin.add ("button", undefined, "Cancel");
cancel_button.addEventListener ("click", function () {alert("cancel_button.addEventListener");myWin.close();exit();});
myWin.show();

for (var i =0; i<20;i++){
    myTxt.text = String("TEsting: " + i);
    $.sleep(100);  
}

myWin.close();
exit();

Need script for find and change text

$
0
0

We have some set of texts that need to find and change in the entire InDesign CS4 document rather than doing manually. Kindly help me out to do the same successfully.

 

for e.g. find text - "mam" and replace with "man".


script for running multiple find/change queries

$
0
0

Working on a large ID book document (*.indb), I have saved several dozens of Find/Change Queries (named "col01", "col02" etc.) that I run on "All documents". For a particular reason I have to run these queries several times a day.

 

So I was wondering whether there is, or whether anybody out there would write, a script that runs these queries one after the other. Given the size of the book, it might be necessary to provide for the script to pause after each query is run (before it goes on with the next), but I am just guessing.

 

Any help is much appreciated!

Apply 10% Black tint Color Text Frame / Object

$
0
0

How can I create a script to apply color tint in text frame or Object (if it´s this item selected)?

 

A don´t want to use caractere, paragraph or object style.

 

Is this possible?

tracking images

$
0
0

is there a way to get the data on a images and what page it is on? so that the information can be put in a spread sheet and tracked for licensing purposes?

Script pallete

$
0
0

Hello, there.

I'm trying to populate a little pallete window with script files in a folder.

I'm able to create the window, automaticaly create the buttons for each script file in the folder. But I can't set a function to each button. What am I doing wrong?

 

#target indesign
#targetengine "Menu de Scripts"


var myFolder = Folder("~/Downloads/Nova pasta");
if (myFolder.exists) {
    var myFiles = new Array;    GetSubFolders(myFolder);    if (myFiles.length > 0) {        myFiles.sort();        var myScriptList = myFiles.join(";");        var scriptFolder = RegExp((String(Folder.decode(myFolder))+"/"),"gi");        var scriptFile = String(myScriptList).replace(scriptFolder,"");        var scriptFiles = String(scriptFile).replace(/\.jsx/g,"");        var myScriptsList = scriptFiles.split(";");               var myMenu = new Window ("palette","Script by LFCorullón", undefined, {resizeable: false});        var myG = myMenu.add ("group");        myG.orientation = "column";               for (var ) {        for (var s=0; s<myScriptsList.length; s++) {            var myFile = File(myFolder+"/"+myScriptsList[s]+".jsx");            var myBtn = myG.add ("button", [0,0,150,25], myScriptsList[s]);            myBtn.onClick = function() { app.doScript(myFile); }            alert(myFile);            }        }        myMenu.show();        }    }


// FUNÇÕES ======================================================================================
function GetSubFolders(theFolder) {    var myFileList = theFolder.getFiles();    for (var q = 0; q < myFileList.length; q++) {        var myFile = myFileList[q];        if (myFile instanceof Folder){            GetSubFolders(myFile);            }        else if (myFile instanceof File && myFile.name.match(/\.js.+$/i)) {            myFiles.push(File.decode(myFile));            }        }    }

How to pass information between JS Extension and JSX host

$
0
0

Hello,

 

My CEP extension for InDesign CC runs some HTML/Javascript code which fetches data from a remote REST API host. It then executes ExtendScript code using the CSInterface:

 

$.get({    url: "some.url",
}).done(function (data, textStatus, jqXHR) {    var csInterface = new CSInterface();    csInterface.evalScript("../jsx/myscript.jsx");
}).fail(...);

 

How can I pass Javascript’s data to the ExtendScript script?

  • It doesn’t seem like localStorage is available across boundaries between the host application’s core (InDesign) and CEP extension runtime. What about sessionStorage?
  • I’d like to avoid using files on the host (Javascript FileSaver, and ExtendScript File) unless there is a way to use proper temporary files in the system’s temp folder.

 

Cheers!

InDesign 2017 Script Documentation

$
0
0

Hi there,

 

I'm a developer working on InDesign scripts for a client using InDesign for publishing. There are InDesign script reference documents available here InDesign developer documentation | Adobe Developer Connection  but these appear to only be up to date as far as CS6.

 

Does Adobe have an updated documentation set for developers? I'm having issues with using methods in my JSX scripts, particularly the PageItem#place method which I have been successfully using up until the latest release to place an ICML file into a document. In CC2017 this simply puts the text "undefined" into the PageItem instead. Is there a new method for placing ICML in CC 2017 and/or is there any documentation surrounding this change?

 

Regards,

James

Directly access fields in Transform panel

$
0
0

I want individual scripts that directly accesses the individual parts of the transform panel, later key commands will be applied to each script.

 

For instance, ⌃⌥H place the cursor directly into the horizontal scale input area, ⌃⌥V places the cursor in the vertical scale area, ⌃H may place the cursor directly in the height area, etc.

 

That way, through the individual scripts, at the touch of a button I can quickly enter or adjust current values for frame and/or image dimensions.

 

I want the transform panel to show every time one of the scripts is ran, whether it’s currently showing or not, in order to enter the values of coarse (versus a separate dialogue window).

 

Tried doing this with apple script and failed completely, I have no real scripting experience whatsoever.

 

 

Any help is appreciated.

 

 

Thanks.


Transfer demensions from one frame to the other?

$
0
0

Is there a way to transfer the height, width, stroke, fill, etc from one frame to another, or to multiple frames? While keeping the specific image file within the separate frames intact.

 

 

Thanks in advance for anyone who can tackle this. Cheers.

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.");
}());

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

New Scripting Features in CS5

$
0
0

This discussion is for new features/improvements in CS5 related to scripting. For changes to the scripting DOM which effect older scripts please use this discussion instead.

 

Appropriate topics are ones which revolve around the ESTK, InDesign's DOM, or new technologies (such as the new "CS Extension Builder"). Please try to keep the discussion on topic!

 

Thanks,

Harbs

With CS4, some things have changed

$
0
0
This topic is not about new features but changes, primarily in the object model, that will affect scripts that run perfectly well under CS3.

Bear in mind that as before, you can create a folder for previous version scripts and run from there, in which case the previous object model is employed -- indeed, CS4 allows you to do this for scripts all the way back to CS scripts. The Object Model Viewer in ESTK, once you've initialized it by opening it once and choosing the InDesign CS4 Object Model, allows you to see all four supported object models.
Viewing all 15932 articles
Browse latest View live


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