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

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


How to automate an InDesign script to run nightly?

$
0
0

Hello, I'm interested in running an InDesign script automatically every night.

 

So, I need to find a solution that will:

  • Open InDesign
  • Run a specified script
  • Close InDesign when the script is done.

 

Any ideas?

Script for change font InDesign CS4

$
0
0

I'm working on a new project and material came from PC/InDesign. Therefore fonts used on their platform are Type 1. I use OTF on MAC, and changing all fonts manually in 150 pages is insane

 

Tried several scripts and none of them help. There is one that change missing fonts, but this is not best solution since i need some families to swap. And in this script still stay some of the main family replacements intouched, so there is still missing font :/.

 

I also try FindChangeByList but mine line didnt work out

 

text{findWhat:"Interstate (T1)"}{changeTo:"Interstate"}{include footnotes:true, include master pages:true, include hidden layers:true, whole word:false}

Anyone have solution for this? Or script for change font when i open up new page in indesign?
Janko Samo

How can I get a total page count of a PDF before placing every page in the PDF?

$
0
0
Before the [long] spiel, I'm using javascript in InDesign CS3.

I'd like to create a script that places a multiPage PDF in any number of different impositions. (saddle stitch, 4up signatures, 16up signatures etc.)

I've easily created a script that iterates through a PDF and places it into a new document as (4,1|2,3), (8,5|6,7) etc, which works for printing in duplex, folding each page in half, and gluing the resulting spines to make a simple thick book (for PDFs with more than, say, 64 pages).

However, the next step is to re-write the script to create a saddle stitch document (16,1|2,15), (14,3|4,13) ... (10,7|8,9). For this I need to know how many pages there are in the PDF before I start placing the PDF pages, and then making the new document [int((PDFpages+3)/4)] pages long.

Is there a simple way to get the count of PDFpages without going through a loop and placing the next page from the PDF until the placed page number equals the first page number?

This way seems wasteful:

var totPDFPages = 1;
app.pdfPlacePreferences.pageNumber = totPDFPages;
myPDFPage = sheetFront.place(File(srcPDF), [0,0])[0];
var pdfFirstPage = myPDFPage.pdfAttributes.pageNumber;
while (doneCounting == false) {
totPDFPages += 1;app.pdfPlacePreferences.pageNumber = totPDFPages;
myPDFPage = sheetFront.place(File(srcPDF), [0,0])[0];
if (myPDFPage.pdfAttributes.pageNumber == pdfFirstPage) {
totPDFPages -=1;
doneCounting = true;
alert("PDF has " + totPDFPages + " pages!");exit();
};
myPDFPage.remove();
};

NB. Javascript above *hasn't* been run, but should look similar once debugged.

The only thing I've though of to relieve the sheer duplication of placing the PDF twice (once for the count, and once for the imposition), is to create an array of impoPages[counter]=myPDFPage, and then shuffle the pages referenced by the array to the correct sheet and position.

It'd be much easier to be able to assign pageCount = File(srcPDF).pageCount !!!

Thanks for any help/tips or even a simple "What are you smoking, man!?"

Cheers,
Jezz

chronological order number needs in index numbers to be changed as ndash

$
0
0
Hi all


I have a task to complete the below requirement for Index part in a book. Please help me.


I have sequence of numbers like this,


Index1, 26, 35, 36, 37, 47
Index2, 65, 78, 79, 89, 90


I need to change like this

 

Index1, 26, 35−37, 47
Index2, 65, 78−79, 89−90


i.e., the number which are in sequence order (chronological order) needs to be changed as ndash.

 

Sajeev

 

Open multiple .indd files

$
0
0

Hello,

usually when I have to ask for opening a single .indd file I use something like this:

 

fileToOpen = File.openDialog("Open a document");

myDocument = app.open(File(fileToOpen.fullName));

 

But what if I have to open multiple files at once (eg. selecting them from the Desktop)?

 

I read from the Indesign object model that the "open" function of the "application" object can accept an array of files.. am I right?

 

Thanks in advance

