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

Modify an Indesign script for me?

$
0
0

Hello all!

 

I'm am fairly new to Indesign scripting and I have a script here that I would like to have modified.

This script places a multi-page pdf in an Indesign file and adds pages as necessary. Right now this script pops up a dialog box that asks which document I want the pdf to be placed in and I would like to have that dialog box eleminated and have the script automatically place the pdf in the document that I have active. Also this script asks which page to start placing the pdf on and I would like if it simply would just automatically start on the first page of the active Indesign document without even asking me. Would someone be willing to make those modifications to the script below and post the code on this thread? Let me know if I did not make something clear.

 

var myDocument = app.activeDocument;
//Get the current page.
main();
function main(){  //Display a standard Open File dialog box.  var myPDFFile = File.openDialog("Choose a PDF File");  if((myPDFFile != "")&&(myPDFFile != null)){  var myDocument, myPage;  if(app.documents.length != 0){  var myTemp = myChooseDocument();  myDocument = myTemp[0];  myNewDocument = myTemp[1];  }  else{  myDocument = app.documents.add();  myNewDocument = false;  }  if(myNewDocument == false){  myPage = myChoosePage(myDocument);  }  else{  myPage = myDocument.pages.item(0);  }  myPlacePDF(myDocument, myPage, myPDFFile);  }
}
function myChooseDocument(){    var myDocumentNames = new Array;    myDocumentNames.push("New Document");    //Get the names of the documents    for(var myDocumentCounter = 0;myDocumentCounter < app.documents.length; myDocumentCounter++){        myDocumentNames.push(app.documents.item(myDocumentCounter).name);    }    var myChooseDocumentDialog = app.dialogs.add({name:"Choose a Document", canCancel:false});    with(myChooseDocumentDialog.dialogColumns.add()){        with(dialogRows.add()){            with(dialogColumns.add()){                staticTexts.add({staticLabel:"Place PDF in:"});            }            with(dialogColumns.add()){                var myChooseDocumentDropdown = dropdowns.add({stringList:myDocumentNames, selectedIndex:0});            }        }    }  var myResult = myChooseDocumentDialog.show();  if(myResult == true){  if(myChooseDocumentDropdown.selectedIndex == 0){  myDocument = app.documents.add();  myNewDocument = true;  }  else{  myDocument = app.documents.item(myChooseDocumentDropdown.selectedIndex-1);  myNewDocument = false;  }  myChooseDocumentDialog.destroy();  }  else{  myDocument = "";  myNewDocument = "";  myChooseDocumentDialog.destroy();  }    return [myDocument, myNewDocument];
}
function myChoosePage(myDocument){    var myPageNames = new Array;    //Get the names of the pages in the document    for(var myCounter = 0; myCounter < myDocument.pages.length;myCounter++){        myPageNames.push(myDocument.pages.item(myCounter).name);    }    var myChoosePageDialog = app.dialogs.add({name:"Choose a Page", canCancel:false});    with(myChoosePageDialog.dialogColumns.add()){        with(dialogRows.add()){            with(dialogColumns.add()){                staticTexts.add({staticLabel:"Place PDF on:"});            }            with(dialogColumns.add()){                var myChoosePageDropdown = dropdowns.add({stringList:myPageNames, selectedIndex:0});            }        }    }    myChoosePageDialog.show();    var myPage = myDocument.pages.item(myChoosePageDropdown.selectedIndex);    myChoosePageDialog.destroy();    return myPage;
}
function myPlacePDF(myDocument, myPage, myPDFFile){  var myPDFPage;  app.pdfPlacePreferences.pdfCrop = PDFCrop.cropMedia;  var myCounter = 1;  var myBreak = false;  while(myBreak == false){  if(myCounter > 1){  myPage = myDocument.pages.add(LocationOptions.after, myPage);  }  app.pdfPlacePreferences.pageNumber = myCounter;     myPDFPage = myPage.place(File(myPDFFile), [0,0])[0];  if(myCounter == 1){  var myFirstPage = myPDFPage.pdfAttributes.pageNumber;  }  else{  if(myPDFPage.pdfAttributes.pageNumber == myFirstPage){  myPage.remove();  myBreak = true;  }  }  myCounter = myCounter + 1;  }
}
var myPDFFrame =  myPlacePDF.parent;

 

