Quantcast
Channel: Adobe Community : Popular Discussions - PDF Language and Specifications
Viewing all articles
Browse latest Browse all 46145

Getting the text position (inside or outside a box?)

$
0
0

Hi all,

 

I'm using plain Ruby to access the content of an PDF file. This by using yob's PDF Reader from GitHub.

Now I've come a long way, but still have one question remaining! How to get the position of a text object (the box of this object)?

 

I've read the PDF reference, it tells me all sorts of stuff about Text Space, Glyph space and User Space... As English is not my native language it's a lot to take in... I currently do have a CTM, a Text Matrix and a Text Render Matrix. I also have all the boxes on the page (media, trim, crop etc.)

For a Image object, I use the CTM e and f values as x and y. This works perfectly, but when it comes to text, I seem to miss something..

 

Example:

 

CTM: Matrix[

  [1, 0, 0],

  [0, -1, 0],

  [-0.0, 640.346, 1]

]

 

Text matrix => Matrix[

  [10.0, 0.0, 0],

  [0.0, 10.0, 0],

  [2062769.1732, 42.6732, 1]

] == Needed to convert from text space to User/device space!

 

Trm: Matrix[

   [1000.0, 0.0, 0.0],

   [0.0, -10.0, 0.0],

   [2062769.1732, 597.6728, 1.0]

]

 

I can count lines, and calc a displacement by multipling this number by the Font size (12pt per example) but how do I get the the box of te text_object? If I've the box, I can make sure it fits in a box or not....

 

Please help with anything I might be doing wrong, or even better if you can help me find the text position!


Viewing all articles
Browse latest Browse all 46145

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>