KurtCode / PDFKitten

A framework for extracting data from PDFs in iOS
MIT License
391 stars 113 forks source link

T* callback implementation #8

Open slitskevich opened 12 years ago

slitskevich commented 12 years ago

I think the T* operator callback TStar implementation might be incorrect.

Selection items have totally wrong translation matrix for occurrences found after the T* operator. I logged text matrix in every operator callback. I noticed that the ty value was decreasing all the time until T* operator was met. After that it started increasing and could go out of the page frame in the end.

TStar callback calls newLine wich has following line in it: [self newLineWithLineHeight: self.leadning save:NO];

As soon as I passed negative value ( -self.leadning ) into the newLineWithLineHeight it started to work just fine. What do you think about it? Is my fix correct or did i miss anything? Thanks

KurtCode commented 12 years ago

Yes, I think you may be right.

The origin is in the lower-left corner, so each new line should translate the text matrix by a negative amount along the Y axis. The text leading parameter seems to be the absolute value of the distance between to adjacent lines. So a new line really should correspond to a vertical shift equal to the negatve leading.

Rather than changing the sign though, I would modify the newLineWithLineHeigth: method directly, so that "make a new line with heigth H" where H is a positive number, translates the text matrix in negative Y-direction.

I guess the other operators need to be changed as well, to pass the positive value too.

Thanks!