Thanks a lot in advance for your help! I greatly appreciate it!


find all line last character and fill color

$
0
0

Dear friend,

 

I need to find all line last character and fill color (No need to words last character).

 

My code problem: Without space in the last character is not fill color.

 

My code is below:

 

var myDocument = app.activeDocument; 
var myLine = myDocument.stories.everyItem().lines.everyItem().getElements(); 
for(i=0; i<myLine.length; i++) 
{     var myCon = myLine[i].texts[0].contents;     if(myCon.match(/\n| /gi) != null){         try{             if(myLine[i].characters.item(-2).fillColor = myDocument.colors[2]);            }catch(e){}         }     } 

 

 

My screenshot also below:

last.png

 

Please suggest friend,

 

Thanks in Advance

KS

Match last line characters

$
0
0

Dear Friends.

 

I need your help:

 

My Requirements: How to match 1st line last character, 2nd line last characters and 3rd line last characters?

 

Example:

 

Last 1st line character >> a

Last 2nd line character >> a

Last 3rd line character >> a

 

My code below: (Not working)

 

var myDocument = app.activeDocument; 
//~ var myLine = app.selection[0].lines;
var myLine = myDocument.stories.everyItem().paragraphs.everyItem().lines.everyItem().getElements(); 
for(i=0; i<myLine.length; i++) 
{     var myChar;    if (String(myLine[i].characters.lastItem().contents).match(/\s/)){        myChar = myLine[i].characters.item(myLine[i].characters.length);        alert("String matches");        }    else{        myChar = myLine[i].characters.lastItem();        }           var myCharCon = myChar.contents;   alert(myCharCon)    if((String(myLine[2].characters.lastItem(-2)).charCodeAt (0).toString(16)).match(String(myLine[6].characters.lastItem(-2)).charCodeAt (0).toString(16))){        alert("String matches");        }    }

 

 

Please suggest friend

 

Thanks in Advance

KS

Convert Cross-Reference to Text

$
0
0

Does anybody have a script that will convert cross-references to text? In other words, I want to be able to remove the linkage of the cross-reference but keep the static text in place.

 

Editorial comment: I set up on my local computer several books in CS6 and used cross-references, and everything worked fine. Then I moved the files to a network location and started suffering that painful slowdown that I had experienced in previous versions of InDesign. (I foolishly believed Adobe would have fixed this by now. My mistake.)

Can't add the old version files to book

$
0
0

Hi All,

I'm working in CC2015, already we have the CS6 version files. I need to add the files in active book.

 

Kindly check the below code and guide to me.

 

Note: If the InDesign files are current version, no issue. But old version, the file can't add to book(save).

 

 

 

myExtensions = [".indd"] ; var myFilteredFiles = new Array;  var myFolder; startDate= new Date();

var myFolder = Folder.selectDialog("Select the folder containing the indesign files", "");

if(myFolder != null){

if(File.fs == "Macintosh"){

    myFilteredFiles = MyMacOSFileFilter(myFolder);

    }

else{

        myFilteredFiles = MyWinOSFileFilter(myFolder);

        }

    }

 

var myBookFileName ,myBookFileName_temp;

if (myFolder != null){

    var myFiles = [];

    var myAllFilesList = myFolder.getFiles("*.indd");

    for (var f = 0; f < myAllFilesList.length; f++){

        var myFile = myAllFilesList[f];

        myFiles.push(myFile);

        }

    if ( myFiles.length > 0)

    {

        if (app.books.length != 0) {

            var myBook = app.activeBook;

            myBook.close(SaveOptions.no); 

        }

        myBookFileName = myFolder + "/"+ myFolder.name + ".indb";

       

        myBookFileName_temp=myFolder.name;

        myBookFile = new File( myBookFileName);

        myBook = app.books.add(myBookFile);

        myBook.automaticPagination = false;

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

                myBook.bookContents.add(myFiles[i]);//struggle from here

            }

        }

    }

 

 

 

 

 

 

