Quantcast
Channel: Adobe Community: Message List - InDesign Scripting
Viewing all 37788 articles
Browse latest View live

Re: I want to get all paragraphs of a document

$
0
0

Try this,

 

var objDoc = app.activeDocument;
var par=objDoc.stories.everyItem().paragraphs.everyItem().getElements();
var paraLength=par.length;
$.writeln(paraLength);
var b = 0;
for (j = 0;j<par.length; j++)
{        if(par[j].tables.length >=1)        {                var a = j;                for(var i=0;i<par[j].tables.length;i++)                {                        var _cells = par[j].tables[i].cells;                        for(var k=0;k<_cells.length;k++)                        {                                if(_cells[k].contents != "")                                {                                        $.writeln(a + k)                                        b = k + 1;                                    }                            }                    }            }        $.writeln(b + j);        var text =    par[j].contents;        var endIP = par[j].insertionPoints.firstItem();        var endTF = endIP.parentTextFrames[0];                                var endCitationPage = endTF.parentPage;            var index=endCitationPage.index;        var offset=endCitationPage.documentOffset;    }

 

Regards,

Chinna


Re: find specific hyphenated word

$
0
0

Correct, and that's why I already said it would not 'do' anything after finding. But the script itself does work, and the variable list is filled with the found items; then the script stops. It's up to you to 'do' something with that list.

 

What do you want to do with the found text? Let me remind you again that something like changing the found text will not work the way one would hope! As soon as you change any text, (1) it will most likely invalidate the rest of the 'found' list, because this stores text positions -- and when text re-formats, the earlier found positions may not be valid anymore; and (2) if the text re-formats, words that are in the list as "hyphenated" may reflow and not be hyphenated any longer, as well as words that are not in the list may be hyphenated.

Re: Re: I want to get all paragraphs of a document

$
0
0

Or in a single line and getting a single array as a result:

 

var allStoryParas = curDoc.stories.everyItem().paragraphs.everyItem().getElements().concat(curDoc.stories.everyItem().tables.everyItem().cells.everyItem().paragraphs.everyItem().getElements());

 

(I think Marc or Peter K. suggested this for an extremely similar question.)

 

This will return all regular text, followed by all paragraphs that are in tables. It will not return text inside footnotes or in tables in tables ... or, for that matter, tables inside footnotes (and tables-in-tables-in-footnotes).

 

Apart from using Find to literally find all text, I don't know a reliable BUT fast way to get all text. Then again, to make further useful suggestions I think we need to know what the OP is going to do with 'all text'.

Re: I want to get all paragraphs of a document

Re: I want to get all paragraphs of a document

Re: I want to get all paragraphs of a document

Re: find specific hyphenated word

$
0
0

Jong,

 

Your script could be magic and irreplaceable in cases where some partitions originate big problems.

 

It is possible to change the finding of a word for an expression that finds hyphen-culo?

 

