[JS] Find hyperlinks in a text block

Is there a way I can easily, given a block of text, find what links have their SourceTexts inside this block of text, or overlapping it?

The only way I could think of was to loop through all the hyperlinks in the document and then check to see if any character in their SourceText = any character in the text block, we are looking.  Seems a bit pointless to me.

I would like this:

Step 1: check the history of each hyperlink source. If the story is not one that you control, throw it away.

2. check the index to sources on the left. If the index is higher at the beginning of your text and less of late, it is within your reach.

This should be very fast...

Substances

Tags: InDesign

Similar Questions

  • Find the first paragraph of each specific chained text block...

    Hi all

    I have this kind of layout:

    Capture d’écran 2015-08-27 à 10.46.02.png

    Capture d’écran 2015-08-27 à 10.46.20.png

    ... with several groups of text blocks chained [red, green,...].

    I want to find in the identity document all the first para of each text block defined by a "BLOCK of TEXT GREEN" object style and apply a paragraph style "GREEN PARA STYLE while FIRST THE block"! as:

    Capture d’écran 2015-08-27 à 10.47.01.png

    Thank you much for the help!

    Here is a new version:

    main();
    
    function main() {
        if (app.documents.length > 0) {
            var story, containers, container,
            doc = app.activeDocument,
            stories = doc.stories;
    
            try {
                app.findTextPreferences = app.changeTextPreferences = NothingEnum.NOTHING;
                app.findTextPreferences.appliedParagraphStyle = doc.paragraphStyles.item("GREEN PARA STYLE FIRST ON BLOCK");
                app.changeTextPreferences.appliedParagraphStyle = doc.paragraphStyles.item("GREEN PARA STYLE");
                doc.changeText();
                app.findTextPreferences = app.changeTextPreferences = NothingEnum.NOTHING;
            }
            catch(err) {
                $.writeln(err.message + ", line: " + err.line);
            }
    
            for (var i = 0; i < stories.length; i++) {
                story = stories[i];
                containers = story.textContainers;
                if (containers.length > 1) { // process only chained text blocks
                    for (var j = 0; j < containers.length; j++) {
                        container = containers[j];
                        if (container.appliedObjectStyle.name == "GREEN TEXT BLOCK") {
                            try { // if the style or the 1st paragraph is missing, write error message to console and continue
                                container.paragraphs[0].appliedParagraphStyle = doc.paragraphStyles.item("GREEN PARA STYLE FIRST ON BLOCK");
                            }
                            catch(err) {
                                $.writeln(err.message + ", line: " + err.line);
                            }
                        }
                    }
                }
            }
        }
        else {
            alert("Please open a document and try again.", "Error", true);
        }
    }
    
  • Find the object in the text block

    Hi all

    How I was able to find my text frame contains an anchored object.

    Suppose I have a list of text blocks and want to check if a particular text block contains an anchored or not object

    Kind regards

    Alam

    The property of a text object pageItems gives you access to all

    anchored objects.

    So if you have a textFrame called f, for example, you would do:

    myAnchoredObjects = f.texts.everyItem () .pageItems ();

    for a list of all the anchored objects.

  • Move the letter outside the text block

    Is it possible to move a letter outside of text without text block movement.

    Move text.PNG

    2 grep and regex 1 styles!

    styles 2 char:

    With 2 grep styles paragraph style

    WARNING: / / 1: ^ normal-space / / 2: ^ normal-space\K.

    A regex:

    WARNING: / / find: \r (? normal space) / / replace with: $0normal-space

    Cool and easy!

  • Text on the stroke to the text block

    I was wondering if there is no way to force the text in a text block to be at the top of the race that I added to the text box. The descenders are cut and I have messed around with various options of baseline for the text block, but can't seem to find a way to make it work without making the largest text block which I prefer not to do.

    I saw a few solutions, but they all seem to be for earlier versions by using the settings that I can't find in the CC options.

    Any help would be appreciated! Thank you

    --

    Kristin

    Use a text image inset.

  • Search the text of paragraph style and place them in the new text block with width 50mm

    Hello

    I'm looking for voor a paragraph to find script dat styles and place them in a new text block with width 50 mm.

    Is there a solution?

    Kind regards

    Patrick

    Width: options General of the frame of the text, GBA: fixed width, then 50mm width

    Height: automatic block text size options

    (These two in the dialog box object styles)

  • Resize the text without scale text block

    Hi people,

    Is it possible to resize a text frame without scaling the text in the 2014 AI CC SDK?

    I'm working on an AI CC 2014 plug-in and need to resize a text frame without scaling of the text. However, I'm not having a bit of luck to find how to do this. Is what I want to resize the text block in the Type area Options Panel makes, but I'm not able to understand how what classes/methods it uses, or whether they are still exposed in the SDK of.

    I tried to use sAITransformArt->TransformArt(), but I can't find a way to stop the text to scale with the text block. I considered, after processing, reformat the text which has been nationally, but that doesn't seem right.

    My current thinking is to move the text of the framework which should be scaling in a new block of text size correctly, and then delete the existing framework, but before that, I thought I would ask here see if do I it's harder it must be because I'm missing something.

    Thanks in advance for any help!

    See you soon!

    -Jim Birkenseer

    You must use sAITransform-> (TransformArt) on the subject of track of the image of the text, not the entire text block.

    For example:

    AITextFrameType textFrameType;
    sAITextFrame->GetType( art, &textFrameType );
    if ( ( textFrameType == kInPathTextType ) || ( textFrameType == kOnPathTextType ) ) {
        sAITextFrame->GetPathObject( art, &art );
        AIRealMatrix sMatrix;
         // Set your matrix as needed here...
        sAITransformArt->TransformArt( art, &sMatrix, 1.0f, kTransformObjects );
    }
    
  • Number of words and then pasting text into the text block

    I'm trying to create a javascript script that counts the words in a block of selected text, adds "WORDS." at the end and then paste at the beginning of this block of text with a "BOLD" character style applied. So he would look like:

    25 WORDS. Text text text text text. etc.

    I managed to find a way to create the character style, to count the words in the selected text block and give me an alert. But I'm not sure how to apply the character style and paste it at the beginning. Any help would be really appreciated. Here's what I have so far.

    Thank you

    -----------------------

    var curDoc = app.activeDocument;

    mySel var = app.selection [0];

    Create the style of wordcount

    If (! curDoc.characterStyles.item("wordcount").isValid) {}

    cStyle var = curDoc.characterStyles.add ({name: "wordcount"});

    }

    else {}

    cStyle var = curDoc.characterStyles.item ("wordcount");

    }

    cStyle.fontStyle = "Bold";

    //

    var mySelWords = mySel.texts.everyItem (). words.length;

    var mySelStoryWords = mySel.parentStory.words.length;

    Alert (mySelWords + "WORDS.");

    Hello

    further, through the selection, change the same way:

    var
         curDoc = app.activeDocument,
         mySel = app.selection,
         len = mySel.length,
         cStyle = curDoc.characterStyles.item("wordcount"),
         mySelWords, mString, curSel;
    
    if (!cStyle.isValid)
        cStyle = curDoc.characterStyles.add({name: "wordcount", fontStyle: "Bold"});
    
         while (len-->0) {
              curSel = mySel[len];
              if (curSel.hasOwnProperty ("insertionPoints") ) {
                   mySelWords = curSel.texts.everyItem().words.length,
                   mString = mySelWords + " Words. ";
                   curSel.insertionPoints[0].appliedCharacterStyle = cStyle;
                   curSel.insertionPoints[0].contents = mString;
                   }
              }
    

    Note that textFrame.words County is those visible only, so the other part of the text is excluded.

    If some of the answers have been useful - mark (their), pls ==> it's a good indicator for other researchers and a few points for me.., mlask.

    Jarek

  • out the anchor text block and copy its contents

    Hi all

    I have a script that will be able to anchor to InDesign text block and it works well. Now my problem is that I released that anchored text frames and then copy its contents the same position where the text block was at anchor.

    Here's what I do:

    1. find and block of text of a document (using the find object, anchored by its applied object style).

    2. release the anchored object found.

    3 copy its contents the same position where it was anchored.

    For 1 and 2 rep, I maybe able to do but point 3 I have no idea.

    Hope someone can lend me the time to solve this problem.

    Thanks in advance for any help.

    -elmer

    then, instead of myFrame.releaseAnchoredObject (); use myFrame.remove ();

  • AppleScript - replace text in specific text block

    Start another there is excellent forum:

    I know how to change the text in a document:

    say application "Adobe InDesign CS5.5.

    set find the text preferences for Nothing

    set change text preferences for Nothing

    -The document for the search string.

    set find what the preferences of text for "SigBelowT"

    -Replace the search with what we have learned from the database

    set implement the change text preferences at theSigCopyB

    -this is the actual search and replace command

    set myFoundItems to change the text

    end say

    I'm changing in a specific, known as paragraph as a layer in my inDesign source Document only:

    say application "Adobe InDesign CS5.5.

    tell the active document

    try

    set find the text preferences for Nothing

    set change text preferences for Nothing

    the value Text_Frame to le text block "PH".

    set find what the preferences of text for ' ~ ' text Text_Frame block

    set " from changing preferences of text to '" "

    set myFoundItems to change the text

    end try

    end say

    end say

    I've tried several iterations of similar to this one, but I'm not hitting the right combination.

    Suggestions?



    Hello

    OK, you may need to change this snippet a little. Right now, it will only apply changes to is named "foo" text frames.

    tell application "Adobe InDesign CS5.5"
              set find text preferences to nothing
              set change text preferences to nothing
              set find what of find text preferences to "~"
              set change to of change text preferences to " "
              tell active document
    
                        set tfs to all page items
                        repeat with i from 1 to count of tfs
                                  set tf to item i of tfs
                                  if name of tf = "foo" then
      change text of tf
                                  end if
                        end repeat
    
              end tell
    end tell
    

    Loïc Aigon

    http://www.loicaigon.com

  • How the auto repeat 'position title (continued)' in the text block

    Hi guys,.

    I've looked everywhere and couldn't find it.

    Here's what I'm trying to achieve:

    I have a few blocks long text which flows into a framework of text block and I would like to have the title for each of the items be repeated first of all in the first line of the block of text on each page as follows (suite).

    I know that I can use master pages and can have a separated with my title text box. But then, if the number of page change, I can end up with a title (continued) where shouldn't.

    The next and previous page number line break does not work for me, because I need it to be the title of the article and it must be in the same frame of definition as title x.

    It's somewhat similar occurs when your table across more than one page. The header is repeated on each image.

    I really tried to find it but no luck. Whenever I have tryied the anwes only I got was to line breaks, next and previous page number.

    Much appreciated if anyone can save me.

    Thank you

    Mau

    I think that we know exactly what you're trying to do, and we told you how to do it in code.

    Word has a few features that allow you to have different headers and footers for section home pages and use them automatically when you set up a new section. This is equivalent to using two masters in ID and one without the variable grant your section start pages. The difference is that you have to do that yourself.

  • Move the text block to another Page

    Hey,.

    I'm new to InDesign scripting, and I've been browsing the docs for quite awhile, but can't find how to move a block of text to another page.

    The closest I came was a .parentPage, but it is read-only.

    I have my frame on the first page of the document, how can I move, let's say, on page 5?

    myFrame.move (myDestinationPage)

    Substances

  • Prevention of the forms of text block

    When I draw a shape (box, circle, etc.) with the tool form - I usually insert columns with text inside them. The form is usually a boarder of the page and sometimes I have to change.

    Several times just by clicking on my text tool in the area of the shape transforms this form in a block of text.

    I need to find a way to prevent the form turns into a block of text.

    There are several ways to handle this. One is to turn off the preference which allows the tool to type convert images to text blocks.

    Another is to put these borders on their own layer and lock the layer.

    A third is actually use the feature to combine the border and a text frame, if it is appropriate for the page layout.

  • Text wrapping will not be in the text block

    I am changing the content on a block of text in Illustrator using a JavaScript file.

    My method is as follows:

    changeLayer = doc.layers.getByName(textKeys[t]);

    changeLayer.textFrames.getByName(textKeys[t]).wrapInside = true;

    changeLayer.textFrames.getByName(textKeys[t]).contents = textArray [textKeys [t]];

    Basically, I set wrapInside to true and then I replace the content of the block of text with a string.

    However, rather than the text as you wish, Illustrator print everything on one line expands the size of the text block (and sleep) to adapt the text on a single line. Even when I put explicitly the width and height of the image in the script, it shrinks the text to fit on a single line in the rather enveloping framework. If I explicitly set the size of the police he then extends the framework once again, but only on a single line. Any ideas? Thanks in advance.

    Good evening

    Don't forget that you have different types of linked text frames. In vba, you can find the property THAT allow you to show that read only 3 types of text frames aiAtraText, aiPathText and aiPointText

    Patrice

  • Rotate the text with the character within the text block style

    I would like to apply a paragraph or character style to a certain character in a text frame. I would need to rotate 90 degrees in the framework, separate from the other text. Is this possible?

    Insert the text block in the block of text as an anchor and rotation you need.

Maybe you are looking for