Selva

Trying to run Wordalizer Script

save pdf in the same location as the orginal .indd file it was exported from

$
0
0

Hello!

 

I am just starting to get my feet wet in Javascript scripting, and I am greatly enjoying it!

 

I am wanting to create a script that exports a pdf using a pdf export preset I have defined and then I want to have the pdf saved in the same folder as the indesign file that it was exported from. I already know how to export the pdf using a preset that I already have. The only thing I don't know how to do is to specify that the pdf be saved in the same folder as the Indesign file that it was exported from. Can someone please help me out? I would greatly appreciate it!

 

I would also like to find a way to name automatically have the pdf be named the same name as the Indesign file it was exported from.

 

If I need to clarify something further, feel free to let me know.

 

Thanks a lot!

a script that communicates with AI and ID

$
0
0

Hello Community

I am currently trying to wrap my head around the Extendscript Toolkit. when i write a code i specify for program i want to use by selecting it in a drop down menu, However i want to use two different programs at the same time. I want to copy all the pageitems of a page in indesign and then paste it on a new page in illustrator. Does anyone know how i can have access to two programs at the same time?

I wrote the follow bit which appears to give me the two application i want to use but the contents of these objects is not the same as if you write "app." with for example indesign selected as your target application.

 

function main(){

    var inApp = this.indesign11;

    var illApp = this.illustrator;

}

 

if i write inApp.activeDocument the Toolkit just ignores it.

 

If anyone has any suggestion i'd be happy to hear them.

 

Thanks,

Dane


Repeated Library Item Names

$
0
0

Hi,

 

I need to know if a library item is place twice. My idea is getting library item name and stored as script label. Then adding an event listener to check whether same script label coming twice it will alert the user.

 

var libName = app.libraries.everyItem().assets.everyItem().name;
alert(libName)

 

 

Library item Names ----->Script Label--->Event listener

 

 

Screen Shot 2016-08-24 at 1.26.29 PM.png

 

If i place Blue library item twice it have to alert.

 

Please help me regarding my logic is correct or not.

 

 

Thanks,

Karthi

Text box selection script

$
0
0

Hi

 

New to scripting so need a little help. Trying to select all the text boxes in a document and then move the selected items onto a new layer. Is this possible and if it is can you apply it to a whole document (20 pages or so) and not just the one spread?

 

Many thanks

Doc assignment label does not persist

$
0
0

Problem:

If you set label property of assignment then it does not persist.

NOTE: Setting label property value as assignment.label = "something";

 

Steps:

1. In an InDesign document, create an assignment.

2. Set the label property of the assignment to some value.

3. Update assignment, Save document, and close

4. Reopen the InDesign document and check the label property of the assignment.

It is gone. It does not persist.

 

Strangely, if this ICMA document is opened in InCopy then the label property can be retrieved.

The ICMA xml document also contains the label value that has been set.

 

Why is it not showing up again after reopening InDesign doc.

This issue exists in InDesign CC 2014 and CC 2015 (Win and Mac)

Modify Paragraph Style by Script

$
0
0

Hello!

I don't know if this is the right place for this question but since its related to scripting i will ask here.

 

Is there a way to modify InDesign Paragraph Styles with a Script?

For example i need to set the hyphenation properties of Format1 to specific values without modifying other properties. For Format2 i need to change other properties like the Glph Scaling.

As i need to do this with lots of files i guess the best way to archive this could be a script.

 

Is there anyone who got an idea on how to do this?

 

Thanks in advance

Thomas

Bullets

$
0
0

Hi all,

I am importing xml data into indesign and have to style it with scripting.

Done everything, except for putting in the bullets.. I hope you guys can help me.

 

It's like this, in the xml there are placed characters where things should happen (like an enter or a bullet).
For example:

 

<row>

<product>Different products: {{;}}Dryer{{;}}Car{{;}}Pencil</product>

</row>

 

I used the replace function (replaced {{;}} with 'bullet') and \n for new lines and the outcome is this:

 

Different products:

bullet Dryer

bullet Car

bullet Pencil

 

