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

Script info

$
0
0

Hi, all.

 

Is there any possibility to display some information to user (e.g. number of pages processed) in status bar or something like that? MsgBox doesn't help, because it interrupts execution of the script. (vba only)


Find format preferences in a Find/Change GREP script?

$
0
0

Hi all,

 

I'm creating my first Find/Change script to handle several GREP queries at once. But I'm struggling to work out how to specify the Find Format: preference in the script as one can in the usual Find/Change dialog box.

 

Here's a sample line in my script. What I'm trying to achieve is for this line to search for characters/words that currently have the [Basic Paragraph] applied to it, and then change the format to a particular paragraph style, which I've called "Team name" ...

 

grep     {findWhat:"(.+)", appliedParagraphStyle:"[Basic Paragraph]"}     {changeTo:"$1", appliedParagraphStyle:"Team name"}     {}     // apply Team name style

 

Btw, I'm using the standard FindChangeByList script that comes with Indesign. All help/feedback is appreciated.

 

Cheers,

Marco

Script to Export INDD file as PDF, named to match containing folder, not original file name

$
0
0

All - I am trying to create a script to open an INDD file and export to PDF, not as the file name but as the name of the folder containing the PDF. Any ideas?

Background Export Cancelled - Event? (JS)

$
0
0

I'm having trouble figuring out how to capture when a user cancels a background export task (from the background tasks panel). ImportExportTask.FAILED_EXPORT doesn't appear to work as described by the documentation, regardless if I listen on the app or the document being exported.

 

I've also tried using Idletasks which wait for changes in status to the BackgroundTask, but it seems really dirty, and IdleEvent.ON_IDLE events don't trigger reliably enough for my purposes (based on my own experience).

 

Ideally I'd like to capture the completion of asynchronous export events (success, failure, or cancellation) as soon as they happen, so that I can close the associated documents (which my script has generated and remain open in the background during the export process) and let the user get on with their day. Success events are no problem, it's the others I'm having trouble with.

 

I'd really appreciate it if anyone could help me with this, I've been spinning my wheels on this one for far too long.

 

Thanks!

 

PS: I am using JS, and Indesign CC 2014

[JS CS3 WIN] ExportEachPageAsPDF

$
0
0

Hello,

 

I have found this script. Now I want to modify the filename section.

 

//ExportEachPageAsPDF.js  
//Exports each page of an InDesign CS document as a separate PDF to  
//a selected folder using the selected PDF export settings.  
//Display a "choose folder" dialog box.  
if(app.documents.length != 0){  
    var myFolder = Folder.selectDialog ("Choose a Folder");  
    if(myFolder != null){  
        myExportPages(myFolder);  
    }  
}  
else{  
    alert("Please open a document and try again.");  
}  
function myExportPages(myFolder){  
    var myPageName, myFilePath, myFile;  
    var myDocument = app.activeDocument;  
    var myDocumentName = myDocument.name;  
    var myPDFPresets = app.pdfExportPresets;
    var myPDFPresetNames = new Array;
    for (i = 0; i < myPDFPresets.length; i++)
        myPDFPresetNames.push(myPDFPresets[i].name); 

    var myDialog = app.dialogs.add();  
    with(myDialog.dialogColumns.add()){ 
        with(dialogRows.add()){   
            with(dialogColumns.add()) {
                staticTexts.add({staticLabel:"Base name:", minWidth:130});  
            }
            with(dialogColumns.add()) {
                var myBaseNameField = textEditboxes.add({editContents:myDocumentName,   minWidth:160});  
            }
        }  
        with(dialogRows.add()){ 
            with(dialogColumns.add()){ 
                staticTexts.add({staticLabel:"PDF preset: ", minWidth:130}); 
            } 
            with(dialogColumns.add()){ 
                var myPDFPresetsDropdown = dropdowns.add({stringList:myPDFPresetNames,  selectedIndex:0}); 
            } 
        } 
    }
    var myResult = myDialog.show({name:"ExportPages"});  
    if(myResult == true){  
        var myBaseName = myBaseNameField.editContents;  
        var myPDFPresetName = myPDFPresetNames[myPDFPresetsDropdown.selectedIndex];
        //Remove the dialog box from memory.  
        myDialog.destroy();  
        for(var myCounter = 0; myCounter < myDocument.pages.length; myCounter++){  
            myPageName = myDocument.pages.item(myCounter).name;  
            app.pdfExportPreferences.pageRange = myPageName; 

 

//Generate a filename. /////////////////////////////
          app.findTextPreferences.appliedParagraphStyle = "picture_description"; 
          app.findTextPreferences.findWhat = '';
         
         myStory = myDocument.stories;
   
          myFound = myStory.findText();
         
       // alert(myFinds[0].contents);

 

            myFilePath = myFolder + "/" + myFound[0].contents + ".pdf";  
            myFile = new File(myFilePath);  
            myDocument.exportFile(ExportFormat.pdfType,   myFile, false, myPDFPresets.item(myPDFPresetName)); 

///////////////////////


        }  
    }  
    else{  
        myDialog.destroy();  
    }  
}

 