For example, in spanish those words composed by the termination culo (culos) –that is literally ***/*****– are seen very bad when the hyphen shows it and the costume is fix them.

Without your script checking these words could be almost impossible as the termination culo/s is part of tens of thousands of words.

It is interesting this point as I am sure this termination is the only one that creates this alert.


70 copy.jpg

Re: find specific hyphenated word

$
0
0

Hi jongware,

For me is important that the script just find the hyphenated word, but when I start the script doesn't find nothing, although the hyphenated word exist.

 

I have one file in indesign that has 600 pages and I have seen that one abbreviation sometimes hyphenated.

Now, I don't want change all occurrences with "find" that word and "change" in the same word but not hyphenated, because the text in this case could moves without my control.

I would like simply to find that word only when it is hyphenated and change manually with controll if the text moves or not.

 

Thank you in advance


Re: find specific hyphenated word

Re: Re: find specific hyphenated word

$
0
0

Okay, that's clear. Here is a longer script that (1) prompts you for the word (it'll remember the last one used, or use any selected text), (2) search for hyphenated occurrences as before, and (3) if found, highlight the next case. It will search through the entire document and start in the position the text cursor is in. It will start searching in the 'current' story and if it doesn't find the word in there, it will check all other stories (i.e., unconnected textframes).

 

 

if (app.selection.length == 1 && app.selection[0].hasOwnProperty("baseline") && app.selection[0].contents.length > 0)   word = app.selection[0].contents;
if (word == undefined)    word = '';
wordToFind = prompt ("Find what", word);
if (wordToFind)
{    app.findTextPreferences = app.changeTextPreferences = null;    app.findTextPreferences.findWhat = wordToFind;    app.findChangeTextOptions.wholeWord = true;    list = app.activeDocument.findText();    for (i=list.length-1; i>=0; i--)        if (list[i].lines.length < 2)            list.splice(i,1);    // found anything?    if (list.length == 0)        alert ("Cannot find match");    else    {        // anything selected?        if (app.selection.length == 0 || !(app.selection[0].hasOwnProperty("insertionPoints")))        {            // no, pick first one            list[0].select();            app.layoutWindows[0].zoomPercentage = app.layoutWindows[0].zoomPercentage;        } else        {            // locate next after current position            for (i=0; i<list.length; i++)            {                if (list[i].parentStory == app.selection[0].parentStory)                {                    if (list[i].insertionPoints[0].index > app.selection[0].insertionPoints[0].index)                    {                        list[i].select();                        app.layoutWindows[0].zoomPercentage = app.layoutWindows[0].zoomPercentage;                        break;                    }                }            }            if (i==list.length)            {                // not in this story; anywhere else?                for (i=0; i<list.length; i++)                {                    if (list[i].parentStory != app.selection[0].parentStory)                    {                        list[i].select();                        app.layoutWindows[0].zoomPercentage = app.layoutWindows[0].zoomPercentage;                        break;                    }                }                if (i==list.length)                    alert ("Cannot find match");            }        }    }
}

How to resize a rectangle with an image?

$
0
0

Hey,

 

I am working on a MacBook, for me this combination would be "CMD" + "ALT" + "SHIFT" to resize the Rectangle AND the Image placed inside. How is this possible with Indesign script? I'm working with Javascript.

 

Thanks really much in advance!!

 

Best regards

Re: Re: find specific hyphenated word

$
0
0

Camilo, I think you could use a GREP style for that! Create a char style that has only No Break set, and apply it to

 

\wculos?\b

 

-- all words that end with 'culo' or 'culos' (good thing the Dirty Word Nanny Filter only complains about English words ) . The No Break will prevent breaking just before this part, but it will still break on other allowed positions.

Re: find specific hyphenated word

$
0
0

This script is exactly what I needed!

Thank you very much jongware

Re: Re: find specific hyphenated word

$
0
0

Jong,

 

Yes, it works although frequency for this item is very high.

Visual control seems better as long words could be need breaking sometimes.

Thanks.

 

Screen Shot 2014-12-03 at 07.54.32.jpg

Re: find specific hyphenated word

$
0
0

hi camilo umana,

very interesting

thank you


Re: Re: find specific hyphenated word

$
0
0

Hi. I understand the script asks for a word?

  1. if (word == undefined) 
  2.     word = ''
  3. wordToFind = prompt ("Find what", word); 

 

JONG.jpg

Re: Select all content of indesign document for attaching script

$
0
0

Hi

 

I have a problem with this script

 

It does not work with element outside of the page:

 

ELEMENTS OUTSIDE THE PAGE:(does not get all elements..)

 

ELEMENTS_OUTSIDE_DE_PAGE.jpg

 

ELEMENTS_INDIDE_THE_PAGE(working)

ELEMENTS_INSIDE_DE_PAGE.jpg

 

Thanks

Re: find specific hyphenated word

$
0
0

Hmm ... I'm a bit busy now so can't check -- and this would require restarting ID a couple of times. I thought 'undefined' values (i.e., not earlier defined) had the contents "undefined". I think I did not notice because while writing "word' always was defined because of previous runs of the same script. Maybe you can add a try..catch around this?

Re: Select all content of indesign document for attaching script

$
0
0

It is look like I found the solution:

 

myItems = app.activeDocument.pageItems.everyItem().getElements();

for (var k = myItems.length - 1; k >= 0; k--) {

    $.write(myItems[k]);

}

Re: How to resize a rectangle with an image?

$
0
0

I found a workaround. This is not the proper solution, but it works for me. Note: "Width" and "Height" are the geometric bounds of the page substracted. x2-x1 = width, y2-y1 = height.

 

newX = width/100*5;

newY = height/100*5;

newWidth = width/100*95;

newHeight = height/100*95;

 

Then I just added my rectangle like so:

 

myRectangle = rectangles.add({geometricBounds:[newY, newX, newHeight, newWidth]});

myRectangle.place(File(myFile));

myRectangle.graphics[0].fit(FitOptions.proportionally);

myRectangle.graphics[0].fit(FitOptions.centerContent);

Viewing all 37788 articles
Browse latest View live


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