Now I would think that I only need to replace it with a bullet, but I can't find documentation on bullet scripting. Yeah about how to make your custom bullet and how to do it in indesign without scripting.. Can someone tell me with what I should replace it?

 

Thanks in advance, greetings

Language Id's wont change

$
0
0

Hi!

I'm poking around with the attemp to set the language ID for simplified Chinese by Javascript.

It does work when i use, for example, french but I couldnt find a way to do this for an asian language.

I also tried it with an installation of InDesign CC in chinese.

May anyone have an idea how to get this to work?

 

var _ps = app.documents.firstItem().allParagraphStyles;   

for (var i = 1; i < _ps.length; i++)    {

    _ps[i].composer = 'Adobe Japanese Paragraph Composer';

     _ps[i].appliedLanguage = '$ID/Chinese: Simplified';

 

Thomas

What is the direction of the curve points returned by entirePath()? [See description for details]

$
0
0

The entirePath() of a polygon returned these points. As clarified in a different thread, we have established that the order is leftControlPoint anchorPoint rightControlPoint if there are control points at all. Otherwise it is just the anchor point.

Screen Shot 2015-10-12 at 12.35.48.png

The question I have here is, consider line 3, the control points specified there, do they represent the control points for the Bezier curve between Line 2 point and Line 3 point or a Bezier curve between Line 3 point and Line 4 point?

 

Thanks!


Help me to script for place eps files and excel data in indesign page by page.

$
0
0

Hello,

 

I have en number of eps files by S1, S2, S3, S4............. sequence. and same number's of data's are available in excel file.

 

Required Script:

 

1)      eps S1 placed in page 1 and eps S2 placed in page 2................in indesign.

 

2)     Excel A1 cell  data should place in Page 1 bottom left corner. and A2 cel data should place in Page 2 same location........in  InDesign.

 

Please provide the script for the same action of en number of eps files and excel data.

 

Thank and regards,

Sampath.S

Export PDF - color destination profile

$
0
0

Hi All,

I'm try to create the export pdf with 'Dot Gain 10%' color destination profile, but can't execute with correction output (10% black).

 

I have missed anything in below code?

 

with(app.pdfExportPreferences){

pdfDestinationProfile = "Dot Gain 10%";

}

 

Screen Shot 2016-08-25 at 5.27.03 pm.png

 

 

 

 

Additionally: interactive pdf method also not work based on the below code

 

with ( app.interactivePDFExportPreferences ){
    pdfPageLayout = PageLayoutOptions.SINGLE_PAGE;
    }

 

 

 

 

 

Thanks in advance,

Selva

A DPS has gone blank in pages,how do you resume visual.

$
0
0

after adding effects to a text and art frame in a DPS, that DPS has gone blank in pages.

so not able to function/move etc.....any suggestions.

 

If this is the wrong forum please direct me to the correct one, thanks.....

Interactive pdf export - with single page

$
0
0

Hi,

I'm try to export the interactive pdf with single page setting with below code. But the single page setting not updated. Kindly help on this.

 

 

with ( app.interactivePDFExportPreferences ){
    pdfPageLayout = PageLayoutOptions.SINGLE_PAGE;//single page setting
    }
var pdfFile =File(File(myFolder).fsName + "/"+myFolder.name+"_WEB.pdf");
    app.activeBook.exportFile(ExportFormat.INTERACTIVE_PDF,File(pdfFile));

 

 

 

Thanks,

Selva

INDD CC page separating issues

$
0
0

At my old job, (using CS5) we used this script (http://in-tools.com/article/scripts-blog/separate-pages-script/) to separate pages so that we could design in spreads, but print from single pages and have an inner bleed.

 

When I tried to use this script today with CC, content on the right pages (it seemed random, on a coworker's computer it was content from the masterpage, on my computer it was content from the main pages) was randomly shifted to the right.

 

Has anyone else had this problem? Is there another solution?

 

I know you can do it by hand, but that can potentially take way too long when we're dealing with 200+ page books. And designing with separate pages is also not ideal for us.

 

Sorry if this has been answered elsewhere, I've been searching online for hours and can't find anything.

Viewing all 8771 articles
Browse latest View live


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