How do I find the position of a single character on a page?

Hi guys,
I am developing a PDFEditor, but am having trouble implementing the code which finds the location of glyph characters on a page (in device space). I have read the pdf reference on Text, but do not quite understand it.
I have worked out the individual character spacings, but I cannot accurately find the location of the first character .
Here is my current attempt:
float y = CGPDFPageGetBoxRect([current_page pageReference], kCGPDFCropBox).size.height-current_matrix_position.y;
float x = current_matrix_position.x;
float xa = a * x + c * y + e;
float ya = b * x + d * y + f;
text_position = [NSValue valueWithCGRect: CGRectMake(xa, ya, 15, d)];
(where text_position is the location of the start character in device space. a,b,c etc come from the Tm operator.
current_matrix_position is set as a point (e,f) from the cm operator.)
This code seems to work with some PDF files:
But does not work with others:
(Note there is text in the box above the blue which cannot be disclosed for reasons...)
Is there something I am missing (like another operator?) or is my formula completely wrong.
Your help would be greatly appreciated

Hi Irosenth,
I have been reading the spec and trying to understand it for several weeks. Unfortunately, I am still confused with how to find the coordinates of the text.
>> You need to parse the content stream(s) that are associated with the page and
I have done this. My program finds both the cm operator, the tm operator and the font widths etc. Unfortunately, now that I have all of this information, I am unsure what to do with it.
How do I properly add these two matricies together? I have looked in the spec which describes it as:
x' = a * x + c * y + e
y' = b * x + d * y + f
I tried this and the results worked on some pages, but not on others (several thousand x coordinates out...). I am finding the ISO 32000-1:2008 very confusing in this section.
>> manage what you find there
This is the part I am having major trouble with. Using the coordinate transformation matricies, how can I determine the starting coordinate for the first glyph in a text (BT, ET) on a non-scaled page (so 1 unit = 1 pixel) using the matricies?
Thanks