[AS or JS] How Can I Access/Gather Font Informations?

$
0
0

Hello all,

 

is it possible to gather font information that is embedded in the font file of a specific font via scripting? E.g. Kerning pairs with values, widths, side bearings of certain characters etc.?

 

Thanks

Tobias

[JS][CS4/CS5] Images dropping off in scripted pdf export

$
0
0

I've encounted a bug that I wonder if someone could try to replicate or suggest a workaround of some sort for.

 

Some background: we often need to batch-export a number of versioned InDesign files to pdf. These files will often share a lot of content, particularly placed images. We've used Peter Kahrel's export script for this purpose, as well as a number of scripts of my own. The specifics of the script don't seem to be important. I've seen the problem in both CS4 and CS5 on the Mac.

 

The problem: Placed Illustrator files (and pdfs) drop off of exported pdfs, without any kind of error being raised, after a user tries to interact with InDesign while it's tied up during a script which opens and exports one file after another. Once an image drops off, it will be missing from every subsequently exported pdf until the script completes. The pdfs are valid—they open and display just fine—they just don't contain all the images they're supposed to. Placed raster images are not affected.

 

If anyone cares to try to replicate this for me, the script I used to trigger it was:

 

var f = File("/path/to/InDesign/file.indd"),    d = Folder("/path/to/export/directory"),    e = 0,    i = 1000,    doc, pdf;while(e++,i--){    doc = app.open(f);    pdf = File(d.fullName + "/" + f.displayName.replace(/\.indd$/,"") + e + ".pdf");    doc.exportFile(ExportFormat.PDF_TYPE,pdf,false,app.pdfExportPresets.firstItem());    doc.close(SaveOptions.NO);}

 

The InDesign file can simply be a single page with any (as far as I know) placed Illustrator file or pdf. I used an .ai file with one black rectangle in the middle of the page.

 

After getting the export script going in the ESTK, I Command-Tab over to InDesign. As soon as I try to click on any UI element (which will get me a spinning beach ball), the placed vector image drops off of the exported pdf and stays dropped off until I stop the script.

 

While the solution seems simple—don't mess with InDesign while it's batch exporting pdfs—it's easy to forget that it's tied up, and the consequences of an image silently dropping off of an exported pdf could be quite dire.

 

Thanks in advance.

 

Jeff


How to capture image name from the file path of the links in indesign

$
0
0

Hi,

 

I am capturing the complete path of links used in indesign through javascript. However, I need to capture only the image name from the file path.

 

For example:

 

Through script I am capturing the path of this image as:

 

/Users/user-name/Desktop/image.ps

 

However, I need to capture from this path only the image name i.e. I want only image.ps

 

I tried doing grep, replace but not too sure how to carry forward.

 

Any help will be appreciated.

 

Here is my script through which I am getting the link path.

 

var myDoc = app.activeDocument;

var myLinks = myDoc.links;

 

if (myLinks.length == 0) {

     ErrorExit("This document doesn't contain any links.", true);

}

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

var currentLink = myLinks[i];

var LinkPath = currentLink.filePath;

alert (LinkPath);

}

}

 

Regards,

 

Abhi

tables and page guidelines

$
0
0
Is it possible to create a script to import tables and make the columns lign up with the page guides?

Zoom to full window size

$
0
0

I use the following script to reset my documents to the first page and zoom to full window size (like Ctrl+0):

 

with (app.activeDocument.layoutWindows[0]) {

    activePage = app.activeDocument.pages[0];

    screenMode = ScreenModeOptions.previewToPage;

    zoom(ZoomOptions.fitPage);

    }

 

I am working on a 15" laptop with a 24" screen connected to it, and the 24" screen is set to be the only display (in Windows 7).

 

When I run this script directly in InDesign CS6 from the Scripts panel, it works fine. When I run the script using DoScript in a VB.NET program, the resulting document is scaled as though it were displayed on the 15" screen of my laptop. How can I make InDesign scale based on the 24" screen and not the 15" screen?

exporting XML with xmlExportPreferences

