Script to determine the number of lines of text in a paragraph?

I'm revisiting a problem I posted here last summer, thanks to all those who have offered help, but I could not sort it out.

http://forums.Adobe.com/thread/455526?TSTART=0

What I'm after is a 'search' function to insert in a FindChangeByList.

Jongware suggested the following - but when inserted in my list, I can't seem to do anything - it does not take a Javascript error.

app.findTextPreferences = NothingEnum.nothing;
app.findTextPreferences.appliedParagraphStyle = "Callout_3";
foundItems = app.activeDocument.findText();
for (var i=foundItems.length-1; i>=0; i--)
{
  if (foundItems[i].paragraphs[0].lines == 2)
    foundItems[i].paragraphs[0].appliedParagraphStyle = "Callout_2";
  if (foundItems[i].paragraphs[0].lines == 1)
    foundItems[i].paragraphs[0].appliedParagraphStyle = "Callout_1";
}

I regularly get a 'word' document on which I run a "FindChangeByList" that cleans and formats the text with a number of GREP/text searches.

One of the lines of research converts a particluar to the text string to a paragraph style "Callout_3" (the most common legends).

This style applies to paragraph NET, above and below the line, to create a block/strip of color that says text is reveresed.

The problem I have, is that the style (due to the rules of paragraph), works well if the paragraph has x 3 lines of text.

I have updated styles in place for any eventuality - Callout_1 (for the single line of text), Callout_2 (for x 2 lines of text) etc.

I'm looking for is a script that can count the number of lines in the paragraph (once the "Callout_3" style has been applied) and then change the style accordingly the number of lines in each paragraph/legend.

Any other thoughts?

Steve

-your script can be incorporated into a FindChangeByList .txt file?

No, he needs to access real paragraph finds it to count the number of line of this paragraph. FindChangeByList Find/change regular strings together, and you can not search for a certain number of lines.

-what it takes to go to the 'findStyle ('Callout_1');"reference within a"group of paragraph style"called"legends "?

... Nothing. Because the style can be within a group, I wrote this little function. The findStyle performs a loop on * all * paragraph styles in the document, the root and in each group and returns the first style with the name that you provide in the function call (tested!).

So if there is a 'Callout_1' style anywhere, it should find it... Are you sure you put the name at the top of the script? I've seen in a post later that it is actually called "Callout_1line".

Tags: InDesign

