• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Cocoa-dev Digest, Vol 11, Issue 139
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cocoa-dev Digest, Vol 11, Issue 139


  • Subject: Re: Cocoa-dev Digest, Vol 11, Issue 139
  • From: Matthew Weinstein <email@hidden>
  • Date: Thu, 13 Mar 2014 13:28:25 -0700

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, <email@hidden> <email@hidden> wrote:

>
> On 11 Mar 2014, at 17:37, Matthew Weinstein <email@hidden> 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 (email@hidden)

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:

This email sent to email@hidden


  • Prev by Date: Re: Removing Core Data from an existing app
  • Next by Date: Why is an IKImageBrowser method not firing?
  • Previous by thread: Re: Removing Core Data from an existing app
  • Next by thread: Why is an IKImageBrowser method not firing?
  • Index(es):
    • Date
    • Thread