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

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

$
0
0

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_pagepageReference], 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 = [NSValuevalueWithCGRect: 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:

working.png

 

But does not work with others:

ss2.png

(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


Viewing all articles
Browse latest Browse all 46145

Trending Articles



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