On every page there is only 1 paragraph styled with the paragraphstyle "picture_description".

I want to use the content of this paragraph for the filename for each page.

 

please, can someone help me?

 

Best regards

Christoph

how to use evaluateXpathexpression through vbs?

$
0
0

hii

 

i want to know how to use EvaluateXpathExpression through vbscript or vb.net?

How to get loop through the elements and get all the elements with the same name?

 

Please help

Thanks

how to use evaluateXpathexpression without using any namespace?

$
0
0

hello

Can anyone please tell me how to use evaluatexpathexpression without using any namespace and adding the child elements to root element?

Is there any way?

Please help

 

Thanks

Dynamically populate InDesign file and publish

$
0
0

Greetings,

 

I have a database full of text and I would like to publish the data into a nicely designed InDesign file. I can easily dump the data into XML, JSON, or raw Text but is it possible to dynamically populate an InDesign file with this data then publish straight to PDF? Are there any examples of dyanmic data being published from an external source (like XML, JSON, etc.)?


Import .eps file script?

$
0
0

Hi all,

 

I am using InDesign CS6 and need help with a script (JavaScript) 

 

I'm doing the exact same thing as this previous discussion below, Exporting MathType equations from Word as EPS files and then trying to place them into my indesign file.

 

Batch importing eps equations into Indesign

 

Since this discussion, is there a better script or method to import .eps files? (see screenshot below)

 

I placed my Word file into InDesign. What I think this script is supposed to do is replace all the @Equ021.eps@ file names with those images in the file path on line 23.

 

Below is the script I am using and apparently all I needed to do was save my script after I entered the path name on line 23. (The person who gave me this no longer works with me so I am on my own)

When I try to save, I receive the error:

error.png

I'm very new to scripting so what does this error below mean, and what do I need to do to fix it?

scrpit.png

 

Thanks for any help! I have thousands of these equations and would hate to import them one by one.

[ID8+/JS] Context Menu Item for Paragraph and Character Style Palette

$
0
0

Hello,

 

I'm looking for a way to add custom scripts to the context menus (right click with the mouse) of the paragraph style and the character style palette.

 

So the user finds the style he's looking for, right clicks on it, chooses my script, the script gets the reference to the selected style item, and runs with it.

 

Is this possible by scripting? A forum and google search was unsuccessful.

 

Thanks!

Tobias

open docs add layer

$
0
0

Hi experts

 

Could some show me how make this script working?

thanks

 

Regard

John

 

        var docs = app.documents;

        for (var i = docs.length-1; i >= 0; i--) {

                docs.layers.add({name: "pics"});

                docs.rectangles.everyItem().itermLayer = "pics"

                }

      alert("Finish.") 

 

I want add a layer "pics" in all open docs, then move all pics to the layer "pics".

cells strokes fill color to none

$
0
0

Hi experts

 

Could someone show me how to full stroke color to none.

 

regard

John

 

how to make it works?

 

    app.activeDocument.stories.everyItem().tables.everyItem().cells.everyItem().strokes.every Item().fillColor = "None";

RSA Library for ExtendScript?

$
0
0

Hi,

has anyone been able to implement a JS library for RSA encryption in ExtendScript?

