• 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
Highlighted Text in PDF Kit
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Highlighted Text in PDF Kit


  • Subject: Highlighted Text in PDF Kit
  • From: Ryan Brown <email@hidden>
  • Date: Mon, 3 Jan 2011 10:23:53 -0500

Hi,

What is the best way to get a string for a block of highlighted text in PDF Kit, given a PDFAnnotationMarkup object? I've tried several approaches, but none of them deals with overlaps in the quadrilateralPoints, gets the text bounds correct, and adds spaces between lines of text. For example, the following will sometimes get words before and after the highlighted text for some reason:

NSArray *quadPoints = [annotation quadrilateralPoints];
NSRect bounds = [annotation bounds];
PDFSelection *selection = nil;

for(j=0; j < [quadPoints count]; j+=2) {
	NSPoint start = [[quadPoints objectAtIndex:j] pointValue], end = [[quadPoints objectAtIndex:j+1] pointValue];

	// quadrilateralPoints are relative to the annotation's bounds
	start.x += bounds.origin.x;
	start.y += bounds.origin.y;
	end.x += bounds.origin.x;
	end.y += bounds.origin.y;

	if(!selection)
		selection = [pdfPage selectionFromPoint:start toPoint:end];
	else
		[selection addSelection:[pdfPage selectionFromPoint:start toPoint:end]];
}

// add spaces between lines of text
NSMutableString *string = [NSMutableString string];
for(PDFSelection *mSelection in [selection selectionsByLine]) {
	[string appendString:[mSelection string]];
	[string appendString:@" "];
}

Thanks,
Ryan_______________________________________________

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: iOS MapKit rotation leaves blank area
  • Next by Date: Application that uninstalls itself
  • Previous by thread: Re: iOS MapKit rotation leaves blank area
  • Next by thread: Application that uninstalls itself
  • Index(es):
    • Date
    • Thread