How to get bounds of bounding box of text item.

Hi all,
I am trying to get the bounds of bounding box of paragraph text item. I found the following link,
the coordinate of a bounding box is the same as the layer's coordinate?
But the solution doesn't work for me. It gives me the layer's bound every time i.e. the bounds of actual text.
Can someone have any idea how to accomplish this?
Thanks.

It's a known "not trivial". You have layer.textItem.width/height, but they don't always report correct values. I.e. if the layer or doc has been resized, those values are missing scale multipliers. Worse it's works differently wrong in different versions of CC and Mac/Win. What I use is below (with some utility functions missing), but it's just CC 2012 and 2014 (CS6 is just bounds).
Alternatively you can get this stuff on Action Manager only, but I'm not familiar enough and let other comment on it.
Photoshop = {
  getTextExtents: function (layer) {
  if (layer && layer.textItem) {
  var text_item = layer.textItem
  if (Photoshop.isCC2014() || (Photoshop.isMac() && Photoshop.isCC2012())) { // in mac the newer method is correct also in CC2012
  return Photoshop._getTextExtentsCC2014(text_item)
  } else if (Photoshop.isCC2012()) {
  return Photoshop._getTextExtentsCC2012(text_item)
  } else {
  return Photoshop._getTextExtentsCS6(text_item)
  _getTextExtentsCC2014: function (text_item) {
  app.activeDocument.activeLayer = text_item.parent
  var ref = new ActionReference()
  ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") )
  var action = executeActionGet(ref)
  //Photoshop._debugActionKeys(action)
  var textKey = action.getObjectValue(stringIDToTypeID('textKey'))
  var bounds = textKey.getObjectValue(stringIDToTypeID('bounds'))
  var width = bounds.getUnitDoubleValue (stringIDToTypeID('right'))
  var height = bounds.getUnitDoubleValue (stringIDToTypeID('bottom'))
  var x_scale = 1
  var y_scale = 1
  if (textKey.hasKey(stringIDToTypeID('transform'))) { 
  var transform = textKey.getObjectValue(stringIDToTypeID('transform'))
  x_scale = transform.getUnitDoubleValue (stringIDToTypeID('xx'))
  y_scale = transform.getUnitDoubleValue (stringIDToTypeID('yy'))
  x_scale *= width / text_item.width
  y_scale *= height / text_item.height
  return {
  x:Math.round(text_item.position[0]),
  y:Math.round(text_item.position[1]),
  width:Math.round(width*x_scale),
  height:Math.round(height*y_scale) }
  _getTextExtentsCC2012: function(text_item) {
  app.activeDocument.activeLayer = text_item.parent
  var ref = new ActionReference()
  ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") )
  var action = executeActionGet(ref)
  var textKey = action.getObjectValue(stringIDToTypeID('textKey'))
  //Photoshop._debugActionKeys(textKey)
  var bounds = textKey.getObjectValue(stringIDToTypeID('bounds')) 
  var width = bounds.getUnitDoubleValue (stringIDToTypeID('right')) 
  var height = bounds.getUnitDoubleValue (stringIDToTypeID('bottom')) 
  var x_scale = 1
  var y_scale = 1
  if (textKey.hasKey(stringIDToTypeID('transform'))) { 
  var transform = textKey.getObjectValue(stringIDToTypeID('transform'))
  x_scale = transform.getUnitDoubleValue (stringIDToTypeID('xx'))
  y_scale = transform.getUnitDoubleValue (stringIDToTypeID('yy'))
  return {
  x:Math.round(text_item.position[0]),
  y:Math.round(text_item.position[1]),
  width:Math.round(width*x_scale),
  height:Math.round(height*y_scale)
  _getTextExtentsCS6: function (text_item) {
  var layer = text_item.parent
  return {
  x:Photoshop.getLayerLeft(layer),
  y:Photoshop.getLayerBottom(layer),
  width:Photoshop.getLayerWidth(layer),
  height:Photoshop.getLayerHeight(layer)

Similar Messages

  • How to get title in Dialog box

    How to get title in Dialog box like "Adobe® Connect™ "

    Works for me. What happened when you tried?
    <pre style="
    font-family: Monaco, 'Courier New', Courier, monospace;
    font-size: 10px;
    font-weight: normal;
    margin: 0px;
    padding: 5px;
    border: 1px solid #000000;
    width: 720px;
    color: #000000;
    background-color: #E6E6EE;
    overflow: auto;"
    title="this text can be pasted into the AppleScript Editor">
    tell application "Finder" to display dialog "I need ® or ™ in dialog box text" with title "I need ® or ™ in dialog box text" buttons {"Aha!"} default button 1</pre>

  • How  to get  the  Save  dialouge box  in   SAP Business One

    Hi,
    How  to get the  Save dialouge box in    Button  click  event  in  SAP Business One.
    Thanks,
    Y.

    Hello,
    You would like to display an SaveFileDialog box?
    may follow this thread, and you can find a sourcecode in vb.net and c# inside (for open dialog, but it is the similar...)
    Regards
    János

  • How to get System status Check Boxes into Query selection screen

    Dear experts,
    Pleas help in knowing how to get System status Check Boxes into quick view query (SQVI), selectionscreen.
    Regards
    Jogeswara Rao
    Edited by: K Jogeswara Rao on Jul 6, 2010 7:26 PM

    Problem solved through other Forum
    (Checkboxes not possible, some alternative solution to my requirement found)

  • How will get  to the transaction box. directley(shourtcut)

    hi
    how will get  to the transaction box. directley(shourtcut)?

    Hello,
    for SAP GUI for Windows, it is Ctrl + / .
    For list of keyboard shortcuts, see menu item "Help for SAP GUI" in the menu shown when clicking the right most toolbar button.
    for SAP GUI for Java, it is Ctrl + T (Cmd + T on Mac).
    For keyboard shortcuts, see the menu items in the menus  with the icons on the right.
    Best regards
    Rolf-Martin

  • How to get query result in comma dilimited text or excel file?

    Does anybody know how to get query results in comma delimited
    text file or excel file, I tried spool abc.txt, but the result
    showed some ------ lines
    Thanks

    Try doing this in your sql scripts
    set heading off
    set pagesize 0
    set linesize 4000
    set feedback off
    set verify off
    set trimespace on
    set colsep ","
    spool output.txt
    select * from dual (or whatever you are querying
    spool off
    There may be a couple other set statement that you could add but
    this should get you started in the right direction

  • How to get Mountain Lion Spotlight to find text in CSV files?

    Does anyone know how to get Mountain Lion Spotlight to find text in CSV Files? Spotlight worked flawlessly with Snow Leopard on my last MAC but with Mountain Lion it doesn't recognize CSV Files. I have researched this extensively and haven't found any solution but I really believe there must be many others who have the same problem. I even contacted Apple's Genius Bar which was of no help whatsoever, they couldn't even tell me why Spotlight wasn't finding text in CSV Files, i.e., function dropped by Apple, bug, etc.
    Thru research I found that if the CSV Files are converted to 'Plain Text Files' Spotlight will find text inside of the files but I typically save my spreadsheets as CSV Files and don't want to have to convert them to Plain Text Files just so Spotlight will search them.
    I appreciate any help you can give.
    Joel

    I should have mentioned earlier that I do NOT have any exclusions set under the Spotlight Privacy tab, however, I did move one of the folders that contains CSV Files in then back out of the Privacy tab to try and get Spotlight to index the folder, but to no avail.
    I have a second Admin account and tried to find text in CSV Files while in that account, again to no avail. I also tried upgrading to Mountain Lion 10.8.4 to see if it might fix the problem, but no soap.
    Below is a screenshot of the Systems Preferences/Library/Spotlight/RichText.mdimporter/ file and I don't even see where Spotlight is setup to find CSV Files on my computer, very confusing but thanks again for your input.

  • How to show value of COUNT_QUERY in a text Item?

    please tell me how to show value of COUNT_QUERY in a text Item?

    If you look a bit further down the thread Rosario posted, you might find the method DanielLiang posted to be easier to implement for you.
    you can use calculation:
    example :
    Database Data Block: block1 ( Query All Records : Yes )
    not Database Data Block : block2 (Single Record : Yes)
    block2 has a text item (number) ,it calculation property :
    calculation mode : summary
    summary function : count
    summarized block : block1
    summarized item : item1(block1's item)

  • How to get rid of black box borders that occur around text

    When ever I type ANYTHING in emails, Pages, I get this irritating black box that shows up around paragraphs.  How do I get rid of this once and FOREVER?

    Press the key combination command-F5 to deactivate VoiceOver. If that doesn't work, proceed as follows.
    For OS X 10.7: From the menu bar, select
     ▹ System Preferences ▹ Universal Access ▹ Seeing ▹ VoiceOver: Off
    For OS X 10.8: Select
     ▹ System Preferences ▹ Accessibility ▹ VoiceOver
    and uncheck the box labeled Enable VoiceOver.

  • How to get rid of navigation box

    Hi guys i would like to know how to get rid of the navigation box in iphoto.  i have mountain lion and the most updated version of iLife. 
    this is the box i am reffering to . 

    Really? You asked a specific question and got a specific answer. Turns out you had a different question...
    You can't.
    Regards
    TD

  • How to get the cursor position in the text edit box?

    Hi, all.
    I want to get the cursor position in the text edit box
    to insert some data.
    But I don't know how to get.
    Can someone give me some advice?
    BestRegard.
    Miya.

    Hi Miya,
    Write your own textSelectionSuite for this.
    and use ITextTarget->GetRange() function.
    Thanks and Regards,
    Yopangjo.

  • How to get Open/Save Dialogue box

    Hi,
    I need to get open/save dialogue box while downloading a file (from JSP).
    One way which I am currently using is on click of the button pass control to servlet and in servlet using the following code:
    /**.....Some Code */
    response.setContentType("application/csv");
    response.setHeader("Content-Disposition", "attachment; filename=" + filename);
    /**.....Some Code */But I am wondering is there any way I can do the same without passing the control to Servlet? On clicking the button in JSP, is there is any possibilty to get the Open/Save dialogue box directly.
    Thanks
    Arun

    without passing the control to Servlet?Why?
    In HTTP you can send the response only once.The application where i have this requirement is an old one. In the application, I have there are some screens, whose control never goes to Servlet.
    TO be more precise, 2 pages one HTML and another JSP. And the file to be downloaded is created when JSP is called from HTML page. And there is no interaction with Servlet. The JSP inturn calls a method in Java file (which is not a Servlet) and gets all the details including the file to be downloaded.
    I have used window.open() to download the file(in JSP) in order to have Open/Save dialogue box.
    But the approach is working fine in Windows XP systems but not in Windows2000. In Win00 machines it is directly opening the file in popup without giving the user any option for Open/Save.
    Please let me know your suggestion on this.
    Thanks

  • How to get the "delete" check box back?

    Hi Guys,
    I just used the "Migrate to Interactive Report" feature. After doing so, the check box is gone that is used to indicate rows to delete. A copy of the region is marked as "disabled" and the check box is still there, but it's not in the newly created region. Without that check box, my page has no way to delete rows. How do I add the check box to the new Interactive Report region? I'd rather not re-create the page from scratch.
    Thanks,
    Kim
    P.S. I'm using Apex 4.1 and Oracle 11g xe - all running on Windows 7.

    How about something like this? Instead of a check box add a new column with a delete image, you can use something like delete.gif (#IMAGE_PREFIX#delete.gif). The downside is that will be deleting one at a time, but in my experience this may not be an issue.
    Add a hidden item to hold the ID of the row your want to delete. We'll call it P1_ID.
    The new column with the delete image will need to "branch" to a URL and use this code (ALL in one single line)
    apex.confirm("Are you sure you want to delete?", {
      request:"DELETE_ROW",
      set:{"P1_ID":#ID#}
      });Then add a page process that fires when the request is DELETE_ROW
    Would probably look something like this:
    delete from some_table where id = :P1_ID;
    A similar technique can be used for checkboxes, but it's a little more advanced as you need to loop through the selections.
    Oh and add the column to the IR you don't really need to select anything. Or better yet, you could re-use the ID column of the report if you have one as your delete column. The #ID# on the code above needs to be the name of your column. So if your column is EMPNO the above would be #EMPNO# instead of #ID#.
    Hope this helps.
    -Jorge

  • How to get hint in password box or password character in Phone Text box

    I want to get hint in PasswordBox or password character(*) in PhoneTextBox in windows phone 8 application. I have seen the solution that uses a password box and text block and then control it onFocus.But I want to use a single input field.Can anyone help?

    I'm sorry, but I don't understand what you're asking for.
    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.
    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined
    objects and unknown namespaces.

  • How to get Case Sensitive Check Box at Search Page

    Hi Everyone,
    I am trying to get case sensitive check box at the bottom of the search page, for that we have to set any propert or we ahve to do anything else.
    Please Help!!!!
    Thanks,
    Amit

    Have never really thought of it. One thing you need to do is set the Case Insesitive Searching Option correclty in PeopleTools Options. I can't find any other setings. But it might have to do with the fields that are on your Search record. My guess is if any of the Search Fields are of type Character and format Mixedcase then the Case Sensitive check box will be displayed automatically.

Maybe you are looking for