[CS3 JS] Finding blank paragraphs

I want to test if a paragraph is blank or just contains space characters. I am using this GREP expression, but it also highlights paragraph returns in paragraphs with text. Any help would be appreciated.
^\x20*
Rick Quatro

"^\x20+$"
Peter

Similar Messages

  • [CS3 JS] Finding paragraph containing table

    I have a table object and want to find the paragraph that contains the table. Then I want to return the contents of the paragraph previous to the table anchor. I am using this, but when I attempt to display the contents of the paragraph, I get "Object is invalid". Thanks for any help you can provide.
    // Get the paragraph inside the table.
    var oPgf = app.selection[0].paragraphs[0];
    // Make sure the paragraph is in a cell.
    if (oPgf.parent.constructor.name === "Cell") {
      // Get the parent cell and table objects.
      var oCell = oPgf.parent;
      var oTbl = oCell.parent;
      // Get the paragraph containing the table.
      var oPgf2 = oTbl.storyOffset.paragraphs[0];
      // Get the story object of the paragraph.
      var oStory = oPgf.parentStory;
      // Get the paragraph's index.
      var iPos = oPgf2.index;
      // Display the contents of the paragraph before the table anchor.
      alert (oStory.paragraphs[iPos-1].contents);
    Rick Quatro
    585-659-8267

    I found a previous post that is helping me with this.
    // Paragraph inside of table.
    var oPgf = app.selection[0].paragraphs[0];
    // Make sure the paragraph is inside a table
    if (oPgf.parent.constructor.name === "Cell") {
      var oCell = oPgf.parent;
      var oTbl = oCell.parent;
      // Get the paragraph containing the table anchor.
      var oPgf2 = oTbl.storyOffset.paragraphs[0];
      // Loop from the table anchor to the top of the story.
      while (oPgf2) {
        $.writeln(oPgf2.constructor.name);
        oPgf2 = oPgf2.parentStory.paragraphs.previousItem(oPgf2);
    This basically works, except this line gives an "Object is invalid" error when it gets to the beginning of the story:
    oPgf2 = oPgf2.parentStory.paragraphs.previousItem(oPgf2);
    I can use a try statement, but I am wondering why the loop doesn't exit gracefully without an error. Thanks.
    Rick

  • Undo on ApplyFormatOperation not working on blank paragraph

    Steps to repro:
    1. Put your cursor in an empty paragraph
    2. Set paragraphStartIndent using an ApplyFormatOperation
    3. Undo
    You will notice the operation wont get undone.
    Here is a little video of it.  I used Ctrl+Z to undo. http://screencast.com/t/YzE0ZTc5OTMt
    It appears the issue is with this code that gets executed from ParaEdit during the undo
    public static function setParagraphStyleChange(flowRoot:TextFlow,begChange:int, endChange:int, coreStyles:Object):void
         var beginPara:int = begChange;
         while (beginPara < endChange)
              var para:ParagraphElement = flowRoot.findLeaf(beginPara).getParagraph();
              para.setCoreStylesInternal(coreStyles);
              beginPara = para.getAbsoluteStart() + para.textLength;
    It seems like it should maybe be beginPara <= endChange in the cases of a  blank paragraph.
    Thanks

    Thanks for the report. I'll write up a bug.

  • Blank paragraph at end of automatically generated TOC

    When generating a Table of Contents InDesign CS4, the TOC text has two blank paragraphs at the end of the generated TOC story. There are no empty paragraphs in any of the stories in the documents that the TOC is being generated from. Is this a bug?

    I don't know if it's a bug, but it's been around for a long time.
      Yeah. And it can cause text to become unnecessarily overset when 
    there are keeps settings in your TOC...
    Harbs

  • Bridge CS3- My find command has quit working, any help?

    In my Bridge CS3 the find command cannot find any of the keywords that I spent hours adding. It has been working fine, but one day stopped. I have deleted the plist, the cache, and the recent workspace to no effect. I have not added any new software recently. It doesn't work if I am searching a file that I have open in Bridge so it is not a matter of not waiting long enough for the thumbnails to generate. Those were the only suggestions I found anywhere. Does anyone have any other suggestions? I am running this on a Mac if that makes a difference.

    I may have to upgrade as you suggest. I did find one thing that is interesting, though it doesn't explain where the problem comes from. If I open a folder in Bridge that holds files that I have added keyword to, when I close it Bridge can find those files with the find command. I am not sure why opening the folders would make a difference, but it seems to. This only works one when searching one sub-folder deep. If there is another folder in that, even though I've opened it, it will not find it.
    I guess until I am ready to spend the money to upgrade I will spend an evening opening all my keyworded folders. I better find a good video to watch while doing it!

  • HT1430 I have been getting emails but recently I switch on and just find blank screen but the app says I am getting mail this is now happened to me twice any ideas?

    I have been getting emails but recently I switch on and just find blank screen but the app says I am getting mail this is now happened to me twice any ideas?

    Quit mail like this.
    Go to the Home screen and double click the Home button. That will reveal the row of recently used apps at the bottom of the screen. Tap and hold on the app in question until it wiggles and displays a minus sign. Tap the minus sign to actually quit the app. Then tap anywhere on the screen above that bottom row to return the screen to normal. Then restart the app and see if it works normally.

  • How to find the paragraph and line numbers [CS3] [JS]

    Hello,
    I have a script that finds certain text formatting. Rather than having the script select all the instances of this text I have an alert that lists the page number and the contents for each found instance. The following gets those.
    var pageNumber = myFoundSet[n].parentTextFrames[0].parent.name;
    var foundContents = myFoundSet[n].contents;
    However, I would like to include the number of the paragraph where the found text resides as well as the line number in that paragraph.
    I am stumped on how to do this. Would be nice if there were a parentParagraph and a parentLine.
    Can someone point me in a direction?
    Thanks,
    Tom

    Tom,
    Assuming that you're looking for the number of the paragraph on the page, you'd need to count the number of paragraphs in the text frame that a found item occurs in. Since indexes are always counted from the beginning of the story, you isolate the text between the top of the page and the found item by starting at the index of the first insertion point of the found item's parent text frame and the found item itself. You capture that with this single long line:
    // range over ...
    paragraph_number = myFoundSet[n].parentStory.characters.itemByRange (
       // ... index of first ins. point of found item's parent text frame ...
       myFoundSet[n].parentTextFrames[0].insertionPoints[0].index,
       // ... and index of found item
       myFoundSet[n].index
       ).paragraphs.length;
    This includes any paragraph that started on the previous page. To find the found item's line number within its parent paragraph you do something similar:
    line_number = myFoundSet[n].parentStory.characters.itemByRange (
       myFoundSet[n].paragraphs[0].index, //first insertion point of paragraph
       myFoundSet[n].index
       ).lines.length;
    There's no need for parentParagraph and parentLine: myFoundSet[n].paragraphs[0] returns an item's parent paragraph, myFoundSet[n].lines[0], the item's parent line.
    Peter

  • How to find a paragraph with restarting numbering [CS3] [Javascript]

    Hi,
    Does any of you know how to solve this one:
    I am making a script which needs to search for numbered paragraphs, and assign it with a specific paragraph style. It should go like this:
    If the paragraph's numbering restarts (meaning it starts with 1) - the style should be "Number1".
    If the paragraph's numbering continues from where it is - the style should be "Number".
    It sounds quite simple in theory, and even doable with the simple "Find/Change" operation in InDesign, but when I went over the object model, I couldn't find a single method for my script to differentiate between the two cases. Does any of you know of a method for this?
    Here is what I've got so far:
    app.findTextPreferences = NothingEnum.nothing;
    app.changeTextPreferences = NothingEnum.nothing;
    app.findTextPreferences.bulletsAndNumberingListType = 1280601709; // Numbers
    app.changeTextPreferences.appliedParagraphStyle = "Number";
    app.changeText ();
    app.findTextPreferences = NothingEnum.nothing;
    app.changeTextPreferences = NothingEnum.nothing;
    Thanks,
    Ola

    numberingRestartPolicies might be the thing you are looking for.

  • [CS2/CS3 JS] Finding the first character of each paragraph

    Hi,
    Can anybody help with my script below:
    for (h=0; myParaCount>h; h++){
    myChars = myStory.paragraphs.item(h).contents;
    if (myChars.characters.item(0) == "l" && myChars.characters.item(0).appliedCharacterStyle == CharStyleWin){
    myStory.paragraphs.item(h).appliedParagraphStyle = "L-B";
    This script is supposed to test if the first character is an "l" with my character style "Wingdings" applied to it. I could not test whether the character style is "Wingdings" or not. What could be wrong with my script. Thanks.

    // You need to have a textFrame selected
    var myFrame = app.selection[0];
    var myParaCount = myFrame.paragraphs.length;
    // There must exist a paragraphStyle name L-B
    var myApplyStyle = app.activeDocument.paragraphStyles.item("L-B")
    for (h=0; h < myParaCount; h++){
    var myChar = myFrame.paragraphs.item(h).characters.firstItem();
    // check if first char is "l" and if its applied charstyle name is CharStyleWin
    if (myChar.contents == "l" && myChar.appliedCharacterStyle.name == "CharStyleWin"){
    myFrame.paragraphs.item(h).appliedParagraphStyle = myApplyStyle;
    /* Edited at 11.21 */

  • Adobe Photoshop CS3 Registration screen blank and unresponsive,

    I just installed Adobe Photoshop CS3 Extended Version, and was eager to use it when I got the registration screen...and it froze.
    It just blanks out after selecting "Do Not Register" and "Register Later"
    I don't know how to fix it...can you guys help me?
    My computer's hardware is:
    AMD Athlon 64 X2 Dual Core Processor 4200+
    Radeon X800 GPU
    2 Gigs of RAM
    110 gigs of freespace
    Using Microsoft XP SP3
    Let me know if you need any other information.

    > and as the only way another user could reply is if they had that EXACT problem and also had a solution,
    I've noticed this message from you several times, John. Often in cases like this where there is a possibility that another user has had the exact same problem, and thus might have an answer.
    I suggest that you shorten your message to "You may need to contact Adobe for help, and the following two lines" which will seem less naggy.

  • [CS3 JS] Find/Change Object Problem

    app.changeObjectPreferences = NothingEnum.nothing does not seem to clear the change object preferences for me.
    app.findObjectPreferences = NothingEnum.nothing works as expected, as do both app.findTextPreferences = NothingEnum.nothing and app.changeTextPreferences = NothingEnum.nothing.
    Does anyone else use the new Find/Change Object?

    Hello. I'm new here but it seems to be the only place where I can post this question to.
    I'm working in a C# application that uses InDesign CS3 scripting. I'm trying to create an index automatically from a tabbed list of words in a text file.
    As C# is a strongly typed language, I have to cast all objects to the right type. I'm having problems when I try to add the page numbers to the created index entries using the following code (I've used the CreateIndexEntry.jsx scrip as a starting point).
    //Find all occurrences of the word or set of words (the topic name)
    ((InDesign.FindTextPreference) app.FindTextPreferences).FindWhat = topic.Name;
    InDesign.Objects foundTexts = doc.FindText(System.Reflection.Missing.Value);
    It's supposed to be an Array of Text objects (InDesign.Text) but when I try to cast each object using this
    //Code is forced because I've tried everything here
    //Loop through each finding and add page numbers to topic
    IEnumerator textEnum = foundTexts.GetEnumerator();
    while (textEnum.MoveNext())
    object text = textEnum.Current;
    topic.PageReferences.Add((InDesign.Text)text, InDesign.idPageReferenceType.idCurrentPage, System.Reflection.Missing.Value, System.Reflection.Missing.Value);
    I got the following exception (translated).
    text is not an InDesign.Text object (Interfaces doesn't match)
    So the question is what object type should I use to cast each object resulting by calling the Document's FindText method.
    Every suggestion will ve very welcome.
    Thank You very much.

  • [win][js][cs4]find/change paragraph styles without losing local overrides

    Hi guys i need a little help here.
    I created a javascript which will find and replace doc file paragraph styles with indesign paragraph styles. everything works fine but the problem is that when it applies the paragraph styles it loses all local overrides. i tried:
    changetext(false);
    but its not working is there some kind of conditional parameter that i can put in the changetext() function so that it wont clear local overrides?
    Thanks.
    CharlesD

    Thanks Kasyan. You're always there to save my day. Thank you very much...
    I slightly modify the script to go through all my paragraph styles that need to be replaced coz there are hundreds of them. Im not sure though if this is the best or is there any faster way to do this:
    replace("T1", "Text", "T1");
    replace("T", "Text", "T");
    replace("1", "Heads", "1");
    replace("2", "Heads", "2");
    function replace(input, folder, output) {
        var foundItem;   
        var doc = app.activeDocument;
        app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.NOTHING;
        app.findGrepPreferences.findWhat = ".+";
        app.findGrepPreferences.appliedParagraphStyle = input;
        var foundItems = doc.findGrep();
        for (var i = 0; i < foundItems.length; i++) {
            foundItem = foundItems[i];
            foundItem.applyParagraphStyle(doc.paragraphStyleGroups.item(folder).paragraphStyles.item( output), false);
        app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.NOTHING;

  • [cs3][JS]Find Enter with no text in Layout

    Hi,
       I need to find enter with no text(idle) in a Layout.I have used the following code.
            app.findGrepPreferences = NothingEnum.nothing;
            app.changeGrepPreferences = NothingEnum.nothing;
            app.findGrepPreferences.findWhat ="\n";
            app.findChangeGrepOptions.includeFootnotes = false;
            app.findChangeGrepOptions.includeHiddenLayers = false;
            app.findChangeGrepOptions.includeLockedLayersForFind = false;
            app.findChangeGrepOptions.includeLockedStoriesForFind = false;
            app.findChangeGrepOptions.includeMasterPages = false;
            var myFoundItems=new Array;
            myFoundItems=app.activeDocument.findGrep();
            var len=myFoundItems.length;
            alert(len);
    I don't know whether my approach is correct or not? Please suggest me.
    Regards
    Kumar

    hi Kumar,
    you need to find "double enter" and then process second paragraph in each found result - but you need to process found items backward
    or if you want to find empty TextFrames - you wont find them in this way - becuase empty TFs are empty no enter or any other characters
    robin
    www.adobescripts.co.uk

  • Strange, long program name for Photoshop CS3 in Finder Open with

    I recently upgraded from Adobe CS2 to CS3 (since they FINALLY fixed the Acrobat issue!), but now when I right-click an image file in Finder, then select "Open with", and look at the suggested programs, I've got these horrendously long, strange program names displaying for Photoshop CS2 and Photoshop CS3. Here's the one that displays for CS3:
    Adobe Photoshop CS3.app (10.0.1x10071012 [20071012.r.1644 2007/10/12:09:30:00 cutoff; r branch]))
    Screenshot:
    http://johnhmoore.com/AdobeOpenwith.png
    Any idea why this is or how I can make it go away?? (and instead just say Adobe Photoshop CS3.app)
    Thanks!
    John

    I would try resetting your LaunchServices database with something like Onyx or Cocktail (I think it does it too). Note that this will wipe out any custom file associations you might have setup.

  • Bridge CS3 "Edit Find" not working after optimizing cache.

    Power PC G5
    Mac OSX v.10.4.11
    3GB RAM
    Photoshop CS3
    After optimizing the cache, my Edit>Find feature does not work. I looked into the Bridge Preferences and could not find anything under Thumbnails or Cache that can turn it back on. Please advise.

    Make sure you have Bridge 2.1.1.9.
    Purge the cache for each folder through the Tools menu in Bridge.

Maybe you are looking for