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

Huge assignment files

$
0
0

Hi,

 

I have created assignment by script and move stories to it. But the assignment, after move stories, becomes huge, with more than 200Mb.

The native assignment in indesign, likes make a compression and the script not. How about?


find specific hyphenated word

$
0
0

hello,

is there a way to find all occurrences of one specific word, but only when it is hyphenated?

Thank you in advance

 

p.s I can see the answer(s) only tomorrow

Re: ID CC 2014 plus ExtendScript (Yosemite) slow to the point of not working...

$
0
0

@Uwe, yes it is slow with even a single tab.

Re: find specific hyphenated word

$
0
0

Yes -- by making a list of all occurrences of that word (which is a built-in function), and then removing the ones that are not hyphenated (which is not, but pretty easy).

 

Note that finding multiple words is a pretty useless operation. Usually you are interested in locating the first (or next) occurrence, or you want to find them then and then do something. A potential problem, however, is that 'doing something' to an hyphenated word may change the running text, and so words that were earlier reported as 'not hyphenated' could be broken, and the reverse.

 

The following script will find all hyphenated occurrences of 'nonfunctional' ... and then do nothing with that information.

 

app.findTextPreferences = app.changeTextPreferences = null;
app.findTextPreferences.findWhat = "nonfunctional";
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);

Re: find specific hyphenated word

$
0
0

Jongware,

 

Very interesting script. I am very sure it will have many possibilities.

 

IT is possible to use a list of words instead of only one?

 

Thanks for this piece.

Re: How to make frames all the same size?

$
0
0

Does anybody understand what I mean?

Re: find specific hyphenated word

$
0
0

Put it in a loop. But its usefulness depends heavily on what you do with the words you find. Finding is okay, then having something automatically done not.

Hyphenated word in CS6

$
0
0

Hi,

 

  If a word contains more than 1 lines, it is hyphenated. But, for the below occurrences is not hyphenated but its also reporting as hyphenated when using the line concept.

 

Screen shot 2014-12-02 at 11.17.18 AM.png

 

Screen shot 2014-12-02 at 11.17.04 AM.png

 

1. if url contains more than 1 line

2. word contains dot (.) . if it contains more than 1 line

 

But actually its not hyphenated

 

Can anyone help me.

 

Thanks in advance

Sudha K


Re: Hyphenated word in CS6

$
0
0

Hi Sudha,

 

Try this.

 

var sel = app.selection[0],    paras = sel.parentTextFrames[0].paragraphs.everyItem().getElements(),    str = "";
for(var i =0;i<paras.length;i++)
{    var _lines = paras[i].lines.everyItem().getElements();    if(_lines.length > 1)    {        for(var j =0;j<_lines.length;j++)        {             if(_lines[j].words[-1].lines.length >1 && _lines[j].words[-1].contents.indexOf(".") == -1)             {                    str +=_lines[j].words[-1].contents + "\r";                 }            }        }    }
alert(str);

 

Regards,

Chinna

Re: Hyphenated word in CS6

$
0
0

Hi,

 

  Thanks for ur reply...

 

  If i use the above code, both url and the word contains dot (".") is skipped.  But for below case, the word software is hyphenated but its contains dot so its skipped. But i want to report this word.

 

Also I need to get the hyphenated word from tables and footnotes.

 

 

Screen shot 2014-12-03 at 10.16.40 AM.png

 

- Sudha K

Re: Re: Hyphenated word in CS6

$
0
0

Hi Sudha,

 

Try this,

 

var doc = app.activeDocument;
var _stories = doc.stories.everyItem().getElements();
var str = "";
for(var k =0;k<_stories.length;k++)
{    var paras = _stories[k].paragraphs.everyItem().getElements(),        fn = _stories[k].footnotes.everyItem().getElements(),        _tables = _stories[k].tables.everyItem().getElements();    findhyphenation(paras)    for(var l=0;l<fn.length;l++)    {        var paras1 = fn[l].paragraphs.everyItem().getElements();        findhyphenation(paras1)        }    for(var m=0;m<_tables.length;m++)    {        var _cells = _tables[m].cells.everyItem().getElements();        for(var n=0;n<_cells.length;n++)        {            var paras2 = _cells[n].paragraphs.everyItem().getElements();            findhyphenation(paras2)            }        }    }
function findhyphenation(paras)
{    for(var i =0;i<paras.length;i++)     {         var _lines = paras[i].lines.everyItem().getElements();         if(_lines.length > 1)         {             for(var j =0;j<_lines.length;j++)             {                 if(_lines[j].words[-1].lines.length >1 && _lines[j].words[-1].contents.indexOf(".") == -1&&_lines[j].words[-1].contents.indexOf(".") != _lines[j].words[-1].characters.length-1)                  {                         str +=_lines[j].words[-1].contents + "\r";                      }                 }             }         }    }
alert(str);

 

Regards,

Chinna

Re: Hyphenated word in CS6

$
0
0