I've been using CryptoJS quite successfully, but it lacks a RSA module. I've tried travist/jsencrypt · GitHub with no luck (ExtendScript complains for few things, like window and navigator), I'll be trying digitalbazaar/forge · GitHub too in the next days.

Any suggestion is welcome.

Thank you!

 

Davide Barranca

Struggling to understand CoordinateSpaces using resolve method

$
0
0

As the title of my post says... I'm struggling to understand CoordinateSpaces. I read the description provided in the 'Adobe InDesign CS6 JavaScript Scripting Guide' and I created a simple document to confirm my understanding. But the results I received were not as expected and I don't think I understanding some core concepts.

 

I will write some blocks of code and then try to explain what I think they work.

 

$.writeln( document.selection[0].resolve( [[0,0], BoundingBoxLimits.GEOMETRIC_PATH_BOUNDS], CoordinateSpaces.PAGE_COORDINATES )[0] );

 

This functions as I expected. The following is a breakdown of the arguments and my understanding of them:

  1. [0,0], BoundingBoxLimits.GEOMETRIC_PATH_BOUNDS
    1. [0,0] – anchor position relative to the object bounds – Top Left
    2. BoundingBoxLimits.GEOMETRIC_PATH_BOUNDS –  I am assuming that this makes the anchor position relative to the PageItem's path where as OUTER_STROKE_BOUNDS makes the anchor position include stroke weight extending past the PageItem's path
  2. CoordinateSpaces.PASTEBOARD_COORDINATES – Is the location of the anchor point within the pasteboard coordinate space


Now this is all understandable but then I saw the following code on indiscripts:

 

$.writeln( document.selection[0].resolve( [[0,0], BoundingBoxLimits.GEOMETRIC_PATH_BOUNDS, CoordinateSpaces.INNER_COORDINATES], CoordinateSpaces.INNER_COORDINATES)[0];


  1. [0,0], BoundingBoxLimits.GEOMETRIC_PATH_BOUNDS, CoordinateSpaces.INNER_COORDINATES]
    1. [0,0] – as above
    2. BoundingBoxLimits.GEOMETRIC_PATH_BOUNDS – as above
    3. CoordinateSpaces.INNER_COORDINATES – This bit I don't understand. I read the Adobe InDesign CS6 JavaScript Scripting Guide and it seems to suggest that this is the location of the anchor point within the coordinate space. But that doesn't make sense to me because thats what the last argument is meant to do isn't it?
  2. CoordinateSpaces.INNER_COORDINATES – Confused now because of point above


So as you can see this example the introduction of a coordinate space in the first argument confuses me. If somebody could help me understand its purpose I would really appreciate it.

 

Also I have the following questions about coordinate spaces:

  1. PARENT_COORDINATES – Wouldn't this just be spread? All PageItems parents are a spread right?
  2. INNER_COORDINATES – What is this!? Documentation says it's the coordinate space the object was created in. How can I tell what coordinate space an object is created in? Why is this usful? If I draw a rectangle on a page is its created the pasteboard, page, or spread coordinate space?

How define table

$
0
0

Hi experts,

 

I have a script for find table and change properties.

Could someone show me how to make it works.

 

Regard

John

 

                        myDoc = app.activeDocument;

                        findTable();

                        function findTable(){

                            for ( s = myDoc.stories.length-1; s >= 0; s-- ){

                                for ( t = myDoc.stories[s].tables.length-1; t >= 0; t-- ){

                                    myTable = myDoc.stories[s].tables[t];

                                    tables[t].cells.everyItem().texts.everyItem().fillColor = "Black";

                                    tables[t].cells.everyItem().fillColor = "None";

                                    tables[t].cells.everyItem().leftEdgeStrokeColor = "None";

                                    tables[t].cells.everyItem().rightEdgeStrokeColor = "None";

                                    tables[t].cells.everyItem().topEdgeStrokeColor = "None";

                                    tables[t].cells.everyItem().bottomEdgeStrokeColor = "None";

                                }

                            }

                        }

                    alert("Finish.") 


How to open instanceof folder

$
0
0

Hi experts

 

I want to open the indd files which in the instance of folder.

How can I make it works.

my script as below, could some tell me what's wrong with the script.

 

Regard

John

 

 