$
0
0

Hi everyone,

 

I have write a javacsript to export xml file from InDesign. For the pretty ptrint I use allowTansform and transformFilename with an xslt script to indent my exported files. But, I have find out an unexpexted behaviour of my script at the export time. My xml files aren't indented.

If I do first an export applying my xslt script by the user interface, the result is well done. Then after i use my javascript which it do nothing, It works well now. I don't see where is my misunderstood ?

 

i hope that I clearly makes me understand.

 

see my script :

 

function mySnippet()

{

   

    with(app.xmlExportPreferences)

    {

        allowTransform = false;

        // Préférences d'exportation au format XML

        charactersReferences = true;

        copyOptimizedImages = true;

        exportFromSelected = true;

        xmlFileEncoding = XMLFileEncoding.UTF8;

        transformFilename= File ('../prettyPrintXML.xsl');

       

        // Activation des variables locales

        var xmlElement;

        var myDocument = app.activeDocument;

        var xmlRoot = myDocument.xmlElements[0];

        myTagElement = xmlRoot.evaluateXPathExpression('//doc');

        xmlElements = xmlRoot.evaluateXPathExpression('//doc//article//texte');

        myAuthorRootTag = xmlRoot.evaluateXPathExpression('//composant-signature');

        myAuthorTag = myAuthorRootTag[0];

        myAuth = myAuthorTag.xmlContent.contents;

        myAuth1 = myAuth.split(" ");

        myAuthorFirstName = myAuth1 [1];

        myAuthorLastName = myAuth1 [2];

        myAuthor = myAuthorFirstName + ' ' + myAuthorLastName;

        myIssueRootTag = xmlRoot.evaluateXPathExpression('//issuedate');

        myIssueTag = myIssueRootTag[0];

        myIssueDate = myIssueTag.xmlContent.contents;

       

        alert (myAuthorFirstName + ' ' + myAuthorLastName);

        alert (myIssueDate);

       

        for (docPos = 0; docPos < myTagElement.length; docPos++)

        {

 

           

            xmlElement = myTagElement[docPos];

            myArticle = docPos;

            myDocPos = xmlElements[docPos].xmlContent.insertionPoints[0].parentTextFrames[0] ;

            myPageName = + myDocPos.parentPage.name;

       

            // Génération du fichier ".cont.xml"

            myCont = myWorkFolder + '/' + myExportNameFile + '_' + myPageName.threeDigit() + '_' + myArticle.threeDigit() + '.cont.xml';

            myFileCont = new File (myCont);

            xmlElement.exportFile(ExportFormat.xml, myFileCont, false);

 

 

            //Génération du fichier ".sys.xml"

            mySys = myWorkFolder + '/' + myExportNameFile + '_' + myPageName.threeDigit() + '_' + myArticle.threeDigit() + '.sys.xml'

            myFileSys = new File (mySys);

            var myXMLElement = myDocument.xmlElements.item(0).xmlElements.item(-2);

            myXMLElement.exportFile(ExportFormat.xml, myFileSys, false);

           

            //Génération du fichier ".meta.xml"

            myMeta = myWorkFolder + '/' + myExportNameFile + '_' + myPageName.threeDigit() + '_'+ myArticle.threeDigit() + '.meta.xml';

            myFileMeta = new File (myMeta);

            var myXMLElement = myDocument.xmlElements.item(0).xmlElements.item(-1);

            myXMLElement.exportFile(ExportFormat.xml, myFileMeta, false);

                }

            }

    }

 

thanks

 

Américo

Script to create heat map in Indesign 5.0 PC?

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!

select text frame from XML structure

$
0
0

I am attempting to move specific text frames created though an XML import to the bottom of the page (bottom pasteboard) as Folio and slug info.

 

I can select the text associated with an XML element "VTag" but not the Text frame. Any help would be appreciated.

 

Thanks

 

 

