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

paragraph

$
0
0

Hi,

 

I made a script for add a continued at end of paragraph but unfunction, call you please help to fix it?

 

var myDialog = app.dialogs.add({name:"add continueds",canCancel:true});
with(myDialog){
    with(dialogColumns.add()){
        with(dialogRows.add()){
           var mySelection = dropdowns.add({stringList:["Continued", "continued", "Cont'd","cont'd"], selectedIndex:0});
       }
   }
}


if (myDialog.show() == true)
   
main();
function main(){
var myObject;
var myCheckSelection = false;
if(app.documents.length > 0){
  if(app.selection.length > 0){
   switch(app.selection[0].constructor.name){
    case "InsertionPoint":
    case "Character":
    case "Word":
    case "TextStyleRange":
    case "Line":
    case "Paragraph":
    case "TextColumn":
    case "Text":
    case "Cell":
    case "Column":
    case "Row":
    case "Table":
     myObject = app.selection[0];
     if(myObject != "None")
   }
  }
}
else{
  alert("No documents are open. Please open a document and try again.");
}
}
function addContinueds(){
    if (mySelection.selectedIndex == 0){
   app.findGrepPreferences.findWhat = "(.)\\r";
   app.changeGrepPreferences.changeTo = "$1 (Continued)\\r";
   app.selection[0].changeGrep();
   app.findGrepPreferences = app.changeGrepPreferences = null;
    }
    if (mySelection.selectedIndex == 1){
   app.findGrepPreferences.findWhat = "(.)\\r";
   app.changeGrepPreferences.changeTo = "$1 (continued)\\r";
   app.selection[0].changeGrep();
   app.findGrepPreferences = app.changeGrepPreferences = null;
    }
   if (mySelection.selectedIndex == 2){
   app.findGrepPreferences.findWhat = "(.)\\r";
   app.changeGrepPreferences.changeTo = "$1 (Cont'd)\\r";
   app.selection[0].changeGrep();
   app.findGrepPreferences = app.changeGrepPreferences = null;
    }
  if (mySelection.selectedIndex == 3){
   app.findGrepPreferences.findWhat = "(.)\\r";
   app.changeGrepPreferences.changeTo = "$1 (cont'd)\\r";
   app.selection[0].changeGrep();
   app.findGrepPreferences = app.changeGrepPreferences = null;
    }
}

 

John


Can you correct my unfunction my script?

$
0
0

Hi, everyone

 

I made a script for add a continued at end of paragraph but unfunction, call you please help to fix it?

 

var myDialog = app.dialogs.add({name:"add continueds",canCancel:true});
with(myDialog){
    with(dialogColumns.add()){
        with(dialogRows.add()){
           var mySelection = dropdowns.add({stringList:["Continued", "continued", "Cont'd","cont'd"], selectedIndex:0});
       }
   }
}


if (myDialog.show() == true)
   
main();
function main(){
var myObject;
var myCheckSelection = false;
if(app.documents.length > 0){
  if(app.selection.length > 0){
   switch(app.selection[0].constructor.name){
    case "InsertionPoint":
    case "Character":
    case "Word":
    case "TextStyleRange":
    case "Line":
    case "Paragraph":
    case "TextColumn":
    case "Text":
    case "Cell":
    case "Column":
    case "Row":
    case "Table":
     myObject = app.selection[0];
     if(myObject != "None")
   }
  }
}
else{
  alert("No documents are open. Please open a document and try again.");
}
}
function addContinueds(){
    if (mySelection.selectedIndex == 0){
   app.findGrepPreferences.findWhat = "(.)\\r";
   app.changeGrepPreferences.changeTo = "$1 (Continued)\\r";
   app.selection[0].changeGrep();
   app.findGrepPreferences = app.changeGrepPreferences = null;
    }
    if (mySelection.selectedIndex == 1){
   app.findGrepPreferences.findWhat = "(.)\\r";
   app.changeGrepPreferences.changeTo = "$1 (continued)\\r";
   app.selection[0].changeGrep();
   app.findGrepPreferences = app.changeGrepPreferences = null;
    }
   if (mySelection.selectedIndex == 2){
   app.findGrepPreferences.findWhat = "(.)\\r";
   app.changeGrepPreferences.changeTo = "$1 (Cont'd)\\r";
   app.selection[0].changeGrep();
   app.findGrepPreferences = app.changeGrepPreferences = null;
    }
  if (mySelection.selectedIndex == 3){
   app.findGrepPreferences.findWhat = "(.)\\r";
   app.changeGrepPreferences.changeTo = "$1 (cont'd)\\r";
   app.selection[0].changeGrep();
   app.findGrepPreferences = app.changeGrepPreferences = null;
    }
}

 