Similar Messages

  • How can I find the position of a robotic arm with a cFP-CTR card?

    Hello,
    I use a CTR-500 to measure the pulses of 3 encoders.
    The encoders are related to the 3 axis (x,y,z), to which a robotic arm is moving.
    Each encoder has 2 channels (A,B) which go to each pair of Count Inputs of the CTR card.
    When the robotic arm is moving on one axis, the corresponding pair of Count Inputs is increasing, but there is a phase between the one Count Input and the second one. What is more, the Count Inputs do not decrease when the robotic arm is moving to the other direction, but they still increase.
    So, I cannot find easily the position of the robotic arm.
    What I have done, is to try finding the position, by using only one Counter Input for each axis. This means that I use the value of the encoder as a counter, and I calculate the position with some software tricks. But for some reason, it does not work properly.
    I have heard that the method I use is not proper. Instead, I have been told that I must use the phase of the 2 Count Inputs, in order to find the direction to which the robotic arm is moving. But, the Count Inputs of the CTR are augmenting in parallel, when the robotic arm is moving forward or backward.
    How can I find the position of the robotic arm, as it is moving like a CNC ?
    Thank you very much.
    Message Edited by nikosfs on 08-21-2009 12:27 PM

    You don't want to use a cFP-CTR-500 card.  What you have are quadrature signals.  You should be using the cFP-QUAD-510.  It has 4 channels that can handle both the A and B signals of a quadrature encoder.  It has the built in circuitry do determine the phasing of A vs. B to know when to count up vs. count down.

  • How do I find the font for a specific character in a textItem?

    I'm writing a script that builds a font list for an open document. While I could have lookup the fonts for the file as a whole, my goal is to iterate over specific layerSets to build a font list from. The issue I'm facing, is that referencing:
    app.fonts[text[n].textItem.font].name
    Only pulls the font name of the first character of the textItem. I need to get the names of all the fonts in the textItem, and while I can successfully loop through each of the letters, they do not have the character attributes associated with them.
    I tried this: app.fonts[text[n].textItem.contents.font].name
    As well as many iterations of a similar idea, and I cannot get it to pull the font name, as it's not an attribute of each character. I apologize if this is a remedial question, but I'm a bit of a novice with javascript in Adobe programs.
    For an example of what I'm trying to acheive, I was easily able to do this in illustrator, by using the following statement:
    fontName = text.characters[j].characterAttributes.textFont.name;
    When placed in a loop, this goes through each font in the text Layer.

    This should get a list of the fonts used in Type Layers in the selected Group.
    // get list of fonts used in the active group;
    // based on code by paul riggott;
    // 2014, use it at your own risk;
    #target "photoshop-70.032"
    if (app.documents.length > 0) {
    var theFonts = main ();
    alert ("the fonts used in the folder " + activeDocument.activeLayer.name + " are"+"\n"+theFonts.join("\n"))
    function main () {
    var theFonts = new Array;
    var someLayerStuff = getActiveLayerIIndex();
    if (someLayerStuff[1] != "layerSectionStart") {return []};
    var aNumber = 0;
    // get number of layers;
    var ref = new ActionReference();
    ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
    var applicationDesc = executeActionGet(ref);
    var theNumber = applicationDesc.getInteger(stringIDToTypeID("numberOfLayers"));
    // determine the start index;
    if (activeDocument.layers[activeDocument.layers.length - 1].isBackgroundLayer == true) {var theStart = someLayerStuff[0] - 2}
    else {var theStart = someLayerStuff[0] - 1};
    for (var p = theStart; p >= 0; p--) {
    try {
    var ref = new ActionReference();
    ref.putIndex( charIDToTypeID( "Lyr " ), p);
    var layerDesc = executeActionGet(ref);
    var layerSet = typeIDToStringID(layerDesc.getEnumerationValue(stringIDToTypeID("layerSection")));
    var isBackground = layerDesc.getBoolean(stringIDToTypeID("background"));
    var theName = layerDesc.getString(stringIDToTypeID('name'));
    // check if group closes;
    if (layerSet == "layerSectionStart") {aNumber++};
    if (layerSet == "layerSectionEnd" && aNumber == 0) {return theFonts};
    if (layerSet == "layerSectionEnd" && aNumber != 0) {aNumber--};
    // if not layer group collect values;
    if (layerSet != "layerSectionEnd" && layerSet != "layerSectionStart" && isBackground != true) {
    var hasText = layerDesc.hasKey(stringIDToTypeID("textKey"));
    if (hasText == true) {
    var textDesc = layerDesc.getObjectValue(stringIDToTypeID('textKey'));
    var paragraphStyle = textDesc.getList(stringIDToTypeID('paragraphStyleRange'));
    var kernRange = textDesc.getList(stringIDToTypeID('kerningRange'));
    var rangeList = textDesc.getList(stringIDToTypeID('textStyleRange'));
    for (var o = 0; o < rangeList.count; o++) {
    var styleDesc = rangeList.getObjectValue(o).getObjectValue(stringIDToTypeID('textStyle'));
    var aFont = styleDesc.getString(stringIDToTypeID('fontPostScriptName'));
    // add to array;
    var theCheck = true;
    for (var n = 0; n < theFonts.length; n++) {
    if (theFonts[n] == aFont) {theCheck = false}
    if (theCheck  == true) {theFonts.push(aFont)}
    catch (e) {};
    return theFonts
    ////// get some stuff from the active layer //////
    function getActiveLayerIIndex () {
    var ref = new ActionReference();
    ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
    var layerDesc = executeActionGet(ref);
    var theIndex = layerDesc.getInteger(stringIDToTypeID("itemIndex"));
    var theSection = typeIDToStringID(layerDesc.getEnumerationValue(stringIDToTypeID("layerSection")));
    var hasText = layerDesc.hasKey(stringIDToTypeID("textKey"));
    return [theIndex, theSection, hasText]

  • How do I find the url for ical

    I had to switch from iphone to droid and now I'm attempting to sync my macbook to my new phone.  How do I find the url for iCal?

    Please see this page:
    http://help.apple.com/icloud/#mm6b1a88ad

  • How to find the position of view in MM02 transaction for coding BDC?

    Hi Guys,
    Is there any FM or BAPI Available to find the position of the view in MM02 transaction. I tried FM SELECTION_VIEWS_FIND. But getting inconsistent results
    i.e Some materials it is giving correct positions but for others i am getting wrong position. So my BDC is getting failed.
    Thanks in advance.
    Vinod.

    Hi,
    data : i_t133a like t133a occurs 0 with header line,
          ch(1),
           viewno(2) type n.
    clear viewno.
      select * from t133a into corresponding fields of table i_t133a
                    where bilds = '21' and guifu like 'SP%'  .
      loop at i_t133a .
        ch = i_t133a-pstat.
        if mara-vpsta na ch .
          delete i_t133a     .
          continue .
        endif .
      endloop.
      sort i_t133a by guifu ascending .
      loop at i_t133a .
        viewno = viewno + 1 .
        if i_t133a-guifu = 'SP01'.  "FOR BASIC DATA1                CHANGES              ACCORDINGLY REFER TABLE T133A TO FIND VTHE VALUE
          exit .
        endif .
      endloop .
    reward if usefull

  • Finding the position of the end of a line in a JTextPane

    I'm trying to make a JTextPane which expands horizontally if the text being typed in it reaches the right hand edge. To do this I need to know the position in the Document of the end of the current line.
    I've managed to write a method which expands the JTextPane vertically using getEndPosition() in AbstractDocument.
    There is an endLineAction in the DefaultEditorKit which moves the Caret to the end of the line but I don't want to move the Caret, just find the position of the end of the line. I did have a method before which moved the Caret to the end of the line, stored the position and moved it back but that wasn't suitable.
    I suspected the answer was to do with the View but I can't figure out how the View relates to the JTextPane or Document.
    Can anyone help?

    Well, personally I don't think its a good idea to keep changing the size of the text pane as text is being typed and I doubt the solution will be as easy as you think.
    As you type the text will automatically wrap so it will be a little late trying to change the width after the text has wrapped, which means you would need to increase the width "before" text is typed. But then you have another problem because you don't know how much to increase the width by since a single character could be typed or a string of text could be pasted into the text area (people always forget about pasting when doing stuff like this).
    Also if text is removed you would need to iterate through all the line to find the longest line and reset the width.
    Anyway the only way to know the width would be to play with the modelToView() method. If you want to find the end of the current line then you can use the Element.
    Check out my [Text Utilities|http://www.camick.com/java/blog.html?name=text-utilities] class which might give you some ideas on how to use the Element class and modelToView() method.
    which has example of using the above Class and method that might give you some ideas.

  • How i can find the execution plan

    how i can find the execution plan for a quesry , and how i can compare two execution plan

    Mohan,
    Just create a table as follows
    CREATE TABLE T1 (STATEMENT_ID VARCHAR2(30),TIMESTAMP DATE,OPERATION VARCHAR2(30),
              OPTIONS VARCHAR2(30),OBJECT_NAME VARCHAR2(30),COST NUMBER(38),
              ID NUMBER(38),PARENT_ID NUMBER(38), OBJECT_NODE VARCHAR2(128),
              OBJECT_OWNER VARCHAR2(30),OBJECT_INSTANCE NUMBER(38),OBJECT_TYPE VARCHAR2(30),
              OPTIMIZER VARCHAR2(255),SEARCH_COLUMNS NUMBER,POSITION NUMBER(38),
              PARTITION_START VARCHAR2(255),PARTITION_STOP VARCHAR2(255),PARTITION_ID NUMBER(38),
              CARDINALITY NUMBER(38),BYTES NUMBER(38),OTHER_TAG VARCHAR2(255),
              OTHER LONG,REMARKS VARCHAR2(80),DISTRIBUTION VARCHAR2(30)
    Now use the sql statements as
    > EXPLAIN PLAN INTO T1 FOR (SELECT * FROM EMP);
    > Select * from T1
    this should do the job . . .
    Regards,
    K.T. Gandhi Karuna

  • How can I get the position assigned to the user in CRM .

    Hi all ,
    How can we get the positions to which a  user is assigned as a holder in CRM .
    Thanks ,
    Naval bhatt .

    Hi,
         Use the PPM toolkit class CL_CRM_PPM_UM_TOOLKIT. You can use the method You can use the method GET_ASSIGNMENTS_OF_USER which returns positions held by an user(user name).  You may also find the method GET_POSITION_OF_USER useful. It accepts username and the organization ID and will return the positions held by the user under that organization.
      This class always uses the current plan (01). If you want otherwise, you can use the FM RH_STRUC_GET. As to how this FM should be used, look inside the above said methods.
    Regards,
    Arun Prakash
    Edited by: Arun Prakash Karuppanan on May 11, 2010 11:40 AM

  • How can I find the table of

    How can I find the table of the structure fields?
    A structures table?
    for example the table of sap standard structure diaprd or diadrp, I do not remember now?
    Thanks.

    The hard way....
    Go to SE11
    Enter the structure
    Position the cursor on the field
    Press Where-Used List
    Check all related table to see which one fulfill your needs
    Greetings,
    Blag.

  • How do I find the tempo of a audio file?

    How do I find the tempo of a imported audio file (stereo track song)
    in Logic Pro 7.

    my way is the old way.
    move your file to the end of the song. (make sure SPL is at the beginning of the region)
    open sample window.
    open tempo list.
    set new tempo and slide the tempo until you see the bar display at the top change position and the down beat of the audio file is underneath the next full bar.
    hope this makes sense.
    you might need to find the next down beat by listening to and then cutting the region at the down beat. that way when you open the saple editor it will be able to see where the down beat is.

  • Find the position of refrence wbs in tx cj02

    HI friends,
    I need to update one WBS element above the refrence WBS elemnet n tx CJ02 for the project defination.....
    The problem is how do i know the position of the Refrenece WBS elment....
    Please help finding the position of the refrence WBS...
    regards
    kanishak

    Hello,
    You should be able to see it in t-code IM23.
    Try this link also
    [http://rwd.tennessee.edu/content/zpposition_find_a_position/wi/postscript/index.pdf]
    Hope it helps
    Thanks,
    Pavan.

  • I have bought a film from itunes and the credit has come out of my account, but i can't find the film anywhere, it said it was downloading, then i left the laptop and on return i couldn't find the film. how do i find the film?

    i have bought a film from itunes and the credit has come out of my account, but i can't find the film anywhere, it said it was downloading, then i left the laptop and on return i couldn't find the film. how do i find the film?

    Maybe it is in the Purchased category of iTunes,
    Try going there

  • How do I find the cookies I want to keep

    Recently I asked for some help but I think my request has got lost.
    I had beenadvised to save the cookies I want to keep but this is beyond me.
    My question is how do I find the cookie I want to keep? It is a cookie for an ebook and I have no idea what it is.
    Will deleting all other cookies mean that it will also delete my passwords and log ins on several sites? I don't want this to happen.
    Which brings me to the last point - You say that if I list exceptions to cookies I want to keep (at least I think that is what you mean), how do I find all those cookies?
    Again, sorry for troubling you but until I can find out more about the cookies, I don't want to delete these in case I delete the wrong ones, such as the ebook.
    Thank you cor-el. I do appreciate your advice...enormously.
    Anthony

    Dear Sir,
    Thank you so much for the above. It will be of great help in telling me where to go. But my problem is that if I can find cookies, I don't know which ones I want to keep. Are they labelled with the sites they refer to? If so that will help me. Apart from one which is the cookie I need to get to my online ebook, I guess there are cookies for the various passwords I have saved?
    Forgive me but I am an old man and not real great with computers.
    Thanks,
    Anthony

  • In Mountain Lion, how do I find the location of an open Preview File?  The file "properties" tab is no longer available.

    I typically have several open Preview files at any one time and often forget where, sometimes if, I saved them.  In Mountain Lion, how do I find the location of an open Preview File?  Tried holding option + command in spotlight but I don't see a path name appear anywhere. 

    Yes, cmd-option on a file you choose in Spotlight and the path will appear at the bottom of the Preview window.
    EDIT: Also, if it is bookmarked the path is in Bookmarks.

  • How can we find the most usage and lowest usage of table in Sql Server by T-SQL

    how can we find the most usage and lowest usage of table in Sql Server by T-SQL
    The table has time stamp column
    StartedOn datetime
    EndedOn datetime

    The Below query has been used , but the textdata column doesnot include the name of the table ServiceLog.
    SELECT
    FROM
    databasename,
    duration
    fn_trace_gettable('F:\Program
    Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Log\log_148.trc',
    default)
    WHERE
    DATABASENAME='ZTCFUTURE'
    AND TEXTDATA
    IS
    NOT
    NULL
    --AND TEXTDATA LIKE 'SERVICE%'
    order
    by cpu
    desc; 

Maybe you are looking for

  • Streaming Adobe Connect meeting to an external player

    Can a live Adobe Connect meeting be viewed from an external Flash-based player (not a recording, but the actual meeting taking place live)? If so, what is the API to use?

  • Unable to upload video to YouTube

    I have tried twice to upload a video to YouTube.  It is a short video, 7 min 33 sec.  I get the error, "Failed (unable to convert video file)".  I recently upgraded to Mavericks & iMovie 11 and this is the first time trying to upload since the upgrad

  • SAP XI and Business Process Modelling and Monitoring

    hi All, Could anybody tell me whether SAP XI has any Business Process Modelling tools or any Process Monitoring tools? If any, are these analogous to IBM WBIs Modeller and Monitor? Also does SAP XI provide any human interaction? Regards, Shree Norway

  • Oracle 8.1.6 on win2k datacentre

    Hi there! We have developed a software(2 tier architecture)using PB6.5.1 on win95,98 and Oracle7.3 on Unix server. We are planning to upgrade the software to Oracle 8.1.6 and also change are OS to Win2k datacentre. Can anyone tell me , if Oracle 8.1.

  • Unable to install OER

    Hi all, I tried installing Oracle Enterprise Repository 11.1.1.3.0, when I ran the OER111130_generic.jar file I got this error C:\Documents and Settings\Desktop\OER>java -jar OER111130_generic.jar Registry key 'Software\JavaSoft\Java Runtime Environm