Connect the words specified in textframe with lines

Hi all

I want to use the script below, and replace it with a script that connects the words specified with lines. Now, it connects all words with lines. I don't know what to do, so I hope someone can help me.

Thanks in advance

#include./lib/bene.jsx
InDesign CS2 JavaScript
The value 4.0 script object model
app.scriptPreferences.version = 4.0;

////////////////////////////////////////////////////////////////////////////////////////// ///
var NomMonScript = app.activeScript.name;

var myObjectList = new Array;
If (app.documents.length! = 0) {}
If (app.selection.length! = 0) {}
for (var myCounter = 0; myCounter < app.selection.length; myCounter ++) {}
switch (app.selection [myCounter].constructor.name) {}
allow only managers of related texts
case "TextFrame:
myObjectList.push (app.selection [myCounter]);
break;
}
}
If (myObjectList.length! = 0) {}
run the thing! call a function
myConnectWords (myObjectList);
}
else {}
Alert ("Please select TextFrame and try again.');
}
}
else {}
Alert ("Please select an object and try again.');
}
}
else {}
Alert ("Please open a document, select an object and try again.');
}

////////////////////////////////////////////////////////////////////////////////////////// ///
functions
///////////////////////////////////////////////////////////////////////////////////////// ////
function myConnectWords (myObjectList) {}
myDocument var = app.activeDocument;
var myLayer, myCounter, myColor;

Measure
var myOldRulerOrigin = myDocument.viewPreferences.rulerOrigin;
myDocument.viewPreferences.rulerOrigin = RulerOrigin.spreadOrigin;
Save the units of measure.
var myOldXUnits = myDocument.viewPreferences.horizontalMeasurementUnits;
var myOldYUnits = myDocument.viewPreferences.verticalMeasurementUnits;
Create the units of measurement to points.
myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.points;
myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.points;

Get references no nuance.
var myNoneSwatch = myDocument.swatches.item ("None");

Create a color (if it does not already exist).
myColor = myDocument.colors.item (myScriptName);
try {}
myColorName = myColor.name;
}
{} catch (MonErreur)
var myColorArray = new Array (100, 0, 0, 0);
myColor = myDocument.colors.add ({model: ColorModel.process, space: ColorSpace.CMYK, colorValue:myColorArray, name: NomMonScript});
}

Create a layer for the generated lines (if it does not already exist).
myLayer = myDocument.layers.item (myScriptName);
try {}
myLayerName = myLayer.name;
}
{} catch (MonErreur)
myLayer = myDocument.layers.add({name:myScriptName});)
}

Process objects (here the text blocks) in the selection.
for (myCounter = 0; myCounter < myObjectList.length; myCounter ++) {}
Download textframe
var myNewFrame = myObjectList [myCounter];

get all the lines in the frame
var myLines = myNewFrame.lines;
linking every word with all of the words in the following line
for (myLineCounter = 0; myLineCounter < myLines.length - 1; myLineCounter ++) {}
get all the words in the line + next line
var myLine = myLines [myLineCounter] mentioning;
var myNextLine = myLines [myLineCounter + 1] mentioning;
myPathPoints.push([myLine.insertionPoints[-2].horizontalOffset,myTmpY]);

Combine this + line then the words
for (i = 0; i < myLine.length; i ++) {}
Get the word
var myWord_i = myLine [i];
Table for the points
var myPathPoints = new Array;
Add fist point X/Y
myPathPoints [0] = [myWord_i.horizontalOffset, myWord_i.baseline];

for (j = 0; j < myNextLine.length; j ++) {}

Get the word

var myWord_j = myNextLine [j];

If (myWord_j.baseline! = myWord_i.baseline & & myWord_j.horizontalOffset! = myWord_i.horizontalOffset) {}

Add the second point X/Y

myPathPoints [1] = [myWord_j.horizontalOffset, myWord_j.baseline];

draw the line

myDrawPolygon (myPathPoints, 1, 100, myColor, myNoneSwatch, myLayer);

}

}

}

}

}

myDocument.viewPreferences.rulerOrigin = myOldRulerOrigin;

Set the units of measure to their State of origin.