Hi Chinna,

 

  Thank you....

 

  Its working for tables and footnote.  But for the above attachment  (software.) is skipped from report. Its hyphenated word so it should be reported.

 

  Our condition is word's lines is greater than 1 is hyphenated. when using condition ".",  If a word contains 2 lines using any other special character it will be reported as hyphenated.  But it should not report know.Screen shot 2014-12-03 at 11.32.38 AM.png(Samples created for testing purpose)

 

  In the above attachment We should reported only consoleWriteLine(     (2nd one).  1st and 3rd one is not hyphenated but it contains 2 lines.

 

- Sudha K

Re: Hyphenated word in CS6

$
0
0

Hi Chinna,

 

  If i changed the condition like this, Its working for the word "software."

 

function findhyphenation(paras) 

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

    {   

        var _lines = paras[i].lines.everyItem().getElements();   

        if(_lines.length > 1)   

        {   

            for(var j =0;j<_lines.length;j++)   

            {                  

                 if(_lines[j].words[-1].lines.length >1 &&(( _lines[j].words[-1].contents.indexOf(".") == -1) || (_lines[j].words[-1].contents.indexOf(".") == _lines[j].words[-1].characters.length-1)))

                 {   

                        str +=_lines[j].words[-1].contents + "\r";   

                     }   

                }   

            }   

        } 

    } 

 

  But my doubt is, will it work for all cases (If contain any other special character) when the non-hyphenated word with two lines...

 

- Sudha K

Re: Re: Hyphenated word in CS6

$
0
0

Hi Sudha,

 

Try now,

 

var doc = app.activeDocument,    _stories = doc.stories.everyItem().getElements(),    str = ""; 
for(var k =0;k<_stories.length;k++) 
{     var paras = _stories[k].paragraphs.everyItem().getElements(),         fn = _stories[k].footnotes.everyItem().getElements(),         _tables = _stories[k].tables.everyItem().getElements();     findhyphenation(paras)     for(var l=0;l<fn.length;l++)     {         var paras1 = fn[l].paragraphs.everyItem().getElements();         findhyphenation(paras1)         }     for(var m=0;m<_tables.length;m++)     {         var _cells = _tables[m].cells.everyItem().getElements();         for(var n=0;n<_cells.length;n++)         {             var paras2 = _cells[n].paragraphs.everyItem().getElements();             findhyphenation(paras2)             }         }     } 
function findhyphenation(paras) 
{     for(var i =0;i<paras.length;i++)       {           var _lines = paras[i].lines.everyItem().getElements();           if(_lines.length > 1)           {               for(var j =0;j<_lines.length;j++)               {                  if(_lines[j].words[-1].lines.length >1)                    {                       var _char = _lines[j].words[-1].characters,                        bool = true;                    for(var o=0;o<_char.length-1;o++)                    {                        if(_char[o].contents == ".")                        {                            bool = false;                            break;                            }                        }                    if(bool == true)                    {                        str +=_lines[j].words[-1].contents + "\r";                           }                     }                   }               }           }     } 
alert(str); 

 

Regards,

Chinna

Re: Bullet and Number - Tab Position

$
0
0

Jarek,

 

if you set your values e.g. to Left Indent: 20 mm, First Line Indent 20 mm, Tab Position 50,8 mm, you will get autoamtically a tab on the ruler in the tabs bar. However: If you delete the tab in the ruler, the value in the bullets and numbering dialog is still alive and honored.

 

If you try to control this value, there is no tabStops[0]  >> therefore no possibility to control the position ?! Sudha is this your problem?


Re: Hyphenated word in CS6

$
0
0

Hi Chinna,

 

   In the above code, If a word contains 2 lines and last character is "." and we skipped that dot, treated it as a hyphenated word.  Where as, a word contains 2 lines and a word contains dot inbetween the word is treated as non-hyphenated word right???

 

 

Screen shot 2014-12-03 at 11.32.38 AM.png

 

 

In this image, Console/WriteLin( is reported as hyphenated word.  But its not hyphenated.

 

If we use this condition, it will work wrongly when any other character breaks word... Its my ques....

 

- Sudha K

Re: Bullet and Number - Tab Position

$
0
0

Hi Kai,

 

Agree, thats how semi-automated feature works - something is going on in background but don't touch it cause "semi" starts to work against you. Microsoft Office has much more "successes" here.

 

Jarek

Re: find specific hyphenated word

$
0
0

hi jongware,

thanks a lot.

However I do something wrong: I copied and pasted youre script. I changed the word "nonfunctional" with one other word (hyphenated) and when I start the script don't happened nothing.

Where I wrong?

Thanks in advance

I want to get all paragraphs of a document

$
0
0

Hi ,

 

I want to get all paragraphs of a document(where document has table and cell and it contains some para as well)

 

Here is my script.

 

var objDoc = app.activeDocument;

var objDocName= objDoc.fullName.toString();

 

var par=objDoc.stories.everyItem().paragraphs.everyItem().getElements();

var paraLength=par.length;

$.writeln(paraLength);

                              for (j = 0; j < par.length; j++)

                              {

                               

                               

                                  $.writeln(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;

//~                                     $.writeln(text + "  Page : " + endCitationPage.name);

//~                                     $.writeln(index);

                    

                                    }

                                   

 

 

This script does not give me the text which is a part of  Cells.

 

 

Is there a property where we can get all the para from doc like :

 

 

var par=objDoc.paragraphs.everyItem().getElements();

Re: I want to get all paragraphs of a document

$
0
0

Hi,

 

var curDoc = app.activeDocument;
// all paras in stories
var allStoryParas = curDoc.stories.everyItem().paragraphs.everyItem().getElements();
// all paras in tables
var allTableParas = curDoc.stories.everyItem().tables.everyItem().cells.everyItem().paragraphs.everyItem().getElements();

 

Notice, that you get also paras that hold the tables!

 

– Kai

Viewing all 37788 articles
Browse latest View live


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