Similar Questions

  • Basic conditional script based on the number of lines in a text layer?

    Just received help here to write a conditional script by using the font size of a text layer. Thank you all for this.

    The next hurdle is a conditional script using the number of lines in a text layer in the differential. Far as I can tell it not the layer details which specify the number of lines. Just '\r' for a return in the idTxt descriptor. Nothing seems to stand for a soft return as far as I can tell. I'll probably have to be able to count the lines with soft and hard returns.

    Any thoughts?

    I was playing around with this a bit and here is a small script to determine the number of rows. This is based on the self in the head, that I calculated to environ.108 times the size of the font.

    #target photoshop
    app.preferences.rulerUnits = Units.POINTS;
    var doc = activeDocument
    var tL = doc.activeLayer
    var h = tL.bounds[3]-tL.bounds[1]
    var per = ((h/5)-(tL.textItem.size))/tL.textItem.size
    var num = h/(tL.textItem.size *1.108)
    
    alert(Math.round( num))
    
  • Essbase calc script to determine the number of occurrence

    Hello

    is it possible within a calc script to determine the number of occurrence of a value in the account dimension?

    I have an account called ranks which can contain any value between 1 and 10.  I would like to know how many times each value is repeated for a specific cost center.  It's in a database of planning BSO.

    Thanks in advance for your contributions...

    CL

    This isn't the typical calculation you would do in an OLAP architecture, but yes it is certainly possible.

    you will need to create 10 accounts such as occurrence_of_1, occurrence_of_2 etc.

    Then you increment them according to the value of the 5th year.

    Don't forget to put in your calculation!

  • How to control the number of lines of text below the image in the slideshow module?

    Lightroom 3.3

    How to control the number of lines of text below the image in the slideshow module?  I have an image with 36 words in the caption field which exports like two lines GOOD.!  I have another image with 57 words in the field of legend who runs the page and shows only a VERY BAD line.  With 57 words I can't do the single-line text box small enough to keep the text does not spread out of the page.

    Ideas?

    On the Mac platform and I expect similar under Windows, just hit enter or return key will not help. Instead, you will have to hit the keys Ctrl + Enter or Ctrl + return. This forces a new line. Windows may use a different modifier key. The screenshot below shows that it is possible. Unfortunately, you need to add the text via the caption or Description field in the library module.

  • Can I limit the number of lines of text entered into a TextArea?

    Hello

    I use Flex Builder 2 to create an application that allows users to enter text in different TextAreas and eventually create a PDF file with their different text. My only problem is that I can't limit the number of lines of text used in each text box. I can limit characters by using maxChar, but this does not take into account a user entering multiple presses "return" - this does not affect the character limit, but can result in the final PDF layout (spitting the text on page 2).

    Is there a way to keep track and limit the number of lines of text in a text box (in Flex 2)?

    (Ideally I won't disable the ability for users to use the 'back' button to create several paragraphs)

    Any help would be appreciated.

    Thank you

    Ben.

    Hello

    Try this code.

    import

     

    flash.events.KeyboardEvent;

    Import flash.events.TextEvent;

    Import mx.controls.TextArea;

    public class LimitedLinesTextArea extends TextArea {}

    private var numLinesAllowed:int = 0;

    private var moreCharsAllowed:Boolean = true;

    public function LimitedLinesTextArea():void

    {

    this.addEventListener (flash.events.TextEvent.TEXT_INPUT, textInputHandler);

    }

    override protected function keyDownHandler(event:KeyboardEvent):void

    {

    if (this. textField.numLines > numLinesAllowed)

    moreCharsAllowed =

    fake;

    on the other

    moreCharsAllowed =

    true;

    Super.keyDownHandler (event);

    }

    private function textInputHandler(event:TextEvent):void

    {

    If

    (! moreCharsAllowed)

    Event.preventDefault ();

    }

    public function the value numberofLines(value:int):void

    {

    numLinesAllowed = value;

    }

    }

  • How to use NIDAQmx to determine the number of lines correlated DIO?

    How can I used NIDAQmx to determine the number of correlated DIO lines that supports a device?  For example, the NI6225 supports 8 correlated digital of/s lines while the NI6229 supports 16 correlated digital of/s lines.  How can I used NIDAQmx to determine the NI6225 supports only 8 lines while the NI6229 supports 16 lines?

    I moved this question from a previous thread.

    Thank you

    Ian

    Here is a code snippet that implements the regular expression detection:

  • count the number of lines of text in the text edit field

    Hello

    I have an edit box of search report international for comments from multiline, requirement is by default text up to 7 lines should be present (which I did), a vertical scroll bar should appear with the text of more than 7 line (done), if the text if more than 7 lines and gives user print the form and then on all the text written in the RDI change fiedl should print. (STUCK WITH IT).

    Can someone help me solve this issue a high priority.

    What I seek is to expand the print command is given and recollasped he cback tonormal size, but whne I enter text with empty spaces between it is not done, I am able to do this if user eneter continues text

    Please it is matter of very high priority, help me.

    Thanks in advance

    POOJA

    The form must be dynamic, the main subform should be set on flowed and the field must be set to develop in the direction y (from the available Panel). The field must be a line of course.

    There is a good example of this is the samples provided with the designer. Take a look at the comments field in order of purchase of samples found in the Designer installation directory at this location:

    EN\Samples\Forms\Purchase Order\Dynamic Interactive\Form

    Paul

  • Move and organize files based on the number of lines

    Hello

    I have a directory containing files nearly 1,500, some of which are composed of 12 lines, some of which are composed of 4 lines, which are all .phy (PHYLIP) files, which can be viewed in Notepad/wordpad as text files.

    I need to execute a script which will determine the number of lines in each file and move them to the corresponding folder. The file size will not work for sorting, I've tried.

    that is, all files with 4 lines in one folder, all the files with 12 lines in another folder, any files left (so I can be sure that everything has been inspected) in the main directory.

    Can anyone help?

    Thank you

    This issue is beyond the scope of this site and must be placed on Technet or MSDN

    http://social.technet.Microsoft.com/forums/en-us/home

    http://social.msdn.Microsoft.com/forums/en-us/home

  • Script to increase/decrease the number of line of initials?

    There is a script to increase/decrease the number of drop caps text paragraph line?

    I use Indesign CS-5 for windows xp.

    Thank you in advance!

    Hi Obi - wan Kenobi,

    Maybe the code below will meet your requirement.

    var incrementFlag = false;
    var decrementFlag = false;
    var w = new Window ("dialog", "Drop Cap");
    var increment_button = w.add ("button", undefined, "Increment drop cap by one");
    var decrement_button = w.add ("button", undefined, "Decrement drop cap by one");
    increment_button.onClick = function(){incrementFlag = true; w.close();}
    decrement_button.onClick = function(){decrementFlag = true; w.close();}
    w.show ();
    if(incrementFlag == true)
    {
        app.selection[0].dropCapLines = app.selection[0].dropCapLines + 1;
    }
    else if(decrementFlag == true)
    {
        app.selection[0].dropCapLines = app.selection[0].dropCapLines - 1;
    }
    

    Vandy

  • determine the number of pages of a pdf prior to any operation on it

    Any of you know how to determine the number of pages in the pdf file (selected with the Open for example)?

    Somehow, I can't understand how to do that any way short of actually opening/pixelation all pages without prior knowledge of the actual number.

    I would like to use this information to determine the number of items to a contact-sheet-like procedure beforehand.

    MultiPageImporter2.0.jsx, which is an Indesign Script by Scott Zanelli, obviously the fact, but so far I have failed to properly use its functions.

    Anyway, have a good weekend

    pfaffenbichler

    OK, now it works...

    Install x script changing the CSx version

    Then run this script by changing the location of pdf and the version of CS... (NB: does not work with CS2.) CS, CS3, and CS4 should be ok)

    /////////////////////////////////////////////////////////////

    var pdffile = file ("~/Desktop/56 pages.pdf") .fsName;

    ////////////////////////////////////////////////////////////

    var file = new File ("/ Applications/Adobe Photoshop CS3/Presets/Scripts/macexec.app/contents/macexec");

    var pdfcnt = File ("~/pdfcnt");

    If (pdfcnt. Exists) pdfcnt.remove ();

    {if (file. Exists)}

    leader. Open ("e");

    leader. Encoding = "BINARY";

    leader. Write ("/ usr/bin/LDM - name kMDItemNumberOfPages");

    leader. Write ("\""+pdffile+"\"|/usr/bin/grep o [0-9]------+ $ > pdfcnt \n");

    The following line closes all Windows Terminal.

    file.writeln ("/ usr/bin/osascript - e ' tell \"Terminal\ request "to quit" ");

    leader. Close();

    }

    leader. Execute();

    var test = false;

    {while (test)}

    if test (pdfcnt.exist) = true;

    $.sleep (50);

    }

    for (var t = 0; t)<>

    If (pdfcnt. Length > 0) break;

    $.sleep (50);

    }

    pdfcnt. Open ("r");

    var number = parseInt (pdfcnt.readln ());

    pdfcnt. Close();

    Alert ("number of pages in" pdffile + "=" + count);

  • How can I fix the height of the datagrid advance according to the number of lines.

    Hello

    I have a datagrid move with a few lines in it. But the height of the grid is higher than the number of lines... How can I fix the height number of lines. That is, if the number of lines is 5 then the height shall be determined in accordance with that.

    Can someone please tell me a solution for this.

    Thank you

    Suma.

    Set rowCount is equal to the length of the dataProvider:

    
    
      
        
      
      
        
          
          
          
          
            
            
          
        
      
    
    
    [Bindable]
    private var dpFlat:ArrayCollection = new ArrayCollection([
      {Region:"Southwest", Territory:"Arizona",
          Territory_Rep:"Barbara Jennings", Actual:38865, Estimate:40000},
      {Region:"Southwest", Territory:"Arizona",
          Territory_Rep:"Dana Binn", Actual:29885, Estimate:30000},
      {Region:"Southwest", Territory:"Central California",
          Territory_Rep:"Joe Smith", Actual:29134, Estimate:30000},
      {Region:"Southwest", Territory:"Nevada",
          Territory_Rep:"Bethany Pittman", Actual:52888, Estimate:45000},
      {Region:"Southwest", Territory:"Northern California",
          Territory_Rep:"Lauren Ipsum", Actual:38805, Estimate:40000},
      {Region:"Southwest", Territory:"Northern California",
          Territory_Rep:"T.R. Smith", Actual:55498, Estimate:40000},
      {Region:"Southwest", Territory:"Southern California",
          Territory_Rep:"Alice Treu", Actual:44985, Estimate:45000},
      {Region:"Southwest", Territory:"Southern California",
          Territory_Rep:"Jane Grove", Actual:44913, Estimate:45000}
    ]);
    

    If this post answers your question or assistance, please mark it as such. Thank you!

    http://www.stardustsystems.com
    Adobe Flex development and Support Services

  • determine the number of brushes with javascript

    I feel that he concocted before (more precisely in the context of rotating brushes), but I can't locate here or on PS - Scripts.com, so:

    How to determine the number of brushes in Photoshop?

    I intend to use this information for is to save the last brush as a set via JavaScript.

    Any help appreciated.

    Nope. It's free.

  • Determine the number of rows returned by a cursor

    I have a problem when I need to use slightly different logic based on whether or not a cursor returns a single line or multiple lines. I know you can use % ROWCOUNT to determine the number of rows returned far+, but it's not really help me because I need to know this information before I start to do any treatment.


    In other words. How can I know the number of rows returned by a cursor without actually iterate through the entire thing.

    I'm looking for something like this:
       Cursor ReqCursor(pi_cert_id IN Varchar2) Is
          SELECT course_id cid, grade g
            FROM requirements
           WHERE cert_id = pi_cert_id;
       c_ReqCursor ReqCursor%Rowtype;
    
    Open CertCursor(p_cert_num);
        Loop
            Fetch CertCursor
              INTO c_CertCursor;
            Exit When CertCursor%Notfound;
            
            If c_CertCursor%NumOfRows > 1 THEN
                Case A;
            Else
                Case B;
            End If 
       End Loop
    Close CertCursor;

    For your business add

     SELECT course_id cid, grade g, count(*) over() Tot_Rows
            FROM requirements
           WHERE cert_id = pi_cert_id;
    --"Fetch 1st row and you will know if the cursor has more than 1 row"
    

    HTH
    SS

  • How can I determine the number of contacts that I have

    How can I determine the number of contacts that I currently have on my iphone

    I don't know of a way on the iPhone, but if you have a Mac, you can go to the Contacts (platform) app and scroll to the bottom where you will find the total.

    Same for iCloud.com on your browser, go to the app, scroll down.

  • How to increase the number of lines 'forward '.

    The number of lines to allow me to "pass" the address elements recently reduced to only 4. Previously, I had an endless places in which to place the forwarding addresses.

    Firefox send an e-mail, it's strictly a web browser.

    If you use Firefox to access your e-mail, you use "webmail". You must seek assistance from your service provider or a forum for this service.

    If your problem is with Mozilla Thunderbird, let know us and we can move this thread to the queue of Thunderbird. This issue is currently in the queue of Firefox to get answers.

Maybe you are looking for