property myHoHoV : {}
on myLoopLoop(myElement)
   
    tell application "Adobe InDesign CS4"
        tell active document
            set moreElement to every XML element of myElement
            repeat with x from 1 to (count of moreElement)
                set em1 to item x of moreElement
                select em1
                if (name of markup tag of em1 is "VTag1") then
                    set em2 to em1
                    set properties of view preferences to {horizontal measurement units:inches, vertical measurement units:inches, ruler origin:page origin}
                    set transform reference point of layout window 1 to top left anchor
                    select text of em2
                    tell application "Adobe InDesign CS4"
                        move text of em2 to {5, 5}
                    end tell
                end if
                tell me to myLoopLoop(item x of moreElement)
            end repeat
        end tell
    end tell
end myLoopLoop


How to call a variable file path in javascript

$
0
0

Hi,

 

My objective is to capture a file path on mac and windows. However, this file path gets changed with various users.

 

For example the path is:

 

c:\user\username\AppData\Local\Temp\myfolder------> this is for windows machine

 

/users/username/Library/Application Support/tempfolder/Temporary Files/-------> this is for mac machine

 

As you can see, the path will be same for all the machines. Only the difference will be in searching the user and username at the start of file path. Rest folders will remain same on all the machines.

 

Is there any grep pattern through which I can call this complete path in a variable for all the users.

 

Any help will be appreciated.

 

Regards,

 

Abhi

Creating a text with a java script on fixed position

$
0
0

Hello i want to know how to create a text with a java script on fixed position

 

thanx

How to open selected files from a listbox

$
0
0

I am trying to open files from selected items in a listbox, but am having some problems.

 

Here is my code:

var firstLibrary = "C:\\Program Files (x86)\\Adobe\\test\\Library1.indl";

var secondLibrary = "C:\\Program Files (x86)\\Adobe\\test\\Library2.indl";

 

var libraryList = [firstLibrary, secondLibrary]; // array filled with file url's

 

var w = new Window ("dialog");

var myList = w.add ("listbox", undefined, libraryList, {multiselect: true}); // list populated with libraryList array

var print = w.add ("button", undefined, "Print selected items");

 

myList.selection = 0; // default selection of first index

 

print.onClick = function () // when button is clicked, should print selections to console, open files and then close the window

    {

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

        $.writeln (myList.selection[i].text); // <-- correctly prints the selected items to the console

        //app.open(File(myList.selection[i].text)); // <-- this line I would assume allows me to open the files because the text is a file url,

                                                                         // however, uncommenting it breaks the code

    }

    w.close();

}

 

w.show ();

Font Replacement

$
0
0

I hope there is an easy solution to this problem.

 

I've got some 200 InDesign documents that are "missing" fonts.

 

When I iterate over document.fonts, I look into the status attribute, and if I find a font to be "NOT AVAILABLE", I would like to replace it with another.

 

Thusfar, I have been unable to find a simplistic means by which to accomplish this.

 

Pointers / advice?

 

Thanks.

how to get font properties like line height, ascend, descend, ideographic top etc..?

$
0
0

I would like to know if we can access font properties like line-height, ascend, descend etc. through scripting.

 

I have been trying to get this now by applying a font to sample text as mentioned below.

 

var fontLists = app.fonts.everyItem().getElements();

var applicationDocument = app.documents.add();

var appPage = applicationDocument.pages.item(0);

 

var appTextFrame = appPage.textFrames.add();

 

appTextFrame.contents = "sample";

 

var appParagraphText = appTextFrame.paragraphs[0];

 

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

     var xfont = app.fonts[i];

    //alert('font name '+xfont.name);

    appParagraphText.appliedFont = app.fonts.item(xfont.name);

    var line = appParagraphText.lines[0];

    var myLineheight = line.ascent + line.descent

    alert('font name '+xfont.name +' \n baselineShift -'+appParagraphText.baselineShift+' \n fontStyle - '+appParagraphText.fontStyle

    +' \n fontAscent - ' + appParagraphText.ascent+' \n descent - '+appParagraphText.descent) + ' \n line height '+myLineheight;

}  

 

Is there any other better way to get this?

Viewing all 15932 articles
Browse latest View live


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