myDocument.viewPreferences.horizontalMeasurementUnits = myOldXUnits;

myDocument.viewPreferences.verticalMeasurementUnits = myOldYUnits;

}

Well Yes - Fun little exercise, it was.

Select an entire text block, or text directly, and this script logs all the words with the character style "label". The lines are at the centre of reference of each word.

if (app.documents.length == 0 || app.selection.length != 1 ||
 !(app.selection[0] instanceof TextFrame || app.selection[0].hasOwnProperty("baseline")))
{
 alert ("Please select a single text frame or some text first");
} else
{
 charStyleName = "label";
 app.findTextPreferences = null;
 app.findTextPreferences.appliedCharacterStyle = app.activeDocument.characterStyles.item(charStyleName);
 list = app.selection[0].findText();
 if (list.length == 0)
  alert ('No text found with char style "'+charStyleName+'"');
 else if (list.length == 1)
  alert ('Only one text found with char style "'+charStyleName+'", no use in going on');
 else
 {
  lpath = [];
  while (list.length)
   lpath.push ( centerOfWord (list.shift()) );
  if (app.selection[0] instanceof TextFrame)
   pg = app.selection[0].parent;
  else
   pg = app.selection[0].parentTextFrames[0];
  while (!(pg instanceof Spread || pg instanceof MasterSpread || pg instanceof Page))
  {
   if (pg instanceof Document || pg instanceof Application)
    break;
   pg = pg.parent;
  }
  l = pg.graphicLines.add({strokeWeight:0.5, strokeColor:app.activeDocument.swatches.item("Black")});
  l.paths[0].entirePath = lpath;
 }
}
function centerOfWord (word)
{
 var l = word.insertionPoints[0].horizontalOffset;
 var r = word.insertionPoints[-1].horizontalOffset;
 return [ (l+r)/2, word.baseline ];
}

Tags: InDesign