John

Folder Array

$
0
0

Hello guys

 

How do I make an array to create all theese folders?

 

if they not exists create them

 

here is my code so far

 

 

 

function createFolderStructure()     {
var a = new Folder("/Volumes/Arkiv/XXXXXXX/XXXXXX/_project_BACKUP");
var b = new Folder("/Volumes/Arkiv/XXXXXXX/XXXXXX/blåkopior i 34xxxx_BACKUP");
var c = new Folder("/Volumes/Arkiv/XXXXXXX/XXXXXX/delivery_BACKUP");
var d = new Folder("/Volumes/Arkiv/XXXXXXX/XXXXXX/DTP_BACKUP");
var e = new Folder("/Volumes/Arkiv/XXXXXXX/XXXXXX/inter_BACKUP");
var f = new Folder("/Volumes/Arkiv/XXXXXXX/XXXXXX/script_BACKUP");
var g = new Folder("/Volumes/Arkiv/XXXXXXX/XXXXXX/source_BACKUP");
var h = new Folder("/Volumes/Arkiv/XXXXXXX/XXXXXX/translation to_BACKUP");
var i = new Folder("/Volumes/Arkiv/XXXXXXX/XXXXXX/validation 1_BACKUP");
var j = new Folder("/Volumes/Arkiv/XXXXXXX/XXXXXX/validation 2_BACKUP");


if (!a,b.exists)
        b.create();   }

 

 

 

Thank you in advance

all good Adobe Members!

How to use script to open a folder on desktop?

$
0
0

Hi, everyone

 

I want open a folder on desktop after gen PDF but error, can someone help me to fix it?


var f = new Folder(“~/Desktop/Revised_PDF put in here/”); 
f.create();

var doc = app.documents; 
app.findTextPreferences = null; 
app.findTextPreferences.underline = true; 
for(var i=0;i<doc.length;i++) 

        var found = doc[i].findText(); 
        var _pages = []; 
        for(var j=0;j<found.length;j++) 
        { 
                var txfms = found[j].texts[0].parentTextFrames; 
                for(var k=0;k<txfms.length;k++) 
                { 
                        _pages.push(txfms[k].parentPage.name); 
                    } 
            } 
        for(var j=0;j<_pages.length;j++) 
        { 
                if(_pages[j] === _pages[j-1]) 
                { 
                        _pages.splice(j,1); 
                    } 
            } 
        if(_pages.length != 0) 
        { 
                app.pdfExportPreferences.pageRange = _pages.toString(); 
                doc[i].exportFile(ExportFormat.PDF_TYPE, new File(“~/Desktop/Revised_PDF put in here/” + doc[i].name.replace(/\.indd$/i,”.pdf”)), false);
            } 
        _pages = []; 
    } 
app.findTextPreferences = null;


folder.open(“~/Desktop/Revised_PDF put in here/”)  // <-----------this line error

 

John

why do I get this result when I use split

$
0
0

Hello guys

I have created a script that looking for the active path,

 

 

var myPath = (File($.fileName).parent.parent.parent.fullName);
alert(myPath)

 

I recieve "/xxxxx/xxxx/xxxx/341542"

 

the only thing I am interested of in this information it's the number,

 

so I added on the code

 

var myPath = (File($.fileName).parent.parent.parent.fullName).split("xxxx/xxxx/xxxx/");

 

the problem is

I recieve ",341542"

 

why do I recieve a comma before the number??

 

there is no comma. in the path.

export pdf per two pages

$
0
0

Hey all,

 

I need to export to pdf in 2-page-increments

 

I found a somewhat similar script here in the forum but can't get it to work. Must be an error somewhere

 

