How to determine the size of selected text

Hi
I'd like to draw a box around some selected text (a textRange), however I can't figure out how to detemine the size or position of the text.  The overall size of a textFrame is possible to find (not sure about position), but when you've got just a few characters selected I don't see any way to get the size or position.  Any ideas?

You may have to do some testing of your own with this… I tested here and 'think' its OK but could have overlooked something… For me the best way to get this data is to outline the type store the info in a variable then undo the outlining process… You can then continue your script with info in hand… An example that draws a box over each selected character… I cheated with only the one text frame but you can resolve that? You could easy use math.min & math.max to draw around an array of bounds… I didn't bother with a load of tests it expects selected text range as is… have fun…
#target Illustrator
textBoxer();
function textBoxer() {
          var i, doc, sel, start, end, spaceB4, spaceInc, mat, grp, count, boxes;
          doc = app.activeDocument;
          sel = doc.selection;
          start = sel.characterOffset-1; // Not zero based…
          end = start + sel.length;
          doc.selection = null;
          spaceB4 = doc.textFrames[0].contents.substr( 0, start );  // Cheated here you will need to find parent frame…
          mat = spaceB4.match( /\s/g ); // Resolve the lost of white space characters before selection
          mat != null ? spaceB4 = mat.length : spaceB4 = 0;
          spaceInc = doc.textFrames[0].contents.substr( 0, end );  // Here too…
          mat = spaceInc.match( /\s/g ); // Resolve the lost of white space characters in selection
          mat != null ? spaceInc = mat.length : spaceInc = 0;
          grp = doc.textFrames[0].createOutline(); // Items in new group are last to first order
          app.redraw();
          count = grp.compoundPathItems.length;
          boxes = Array();
          for ( i = 0; i < count; i++ ) {
                    boxes.push( grp.compoundPathItems[i].visibleBounds );
          boxes.reverse(); // Fix the order
          app.undo(); // Bounce back…
          app.redraw();
          start = start - spaceB4;
          end = end - spaceInc;
          for ( i = start; i < end; i++ ) {
                              doc.pathItems.rectangle( boxes[i][1], boxes[i][0], boxes[i][2]-boxes[i][0], -boxes[i][3]- -boxes[i][1], false );
          app.redraw();

Similar Messages

  • How to determine the size of an InputStream??

    Hello,
    I need to get the size of an inputstream. In fact, I am working with java.nio.channels and need to tranfer a file from within a Jar to the FileSystem.
    I have created a ReadableByteChannel from the jar resource, and a FileChannel from the FileSystem destination. The problem is that to use the FileChannel .tranferFrom(..) I need the size of the src file. But, ReadableByteChannel has no size() method.
    How can I determine the size of this InputStream??
    advanced Thanx
    here is code:
    private void copyResourcesToFileSystem(){
              try{
                        String name = getFileName(); // gets the name
                        ReadableByteChannel srcChannel =
                             Channels.newChannel(this.getClass().getClassLoader().getResourceAsStream(("dtd/"+name)));
                        File newFile = new File(TempDirCreator.getXmlDir(),name);
                        FileChannel dstChannel = new FileOutputStream(newFile).getChannel();
                        dstChannel.transferFrom(srcChannel, 0, srcChannel.size());  // doesn't work -- there is no ReadableBC.size()
                        // lets close the show
                        srcChannel.close();
                        dstChannel.close();
              }catch(IOException x){x.printStackTrace();}
              catch(Exception ex){ex.printStackTrace();}
         }

    In general the "size of an InputStream" is a meaningless concept. It's possible to have an InputStream that never terminates. So if you can't get a size from whatever you're reading from, you're out of luck.
    I missed where you explained why you need the size. I've never felt the need to know how many bytes would be passing through my code when copying from input to output.

  • How to determine the size (in pixels) of the current mode

    Hello.
    I am looking for a was to determine the size (horizontal and vertical pixels) of the current mode (SAPGUI window). I have already looked through the methods provided by class CL_GUI_CFW...
    CL_GUI_CFW=>GET_METRIC_FACTORS provides the size of you display (i.e. 1600 x 1200 pixels) and some other information I am not able to interprete.
    Futhermore I have had a look at the Methods CL_GUI_CFW=>COMPUTEPIXEL, but I don´t know how to use them.
    Has anybody of you any experiences in this topic? I would be grateful ...
    MIKE

    Sorry Manoj,
    but i didn´t find out, why these programs should be able to solve my issue. They just display a picture using the CL_GUI_PICTURE control.
    I am looking fo a way to resize a given control to the very maximum, so that it fills the whole SAPGUI window!
    Thanks anyway...
    MIKE

  • How to determine the size of the JVM process?

    Hi,
    How to determine the total process size of the JVM process (that includes Heap, Non Heap and Native memory)?
    Is there any command to obtain this value on Solaris (for Sun JVM)?
    I refer the process size to http://middlewaremagic.com/weblogic/wp-content/uploads/2010/11/Java_Heap_Diagram_12.jpg) here.
    Many thanks for your help in advance!

    Hi,
    Make sure that Total Heap + Native memory will be consider as total Memory.
    That means in 32 bit you will have only at most 4 GB for process + additional 2 GB for OS.
    So let assume if you have 4GM RAM then out of the 4GB you can allocate 2GB as Heap and 512m as Perm in case of Hot spot and remaining will be consider as Native memory.
    But in case of 64 bit will change you will have good amount of the memory so you can use plenty of Heap and Perm size.
    Still if you have query let me know.
    Regards,
    Kal

  • How to determine the size of an iMovie09 project?

    Hello:
    I recently created a nice video of about 2 hours in iMovie09. I "shared" it to iDVD but it was about 10% too big to burn. I went back to iMovie09 and removed some time to make the project smaller but how can I determine the size of my iMovie09 projects before I send them to iDVD? I know that both time and audio will affect the size of the iMovie09 project so the time of the video is not necessarily an accurate indicator.
    Thanks!

    Welcome to iMovie Discussions.
    As long as your movie is under about 1hr 50 minutes it should fit on a DVD.
    The thing which determines how much time is available on your DVD is usually the complexity of any Menus which you add in iDVD.
    With a simple Menu, which may "eat up" 10 mins of space, you should have room for 1h 50mins of movie.
    With complex, multi-level menus, your movie running time may be reduced by about 25 mins, or possibly more.
    Keep menus simple, and you should have space for about 1hr 50mins. It's always running time which counts, NOT "size" (in GB) of your movie.

  • How to determine the size of recorded iPhone-video?

    After I record a video with my iPhone 4S, how can I tell what the size of that video file is?

    Welcome to iMovie Discussions.
    As long as your movie is under about 1hr 50 minutes it should fit on a DVD.
    The thing which determines how much time is available on your DVD is usually the complexity of any Menus which you add in iDVD.
    With a simple Menu, which may "eat up" 10 mins of space, you should have room for 1h 50mins of movie.
    With complex, multi-level menus, your movie running time may be reduced by about 25 mins, or possibly more.
    Keep menus simple, and you should have space for about 1hr 50mins. It's always running time which counts, NOT "size" (in GB) of your movie.

  • ComboBox Problem to change the size of selected text in JTextPane.

    hi 2 all!
    I have a problem in combo box actions, when i change the item in the combo its set is not set at that time but that action is performed when next action is taken, i have used combobox.setAction(new StyledEditorKit.FontSizeAction(" click", 12);) command to set the size of the selected text
    Plz suggest the solution also if possible,plz provide some code for this
    Action action1 = new StyledEditorKit.FontSizeAction(
                                                 "double click", 12);
                                       Action action2 = new StyledEditorKit.FontSizeAction(
                                                 "double click", 14);
                                       Action action3 = new StyledEditorKit.FontSizeAction(
                                                 "double click", 18);
    s2 = (String) cb7.getSelectedItem();
                                       if (s2.equals("Small")) {
                                            cb7.setAction(action1);
                                            e1.setSource(cb7);
                                                      } else
                                       if (s2.equals("Medium")) {
                                            cb7.setAction(action2);
                                            e1.setSource(cb7);
                                                                          } else if (s2.equals("Large")) {
                                            cb7.setAction(action3);
                                            // e1.setSource(cb7);
    when i chooze any combobox item then according to that item i set the Action on ComboBox but that action is not working properly on the selected text in the JTextPane..means selected text in JText Pane is not changes its Size according to the comboBox selected ITEM.
    PLZ plzzzzzzzzzz help me:((.i will be thankfull to u.
    thanx in advance..

    this code is not working properly according to the action i set on comboBox.Thats correct, the setAction() method is used to invoke an existing Action on the combo box, not create a new Action.
    What you need to do is have a single action that uses the information from the item that was selected to build a dynamic Action to change the font. Something like:
    public void actionPerformed(ActionEvent e)
         JComboBox comboBox = (JComboBox)e.getSource();
         int fontSize = Integer.parseInt( comboBox.getSelectedItem().toString() );
         Action fontAction = new StyledEditorKit.FontSizeAction("size", fontSize);
         fontAction.actionPerformed(null);
    }

  • How to determine the size of a flat file attachment in a mail sender cc?

    Hi
    I use PI 7.11
    I have a scenario where a flat file attachment is being picked up by a MailSender adapter and if the size of the attached flat file is larger that 500 bytes the receiver is A and if the attachment is less that 500 bytes the receiver is B.
    I have checked the Context Object list in the Conditions section of Receiver Determination, and it seems, that only the file adapter allows for validation on the file size.
    I contemplated an extended receiver determination but the attachment is a flat file which just needs to be passed thru without being converted to an XML document, so my source document is not of XML format.
    An other but not very nice way would be to use an intermediate folder to drop the attachment in and from there use a file sender adapter and thus get access to the filesize attribute in my receiver determination, but I would like to avoid this.
    Any suggestions?
    BR MIkael

    Hi
    I have decided to make a module, where I plan to place the size of the attachment in the Dynamic Configuration variable "ProcessStep", but to my surprise, it seems that all the context objects in the receiver determination condition section are of type String and hence it is not possible to make a condition where I test for whether the value is smaller than say 500!? Only equal, NOT equal and LIKE are available (EX seems to be disabled as this probably only works in an xpath.
    Would one way be to use the xpath expression like this ns1:Main\ProcessStep < 500 where ns1: http://sap.com/xi/XI/System?
    MIkael

  • How to calculate the size of a Text Field?

    Is there a way to calculate the number of characters allow in a Text Field? If a uer type over this number of characters a popup window will appear telling the user that he/she has too much texts. Of course I could use the Limit Length, but I have to manually put texts into this text field and count them. If the Limit Lenth number is too small, the texts does not fill the whole text field. If the number is too big then the texts does not get printed.

    There would be no easy way to do this. You'd need to do some pretty fancy calculations, it would all depend on the size of the field, what font is used, the font size, whether it's been bolded, underlined, italicized, etc etc.
    What are you trying to accomplish? Make it so that the user can type in the text field until it fills and then have it stop without scroll bars coming up to allow him to keep typing?
    Chris
    Adobe Enterprise Developer Support

  • How to determine the size of client in sap system

    Dear Exports,
                         Pls suggest me how we can check the size of the client in oue sap system.
    Thanks in advance.

    Hi Amit,
    If you are not able to check the note 118823 or you can't able to find the solution. Just start client copy in test mode, there you can get the size of the client then you can cancel the client copy(which is in test mode).
    Hope it will resolve your doubt.
    Thanks
    Kishore

  • How to determine the size of The Entire iPhoto Library

    Hello,
    Can someone tell me if its possible to determine the entire size of my iPhoto library?
    Thanks

    The size of the Library when you do a "get info" for it in the finder will be larger because it includes all the data files, thumbnail files, originals and edited originals.
    The size of the library when you do a "get info" of the library while within iPhoto will just give you the size of all the images.
    As for my avatar I just did this;
    I am not sure what picture you meant, but yes I should be there somewhere and I have 2 children and one grand daughter.
    The sausage making was lots of fun.
    ☺Lori

  • How to increase the length of selection texts

    Hi to all..
    please do a favour......
    My problem is ,I am not able to enter long text in SELECTION TEXTS after certain length ,but we need long texts .So what I have to do to enter long texts..
    plz respond

    Hi Suribabu,
    In SE63 We can increase the length of the text.
    There is one option called Praposal,Edit Icon, There you can increase the length Max 255(see the Data element LXEUNITLIN) of the selection text.
    Regards
    Bhavani

  • How to determine the size of a file on application server

    Hello,
    using open dataset I have created a file on the application server and have put some data into the file.
    Now I want to know the size of this file.
    Is there a function module to do this ?
    Best regards
    Michael

    Hi,
    Use Function module   'EPS_GET_FILE_ATTRIBUTES'
    DATA fsize TYPE epsf-epsfilsiz.
    CALL FUNCTION 'EPS_GET_FILE_ATTRIBUTES'
      EXPORTING
        file_name =     " here provide filename
        dir_name  =    "  here provide directory
      IMPORTING
        file_size = fsize.
    WRITE: 'File size' , fsize.
    Regards,
    Ravi

  • How to increase the length of selection text

    hi All,
    I have a requirement where the select option text is longer then the usual size.
    I tried to use the selection screen comment but it is not coming in the same line.
    Kindly suggest on this.
    Select-options:s_st_obj FOR hrp1001-objid NO INTERVALS
    here s_st_obj text is Object ( PERNR / Position id / Org.id)

    Hi,
    I think not able to display all text, try to delete the spaces between words
    Object(PERNR/Pos id/Org.id)
    Regards,
    Sunil

  • How to determine the field size

    I am going to make a multiplatform application that hopefully
    will run on linux and windows 2000.If the os is 2000, then I will use
    vb.net/aspx else I'll use java servlets. I make the connection
    to the web server ( through HTTP) not directly to database server.
    So, the resultset will be stored in the String object. The columns
    will be separated by delimeter. Our problem is how to determine
    the size and type of the fields of mssql,oracle and postgres database
    so that we can include it in the String object.
    Ex.
    String sResultSet=new String();
    ResultSet rs=statement.executeQuery(sSQL);
    while(rs.next()){
    sResultset=sResultSet + rs.getString(field1) + "||" + rs.getString(field2) + "||";
    vertical bars acts as delimeter
    supposedly this is the code:
    sResultset=sResultSet + rs.getString(field1) +"_" + rs.getFieldType() + "_"+
    rs.getFieldSize() + "||" + rs.getString(field2) +"_" + rs.getFieldType() + "_"+
    rs.getFieldSize() + "||";
    supposedly this is the code if rs.getFieldType() and rs.getFieldSize() methods are existing
    Anyone can give me an idea how to get the field type and field size of the database?
    thanks in advance

    Yes, but I dont know how to do it.
    Can you give me an example of using it.
    Thanks in advance

Maybe you are looking for

  • Get All images from a website and put them in a listbox.

    Hi Everyone, I am new to Java Programming. I wanted to know if there is a way to get all the images in a website and put them in a listbox. And if an item is clicked in list box, view it in a picturebox.

  • IBook G4 will not recognize Super Drive

    There is a DVD stuck in my optical Super Drive. The drive now is no longer recognized in the system profiler either. There is no noise at all coming from the drive on startup or when an eject is attempted. This is a second-hand iBook so unfortunately

  • Contacts crashing when I try to "find duplicates". Please help!

    Process:         Contacts [285] Path:            /Applications/Contacts.app/Contents/MacOS/Contacts Identifier:      com.apple.AddressBook Version:         8.0 (1365) Build Info:      AddressBook_executables-1365000000000000~1 Code Type:       X86-64

  • Where's the download link for X230 Windows 8 beta driver?

    I am trying to download the Media Card Reader Driver for Windows 8 Beta for my new X230i, but there is no download link on the driver details page as below: http://support.lenovo.com/en_US/downloads/detail.page?&DocID=DS030731 Can anybody let me know

  • False Positives?

    A personal friend owns a local heating and air company.  He had an IT friend re-do his website recently.  My wife noticed it and had me take a look.  It's simple and clean and in Firefox text doesn't overlap when one zooms text only.  I took a look a