Similar Questions

  • How to find the words that spans end of line to the next line in pdf format?

    I use Adobe Acrobat Pro X version for our development and form maintenance. I am writing a command Acrobat JAVA script which reads through all words and run the spell check and reports the wrong words spelled in an excel sheet. Because I run this script in batch for more than 1000 PDFs - I get a lot of words together. When I looked in the PDF files all these words are good looking because it makes its appearance at the end of the right margin, and the next word is in the next line. Since there is no space between them, it was mined in one word. Where the failure.

    I have used wordf = this.getPageNthWordQuads (i, j) to get the word start and end coordinates. When I look at my values create a rectangle, and extending through the lines. I got the coordinates for the ordinary Word and which cover the two lines acoross. the coordinates are same.

    I think I'm screwed I 8000 words and not the slightest idea how to get rid of them actual misspelled words.

    Help, please. Let me know if any /method class so I give the speech will give me the end of line or I have to go to the next layer to find this split.

    the addnot is somehow marking the words using this contact information - please hellp understand me how this works. Thank you.

    for all pages

    for (var i = 0; i < this.numPages; i ++)

    {

    For all words

    PG += 1;

    numWords = this.getPageNumWords (i);

    for (j = 0; j < numWords; j ++)

    {

    get spell checking

    ckWord = spell.checkWord (this.getPageNthWord (i, j))

    If (ckWord! = null)

    {

    Jn = 0

    ml = 0

    If the misspelled word found.

    wordf = this.getPageNthWordQuads (i, j)

    swordf = wordf.toString)

    var St = swordf.split(",")

    var diffx0 = parseInt(st[0])-8

    var diffx1 = parseInt(st[1])-8

    var diffx2 = parseInt(st[2])-8

    var diffx3 = parseInt(st[3])-8

    var diffx4 = parseInt(st[4])-8

    var diffx5 = parseInt(st[5])-8

    var diffx6 = parseInt(st[6])-8

    var diffx7 = parseInt(st[7])-8

    If (bparole is csword)

    {

    Jn = 1

    }

    If (m [1]! = m [3])

    {

    ml = 1

    }

    dataLine += "\r\n writing".

    }

    on the other

    {

    ml = 2

    }

    dataLine += "\r\n"+this.documentFileName. "

    + "\t" + this.getPageNthWord (i, j)

    + "\t" + pg

    + "\t" + j

    + "\t" + ml

    + "\t" + jn

    '\t st [0]' + diffx0 + '\t m [1]' + diffx1 + '\t st [2]' + diffx2 + '\t [3] st' + diffx3

    '\t st [4]' + diffx4 + '\t st [5]' + diffx5 + '\t [6] st' + diffx6 + '\t st [7]' + diffx7

    CK = 1

    }

    }

    }

    If Acrobat is reading each part of the word and the distinct words, you have a problem.

    The way I approached it in some of my tools was to check if a word ends

    with a hyphen and if so, to check if it is the last one on the line. If the two

    conditions are met, combined with the word on the next line. It comes

    do not fool proof, of course, as there are documents with columns are another

    structural elements that prevent this from working. Better than nothing,

    Although...

    However, it is also possible that Acrobat sees both as parts of

    the same word. In this case, getPageNthWordQuads() returns several

    tables of quads. As you know, this method returns an array of arrays quad.

    He is usually alone, but in principle it could be more... Something

    to check before giving up.

  • connecting the 2 everything in those with hdmi

    Hello

    We recently purchased a HP Envy 27 runnung windows 8.1. We have already had a HP Touchsmart 610 Windows 7.

    I would use the 610 as a second monitor for the new Envy27. I have connected the 2 computers with an hdmi cable, but can't get to save as a second monitor.

    Can someone help me, or is it not possible to link these 2 all in UNITS?

    Hello

    AIO machines are designed to run as AIO (stand-alone machines, without having to connect what either). At this point no other choice than to use an exit USB video card on a same machine and UNPLUG the video card in any other machine. You want to do this? Buy the USB video card and another monitor, it's much cheaper and more convenient.

    Kind regards.

  • Anyone with the problem of not show apple tv on the same wifi to connect the new application remote control (with the last operating system both on device)?

    Tried to connect the new (launched in July 2016) Apple Remote app, I'm not able to add the Apple Tv from my iphone (5 c), because it does not show apple tv to connect even on the same wifi. I use the latest os on iphone and TVos 9.3.3.

    9.3.3 isn't the latest version of the software for your phone or your Apple TV.

    Try the following steps for the Apple TV 4, check if things work after each step if necessary, before you try the next.

    1. Restart the Apple TV (settings > system > restart).
    2. Restart the Apple TV by removing ALL cables for 30 seconds.
    3. Restart your router. (Also try to remove the power cord for at least 30 seconds)
  • Continue to use MS Word 2003 instead of the Word 2007 that came with my new operating system (Windows Vista)

    I have Windows Vista OS with Word 2007 (bougth with my new machine).  Previously, I have Windows XP with Windows 2003.  I would like to keep Word 2003 and which have to be my default program.  How can I do this?  I have still my Windows XP disc - should I reinstall?  What are the risks/disadvantages to return to Windows XP?  Thank you.

    "Windows XP with Windows 2003? You mean Office 2003?

    Microsoft Office 2003 is Vista Compatible and supported by Microsoft.

    Uninstall Office 2007 > install Office 2003 using the Office 2003 disc.
    If Office 2003 is an office retail license, it can be transferred to another computer.
    If Office 2003 is part of Office/XP agreement of the manufacturer of the computer, it is classified as an OEM license and is non-transfereble to another computer.

    If you have problems uninstalling Office 2007, read this:

    http://support.Microsoft.com/default.aspx/KB/928218

    How to uninstall manually Office system 2007 if you cannot uninstall it by using the function "Add or Remove Programs".

    For questions of office:

    Office:

    http://www.Microsoft.com/Office/Community/en-us/flyoutoverview.mspx

    Office newsgroups

    http://www.Microsoft.com/Office/Community/en-us/default.mspx?DG=Microsoft.public.Office.misc&lang=en&CR=us

    Discussions of general issues of the Office.

    They will help you with your office questions when repost you in the Office discussion groups above.

    See you soon.

    Mick Murphy - Microsoft partner

  • How to connect the Pavilion to Panasonic th42px80b with windows 8.1

    Thought I had this nailed but the laptop does not recognize the tv as a second monitor.

    Any ideas please?

    Hi Trialsfan,

    Thank you for visiting the Forums HP's Support and welcome. I have read your thread on your HP Pavilion computer and don't read does not correctly when it is attached to the TV. Only, you should be able to have the HDMI cable connected from the computer to the TV.

    and try to touch the key FN and F4 for transferring the image of the computer to the TV while the HDMI cable is connected. This is a document aboutconnecting a TVto your laptop.

    I hope this helps.

    Thank you.

  • Connect the keyboard and mouse wireless with new transmitter/receiver

    Hello.

    I have a keyboard and wireless Microsoft mouse 2000 but the transceiver does not seem to work.

    I also have another transmitter/receiver (same model) which belongs to Microsoft Wireless Keyboard and Mouse 5000, so my question is:

    is there a way to use the wireless 2000 with this new transceiver box? How can I change the transceiver settings so that it finds the keyboard and mouse?

    Thanks in advance

    You can not.

    The receiver is synchronized with the keyboard and the mouse in the factory and cannot be re paired at the level of the Office

  • My PPT file that I normally convert to Word usually goes from 600 KB in size similar to the word PPT, now it keeps converting a file from Word 8 200 Ko... Please help :)

    For 7 years, I create Powerpoint presentations then go file/send to / Microsoft Word and using Notes with blank lines options.  If the TPP is 605KO the Word document is quite small.  But for some reason some today - it is by my file 605KO turn into a 8 200 KB Word document.  It is slow and massive.  My big problem is that I take the Word file and merging with others to make a manual.  I talked to my Service Desk at the office and they can not help it is urgent... So I am hoping that someone out there knows a quick fix.  Assistance Service has tried to make the detection and repair, but it didn't matter.  I'll take suggestions :)

    Thank you for visiting the Microsoft answers community.

    The question you have posted is related to Microsoft Word and would be better suited in the Group Discussion in Microsoft Word. Please visit this link to find a community that will provide the support you want.

    Lisa
    Microsoft Answers Support Engineer
    Visit our Microsoft answers feedback Forum and let us know what you think.

  • Meaning of the word beta?

    Hello

    On page reference following languages (http://help.adobe.com/en_US/FlashPlatform/beta/reference/actionscript/3/fl/motion/Animator FactoryBase.html), the word beta is associated with the AnimatorFactoryBase class.

    Can you assume that the class is not yet fully functional?

    When I click with the right button on a functional movement in Flash Tween and select "Copy motion as Actionscript 3.0", the code does NOT at all (if no error).

    Kind regards

    Ron

    I presume it's beta when the document you are referring was published, but not on the most - see http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/fl/motion/AnimatorFacto ryBase.html

  • How to get the string (specified by row and column) of txt file with labview

    Hello world

    How to get the string (specified by row and column) of txt file with labview

    THX

    As far as I know, a text file has no column.  Be more specific.  Do you mean something like the 5th word on line 4, where the words are separated by a space, and lines are separated by a newline character?  You can read from the spreadsheet String function and set the delimiter to a space.  This will produce a 2D channels table.  Then use the table to index and give the line number and column number.

  • connecting the iphone 6 with the Mac Pro for messages

    My iPhone 6 is not bind properly with my Mac Pro for Messages.  When sending a message from the Mac Pro, the message will be displayed on the iPhone immediately, but this is not always appear as "sent" or "delivered" on the Mac; It just shows an incomplete treatment green line at the top of the message on the Mac bar.  This occurs only with SMS messages.

    I followed the instructions to connect the two devices using my Yahoo account, but it still does not work properly.

    Any ideas?

    Make sure that your iPhone software is up-to-date.

    Tap Settings > general > software update

    The latest iOS version is 9.3.4.

  • Why Web site navigation words appear as small rectangles, wavy lines / w when on Explorer, they show that the words?

    When I use Mozilla browsing different sites passwords don't show - on the contrary, there is a small rectangle with wavy instead of their lines. I tried Internet Explorer on the same sites, and the words appear. I prefer Mozilla and don't want to have to rely on the MSN browser. Can you tell me how I can get the same results with your browser I get with them?

    Thank you everyone - it worked. Never would have guessed. Appreciate the help!

  • HP Pavilion HPE h8 - 1260t CTO: stuck at the screen with the words "Press ESC for Boot Menu" on the bottom

    I unplugged the graphics card to clean dust. After that I connected everything again, he stuck to the blue screen with the words "Press ESC for Boot Menu" on the bottom. If I press ESC at the beginning, it will go to a black screen and it will show the basic information of the computer (information about the processor and memory). It also show this black screen, "Press ESC for Boot Menu" on the bottom and it will show "Start menu" in the lower right corner. If I press F8 at the beginning, it's going to be the same black screen, but it does not "Start menu" show in the lower right. If I press F10 at the beginning, it will go to the same black screen, and it will show "setup" in the lower right. Can someone help me solve this problem? And thank you very much!

    So I suggest to look at the following and try to 'Clear the CMOS settings' as described at the bottom of the page: HP and Compaq Desktop PCs - specifications of the motherboard, IPISB-CH2 (Chicago).  Then see if there is no change at all.  If there is no improvement, then use the following http://www.hp.com/contacthp, fill in the form, create a folder for your question and then use the information to contact HP.

  • the analysis of a word table of ms with different numbers of columns for each row

    I'm reading in a MS Word table that contains 20 lines, each with a different number of columns.  I have to iterate over each line then I iterate on each column of the row and read his text.  I don't know a way to find out how to stop an iteration on the columns.  Is a property or a method which tells you the number of columns in a specific line for a table in MS Word?

    ID says:

    I'm reading in a MS Word table that contains 20 lines, each with a different number of columns.  I have to iterate over each line then I iterate on each column of the row and read his text.  I don't know a way to find out how to stop an iteration on the columns.  Is a property or a method which tells you the number of columns in a specific line for a table in MS Word?

    For each row, use the count property of cells. Since there a number of subject lines is the number of columns.

    Ben64

  • all my prints are coming out with the word 'project '.

    I use an iMac with Mac OS 10.6 (snow leopard).

    I to printers connected by wi - fi: Office Jet Pro 8500 has more and LaseJet CP1525nw color.

    With the 8500 has more each impression is correct.

    But with the CP1525nw, each print comes out with the word 'PROJECT', no matter the settings (the option "watermark" is already 'OFF' on the print settings, etc.).

    This happens not only with the microsoft office for Mac (Word or Excel), but all prints (for example, work online with my bank account, if I chose to print a statement, he will come out with the word "PROJECT". Even if I save it in PDF format and open the PDF file using the preview or any other PDF reader, it always come out with the word "PROJECT").

    How can I solve this problem?

    Hello again,
    I just ran across this interesting link that another user had the same problem and was able to resolve with an update. The first link below is where you can get updates for your printer. The second is the other thread. Check below and good luck!

    http://goo.GL/rVCXh

    http://goo.GL/0vJxc

Maybe you are looking for

  • Stream for computer laptop 11-r005na: new netbook installation is not complete.

    Try to restart does not allow me to log in, keeps telling me a wrong password, (do not think that I put one yet) think its microsoft, which is the origin of the problem, he said: I need a removable media, what the hell is one of them. I'm already on

  • Satellite L855 cut 3 times due to overheating

    Hi, me too I have concerns on my Toshiba L855 and total heat produced. I bought a portable high spec that I use for intensive several software and browser sessions. Tonight I got to 5 GB used of 8 GB, 15% of CPU, disk writing 25% average The temperat

  • I am trying to speed up my computer. How can I do this

    My computer is runn so slow that it takes literally minuets to open it.       My games do not work smoothly they run with a jerky movement and there is a delay in all. ?

  • pushscreen

    Hello I am Manager of a navigation, click the labelfield during the click on this label pushes TSTC screen field. I don't know where area thelabel in the TSTC is not getting added to the container. I'm new to development. I enclose my code below, ple

  • Operating speed of 1333 MHz memory

    At startup, I see 1333 MHz for the speed of the memory instead of 1600 MHz I have 4 DIMM (16 G DDR3 - 1600 MHz) into the slots A0 and B0, E0 F0. I thought that I have disabled all the hiding power of shit. I can check some other settings? Thank you