Would someone please check and correct this for InD CC2014?

 

Thanks so much.

 

// Output PDF pages per 2 pages.  //

var SectionLength = 2;

for (var p=0; p<app.activeDocument.pages.length; p += SectionLength)

{

     with(app.pdfExportPreferences)

     {

          if (p+SectionLength-1 > app.activeDocument.pages.length)

               pageRange = app.activeDocument.pages[p].name+"-"+app.activeDocument.pages[app.activeDocument.pages.le ngth-1].name;

          else

               pageRange = app.activeDocument.pages[p].name+"-"+app.activeDocument.pages[p+SectionLength-1].name;

          theFile = new File(pageRange+".pdf");

          app.activeDocument.exportFile (ExportFormat.pdfType, theFile, false);

     }

}

HTTP: link problem

$
0
0

Hi All

 

I have problem vile am automated work flow when it comes references It create problem in HTTP://

 

While running script [Open Dialog was appear and it show Link of this site.

 

 

APA. (n.d.). Leadership Institute for Women in Psychology. Retrieved fromhttp://www.apa.org/women/programs/leadership/index.aspx

 

Kindly suggest us.

 

Regards

Ramakrishna.K

Copy foldername and specific indd files.

$
0
0

Hello guys


I need a function,

 

there is first a dialog-window that appears, from the dialog-window I select some indd files and pressed ok.(that have not to be all indd files from the folder)

then appears a new dialog window so I can select a target to copy the selected files into also, copy the foldername from the selected indd files location and create that folder and put the files when I have selected a target.


finally  create a textfile to save all indd filenames in / or if its possible to tag them in another way so I got them in.

I know in mac finder you can put a color on files.

 

Could someone help me out?

 

Thank you in advance

 

All Adobe Members


Cheers!


How add color not to swatch?

$
0
0

I want add a color to document,but  i don't want exist in swatch:

I use code:

myDocument.Colors.Add

but it add to swatch too.

How to let selectedIndex keep previous choise?

$
0
0

Hi, everyone,

 

I want to:

 

same script UI2.jpg

let the script do as same as last thing

 

 

 

 

I have a script as below:

 

 

var myDialog = app.dialogs.add({name:"add continueds",canCancel:true});
with(myDialog){
    with(dialogColumns.add()){
        with(dialogRows.add()){
           var mySelection = dropdowns.add({stringList:["Continued", "continued", "Cont'd","cont'd"], selectedIndex:0});
       }
   }
}


if (myDialog.show() == true)
   
main();
function main(){
var myObject;
var myCheckSelection = false;
if(app.documents.length > 0){
  if(app.selection.length > 0){
   switch(app.selection[0].constructor.name){
    case "InsertionPoint":
    case "Character":
    case "Word":
    case "TextStyleRange":
    case "Line":
    case "Paragraph":
    case "TextColumn":
    case "Text":
    case "Cell":
    case "Column":
    case "Row":
    case "Table":
     myObject = app.selection[0];
  if(app.selection && app.selection[0].hasOwnProperty ("contents") );
      addContinueds(); 
    }
  }
}
else{
  alert("No documents are open or wrong selection. Please try again.");
}
}
function addContinueds() { 
    if (mySelection.selectedIndex == 0){
   app.findGrepPreferences.findWhat = "(.)\\r";
   app.changeGrepPreferences.changeTo = "$1 (Continued)\\r";
   app.selection[0].changeGrep();
   app.findGrepPreferences = app.changeGrepPreferences = null;
    }
    if (mySelection.selectedIndex == 1){
   app.findGrepPreferences.findWhat = "(.)\\r";
   app.changeGrepPreferences.changeTo = "$1 (continued)\\r";
   app.selection[0].changeGrep();
   app.findGrepPreferences = app.changeGrepPreferences = null;
    }
   if (mySelection.selectedIndex == 2){
   app.findGrepPreferences.findWhat = "(.)\\r";
   app.changeGrepPreferences.changeTo = "$1 (Cont'd)\\r";
   app.selection[0].changeGrep();
   app.findGrepPreferences = app.changeGrepPreferences = null;
    }
  if (mySelection.selectedIndex == 3){
   app.findGrepPreferences.findWhat = "(.)\\r";
   app.changeGrepPreferences.changeTo = "$1 (cont'd)\\r";
   app.selection[0].changeGrep();
   app.findGrepPreferences = app.changeGrepPreferences = null;
    }
}

 

 

 

for do some tedious works, but it has some options, how can I add something to it aim to tell the script I want to do something as previous choice?

I expected it can remember the last what I do. and then do as same as previous jobs.

like I want to repeat one job again and again

 

 

John

Need script for "Convert bullets and numbering to text"

$
0
0

Hi

Need script for "Convert bullets and numbering to text".


Help to set activepath on my function

$
0
0

Hello guys,

 

Chinnadk helped me with this function

 

my question is..

I wonder how do I add a default path so each time the File.openDialog comes up it navigastes to ("C:/test/xxx example")

see my function below

 

 

function copyfiles()  {  var _files = File.openDialog("Select indesign files","*.indd",true),   TargetFolder= Folder.selectDialog("Select the target folder"),   _parent = _files[0].parent.toString().replace(_files[0].parent.parent,"");   new Folder(TargetFolder+ _parent).create();   var filenames = "";   var txtfile = new File(TargetFolder+ _parent + "/myFileLog.txt");   for(var i=0;i<_files.length;i++)   {   _files[i].copy(new File(TargetFolder+ _parent + "/" + _files[i].name));   filenames +=_files[i].name + "\r";   }   txtfile.open('w');   txtfile.write(filenames);   txtfile.close();   //txtfile.execute();   öppnar textfilen  //#include "/Kommuni/LaRe/LareAUTO/341542/scripts/interface/scripts/KABPDFExport_1.jsx"  // $.writeln(myFile.displayName);  // just for write the data in console 


}

 

 

thank you in advance

 

All good Adobe Members!

 

Cheers

How Can I add a dialog in script?

$
0
0

Hi, everyone,

 

I have this script:

 

var myDialog = app.dialogs.add({name:"Tedious Works",canCancel:true}); // <--------- I think can add a dialog in this line but I don't know the syntax
with(myDialog){
    with(dialogColumns.add()){
        with(dialogRows.add()){
           var mySelection = dropdowns.add({stringList:["end digit superscript", "beginning digit superscript", "notes to italic","Initial Cap+ markup","Small Cap + markup","del [ ] + markup","add an EM at beginning"], selectedIndex:0});
       }
   }
}


if (myDialog.show() == true)
   
main();
function main(){
var myObject;
var myCheckSelection = false;
if(app.documents.length > 0){
  if(app.selection.length > 0){
   switch(app.selection[0].constructor.name){
    case "InsertionPoint":
    case "Character":
    case "Word":
    case "TextStyleRange":
    case "Line":
    case "Paragraph":
    case "TextColumn":
    case "Text":
    case "Cell":
    case "Column":
    case "Row":
    case "Table":
     myObject = app.selection[0];
  if(app.selection && app.selection[0].hasOwnProperty ("tedious_works") );
      tedious_works(); 
    }
  }
}
else{
  alert("No documents are open or wrong selection. Please try again.");
}
}
function tedious_works() { 
    if (mySelection.selectedIndex == 0){
   app.findGrepPreferences.findWhat = "\\d$";
   app.changeGrepPreferences.position = 1936749411;
   app.selection[0].changeGrep();
   app.findGrepPreferences = app.changeGrepPreferences = null;
    }
    if (mySelection.selectedIndex == 1){
   app.findGrepPreferences.findWhat = "^\\d";
   app.changeGrepPreferences.position = 1936749411;
   app.selection[0].changeGrep();
   app.findGrepPreferences = app.changeGrepPreferences = null;
    }
   if (mySelection.selectedIndex == 2){
   app.findGrepPreferences.findWhat = "(?i)\\(note.+\\)$";
   app.changeGrepPreferences.appliedCharacterStyle = "Italic";
   app.selection[0].changeGrep();
   app.findGrepPreferences = app.changeGrepPreferences = null;
    }
  if (mySelection.selectedIndex == 3){
   app.findGrepPreferences.findWhat = "(附[註注].+)$";
   app.changeGrepPreferences.appliedCharacterStyle = "Italic";
   app.selection[0].changeGrep();
   app.findGrepPreferences = app.changeGrepPreferences = null;
    }
  if (mySelection.selectedIndex == 4){
   app.findGrepPreferences = app.changeGrepPreferences = null;
   app.findGrepPreferences.findWhat = "\\<a";
   app.changeGrepPreferences.changeTo = "A";
   app.changeGrepPreferences.underline = true;
   app.selection[0].changeGrep();
   app.findGrepPreferences = app.changeGrepPreferences = null;

//...........................not to show too much

 

 

 

I want to add a dialog “please select a tedious works” under the bar, see pic:

 

dialog.jpg

please tell me what is the syntax?

How to display Progress Bar while exporting PDF from Book using Javascript

$
0
0

I am using CS6 and by using Javascript I am adding all the InDesign documents to book and generating a Interative PDF from that book.

 

Its taking too much time, so want to see the progress of exporting PDF from book, and I don't want to ask the user to show the PDF export options.

 

How to show the progress bar while exporting PDF from book, and the background process panel is not showing any progress at all.

 

Any help appreciated.

How Can I add a some functions into script?

$
0
0

Hi, everyone

 

I got this script:

 

if ( app.selection.length > 0 && ( app.selection[0].constructor.name == "Cell" || app.selection[0].constructor.name == "Table" ) ) {  

    if ( app.scriptPreferences.version >= 6 ) { 

        app.doScript( main, ScriptLanguage.JAVASCRIPT , [], UndoModes.ENTIRE_SCRIPT, "style every second column in selection" );          

    }  

    else { 

        main(); 

    } 

} else { 

    alert ( "Nothing or wrong selection!" ); 

 

function main() { 

     

    var myColor = "Black"; 

    var myFillTint = 20; 

    var myCharStyleName = "Bold"; 

    var myStrokeWeight = 0.5; 

 

    var curSel = app.selection[0]; 

    var allCells = curSel.cells; 

    var startCol = curSel.cells[0].name.split(":")[0]*1;    

    var endCol = curSel.cells[-1].name.split(":")[0]*1; 

    var startRow = curSel.cells[0].name.split(":")[1]*1;    

    var endRow = curSel.cells[-1].name.split(":")[1]*1;   

    var counter = startCol + 1; 

 

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

        var curCell = allCells[i]; 

        var curCol = curCell.name.split(":")[0]*1; 

        var curRow = curCell.name.split(":")[1]*1; 

 

        if ( curCol == counter ) { 

            with ( curCell ) { 

                fillColor = myColor; 

                fillTint = myFillTint; 

                texts[0].appliedCharacterStyle = myCharStyleName; 

                rightEdgeStrokeWeight = myStrokeWeight; 

                rightEdgeStrokeColor= myColor;  

                leftEdgeStrokeWeight = myStrokeWeight; 

                leftEdgeStrokeColor= myColor;                  

            } 

            if ( curRow == startRow ) { 

                curCell.topEdgeStrokeWeight = myStrokeWeight; 

                curCell.topEdgeStrokeColor= myColor; 

            } 

            else if (curRow == endRow ) { 

                curCell.bottomEdgeStrokeWeight = myStrokeWeight; 

                curCell.bottomEdgeStrokeColor= myColor; 

            } 

             

            counter = counter + 2; 

        } 

         

        if ( counter > endCol ) { 

            counter = startCol + 1; 

        } // end if 

    } // end for 

} // end main

 

which made by Kai Rübsamen

 

Can cells like this:

 

before

 

modify cell before.jpg

 

After

 

modify cell after.jpg

 

but what if I want add a function into it, let the script can make dollar sign italic?

like this:

 

modify cell add to it.jpg

I expected it can let me thoose which row I want to make it Bold+Italic, and Italic

 

How can I do that?

 

John


Indesign Applescript Placed Object Layer Visibilty Override

$
0
0

Hi, trying to programmatically control layer visibility of placed objects (either AI or other ID files) in a multi-page Indesign document.  Have looked all over the dictionary but can't seem to figure a way to reference the layers.

 

Would someone have an example of how to do this in Applescript?  (Please, not javascript, will convert one day but for now am staying with AS.)

 

Thanks!

Script UI layout

$
0
0

Hi everyone,

 

I made a Script UI like this:

 

script UI.jpg


the code:

 

var myDialog = app.dialogs.add({name:"Modify current years' cells"});
with(myDialog.dialogColumns.add()){
  with(dialogRows.add()){
   with(dialogColumns.add()){
    with(borderPanels.add()){
     staticTexts.add({staticLabel:"Column fill colour?"});
     var myVerticalAlignmentButtons = radiobuttonGroups.add();
     with(myVerticalAlignmentButtons){
      radiobuttonControls.add({staticLabel:"Yes", checkedState: true});
      radiobuttonControls.add({staticLabel:"No"});
     }
    }
   }
    with(dialogColumns.add()){
        with(dialogRows.add()){
   staticTexts.add({staticLabel:"Color:"});
           var mySelection = dropdowns.add({stringList:["Red", "Green"], selectedIndex:1});
       }
   }
    with(dialogRows.add()){
   staticTexts.add({staticLabel:"Tint:"});
        with(dialogColumns.add()){
           var mySelection = dropdowns.add({stringList:["10%", "15%", "20%", "25%", "30%"], selectedIndex:2});
       }
   }

}
}
with(myDialog.dialogColumns.add()){
  with(dialogRows.add()){
   with(dialogColumns.add()){
    with(borderPanels.add()){
     staticTexts.add({staticLabel:"With stroke?"});
     var myVerticalAlignmentButtons = radiobuttonGroups.add();
     with(myVerticalAlignmentButtons){
      radiobuttonControls.add({staticLabel:"Yes", checkedState: true});
      radiobuttonControls.add({staticLabel:"No"});
     }
    }
   }
    with(dialogColumns.add()){
        with(dialogRows.add()){
   staticTexts.add({staticLabel:"Stroke colour:"});
           var mySelection = dropdowns.add({stringList:["Red", "Green"], selectedIndex:1});
       }
   }
    with(dialogRows.add()){
   staticTexts.add({staticLabel:"Stroke weight:"});
        with(dialogColumns.add()){
           var mySelection = dropdowns.add({stringList:["0.5pt", "1pt", "1.5pt", "2pt"], selectedIndex:1});
       }
   }
with(myDialog.dialogColumns.add()){
  with(dialogRows.add()){
   with(dialogColumns.add()){
    with(borderPanels.add()){
     staticTexts.add({staticLabel:"With stroke?"});
     var myVerticalAlignmentButtons = radiobuttonGroups.add();
     with(myVerticalAlignmentButtons){
      radiobuttonControls.add({staticLabel:"Yes", checkedState: true});
      radiobuttonControls.add({staticLabel:"No"});
     }
    }
   }
    with(dialogColumns.add()){
        with(dialogRows.add()){
   staticTexts.add({staticLabel:"In which row:"});
           var mySelection = dropdowns.add({stringList:["1st", "2nd", "3rd", "4th", "5th", "th"], selectedIndex:1});
             }
         }
      }
   }
}
}
myDialog.show();

 


but I want this layout,

 

have a choice.jpg


Can someone help me to reorder it?


John

Liguature

$
0
0

Dear Friends,

 

See my script below, Error found in H1 style line, how to rectify this error,

 

myDoc=app.documents.item(0);

for (i=1; i<myDoc.paragraphStyles.length; i++);

{

myPstyle=myDoc.paragraphStyles.item(i);

if (myPstyle.name=="H1"); {

    myPstyle.hyphenation=false;

    }

myPstyle.ligatures=false;

}

 

Thanks

kanagakumar

Which .dll contains the Splash Screen?

$
0
0

Hey gang,

 

Do any of you know which .dll file within Adobe InDesign CS6 contains the startup splash png image file?

 

Best,

 

Mike Witherell, ACE

JS "goto item"

$
0
0

Upon choosing a XMLelement in the structure i need it's object on the page selected.

How to do that using JS? i can't find the "goto item" in ES toolkit.

 

Please advise.

Thank you.

Viewing all 8771 articles
Browse latest View live


Latest Images

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