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:
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