#target indesign

       app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;

       var folder = Folder.selectDialog ("Select the root folder");  

       var myfiles = [];  

       getsubfolderfiles(folder);  

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

                        {  

               var docs = app.open(myfiles[i]);  

                                    for (i = docs.length-1; i >= 0; i--) {

                                        var myTables = docs[i].stories.everyItem().tables.everyItem().getElements() 

                                            for ( t = 0; t < myTables.length; t++ ){ 

                                                    myTables[t].cells.everyItem().texts.everyItem().fillColor = "Black"; 

                                                    myTables[t].cells.everyItem().fillColor = "None"; 

                                                    myTables[t].cells.everyItem().leftEdgeStrokeColor = "None"; 

                                                    myTables[t].cells.everyItem().rightEdgeStrokeColor = "None"; 

                                                    myTables[t].cells.everyItem().topEdgeStrokeColor = "None"; 

                                                    myTables[t].cells.everyItem().bottomEdgeStrokeColor = "None"; 

                                                    } 

                                        } 

                               }    

                          

                          

                    function getsubfolderfiles(folder)  

                              {  

                                  var filelist = folder.getFiles();  

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

                                  {  

                                      if(filelist[i] instanceof Folder)  

                                      {  

                                          getsubfolderfiles (filelist[i]);  

                                      }  

                                      else if(filelist[i] instanceof File)  

                                      {  

                                          if(filelist[i].name.indexOf(".indd") > -1){  

                                              myfiles.push(filelist[i]);  

                                          }  

                                      }  

                                  }  

                              } 

 

 

                                   

                             var docs = app.documents;

                                 for (var i = docs.length-1; i >= 0; i--) {

                                     if(docs[i].saved == false){

                                           docs[i].close(SaveOptions.NO);

                                         }

                                     else if(docs[i].close(SaveOptions.YES));

                                    }

                          app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;

                         

                          alert("Finish.")

Tables and boxes in eps format

$
0
0

I need to convert tables and boxes in eps format. Is this possible via scripting.



how to ignore or skip the empty cells in a table using indesign javascript.

$
0
0

i dont want to delete or remove the empty cells in my table , but i want skip or ingore the empty cells..

when doing tab alignment to that table..

need a script for hyperlink data merge placing numerous and different urls into text

$
0
0

I need to find a script that can take urls from a .txt file and merge them into an indesign document INTO text that reads "LINK TO ARTICLE". There are many different urls going into the document. I can already do the data merge and it places the url in text form. Then i can convert them to active hyperlinks. What i need to be able to do is insert the urls as a hyperlink into the text, rather than just showing a long string of text/url.

Any help?

Thank you very much!!!

AD

Getting the footnote number for index entries which are in footnotes

$
0
0

I am laying out a scholarly book, and have just finished the index. Now I need to find which entries are in footnotes, and get the footnote number. I will then manually edit the generated index to include the footnote numbers. Each chapter is in a separate story within the same Indesign document (not an Indesign Book), and the footnote numbering starts over at the beginning of each chapter/story. I have also included some of the front matter in the index, so I do have entries in lower-case roman numerals.

 

Example.

Original: A se ipso (Aseity) 190, 231, 253, 269, 270, 272, 274

Edited: A se ipso (Aseity) 190, 231nn96-97, 253, 269, 270n201, 272, 274

 

The logic I am thinking of would go something like:

Open new document

For each index entry

     If (in footnote)

          Get and output: topic, (tab) page number/range associated with entry, (tab) footnote number (new line)

     end if

end For Each

end script

 

Alternatively, I could

     Search through only footnotes

          at each entry output: topic, (tab) page number/range associated with entry, (tab) footnote number (new line)

 

In another thread, I saw this:

  1. myFoot = app.selection[0].footnotes[0]; 
  2. whichOne = myFoot.index - myFoot.parent.footnotes[0].index; 

 

This may be what I am looking for, but i am not yet sure, since I also saw that "index" refers to the z-order.

 

Unfortunately, I am not familiar with Indesign Scripting, so the actual piecing it together by myself is, currently, beyond me. I could do this manually (I have started doing so) but that will take quite a while, and this book is already overdue.

 

God reward you,

brother Charles, FI

Viewing all 8771 articles
Browse latest View live


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