Doesn't seem to work; Using the following code, I really get wildly differing results. (cleaned up a lot)
selArray = [mySelection selectionsByLine]; if(selArray != nil) saCnt = [selArray count]; // get the start of the range ps1 = [selArray objectAtIndex: 0]; page1 = [[ps1 pages] objectAtIndex: 0]; p1 = (int) [[myView document] indexForPage: page1]; //get the bounds for the start of the range r1 = [ps1 boundsForPage: cpage]; pnt1 = r1.origin; //convert point to character index dx1 = [cpage characterIndexAtPoint: pnt1]; //ps cocoa-dev: this seems to work //do the last point ps1 = [selArray lastObject]; page2 = [[ps1 pages] objectAtIndex: 0]; p2 = [[myView document] indexForPage: cpage]; r2 = [ps1 boundsForPage: page2]; //this seems to give the wrong bounds pnt1 = NSMakePoint((float) NSMaxX(r2), (float) NSMinY(r2)); //or maybe this is the wrong point to use? dx2 = [cpage characterIndexAtPoint: pnt1]; selRange = NSMakeRange(dx1, dx2-dx1); //I know this is too simple; but for now only dealing with selections on a single page. On Mar 13, 2014, at 12:00 PM, <cocoa-dev-requ...@lists.apple.com> <cocoa-dev-requ...@lists.apple.com> wrote: > > On 11 Mar 2014, at 17:37, Matthew Weinstein <mwein...@kent.edu> wrote: > >> Trying to figure out how to get a pages selection range (offset and length) >> for a pdfselection. I've been using the bounding rect, but if I have a >> selection that is a sentence that crosses lines and terminates half way in >> the last line, the rect includes everything to the edge (of course). But if >> I just want the offset and length, how do I extract that? > > Matthew, ask the PDFSelection for its “selectionsByLine”. You should get two > selections. One for the first line, one for the second. Examine both to exact > the data you need. > > - António _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com