Skip navigation.
 
mlRe: Storing PDF selection
FROM : Antonio Nunes
DATE : Sat May 17 18:57:14 2008

On May 17, 2008, at 2:02 PM, Laurent Cerveau wrote:

> On May 16, 2008, at 9:11 AM, Antonio Nunes wrote:
>

>>
>> You ask the page for a selection for the range you provide, and 
>> assign that to PDFView's current selection:
>>             [somePDFView setCurrentSelection:[yourRememberedPage 
>> selectionForRange:yourRememberedRange]];
>>
>> Selections can span multiple pages of course, so covering that 
>> requires a bit more work, but it's not difficult.

>
>
> But the problem here  is to get the "yourRememberedRange". Access to 
> it does not seem to exist on a PDFSelection. As John Calhoun 
> suggested in another email I tried with rect but this fails also.


I would suggest you try to verify why John's suggestion fails, as one 
would expect it to work. Alternatively try this:

Untested:
1. Ask for the bounds of the selection
2. Get the string of the selection
3. Get the string of the page
4. Use rangeOfString:options:range: on the page-string to search for 
the selection-string (or you can use an NSScanner, but I think this is 
simpler)
5. If you get a match you have a range. Use it to call 
selectionForRange: on the page
6. If the bounds of the returned selection match the bounds returned 
in step 1 you've found your range. If not continue searching the page-
string until you find the match.

I guess we should file a bug requesting PDFSelections be able to 
return their rangeForPage: and also their rangeForDocument or 
similarly named method that would yield the range within the full text 
of the document.

António

-----------------------------------------------------------
And could you keep your heart in wonder
at the daily miracles of your life,
your pain would not seem less wondrous
than your joy.

--Kahlil Gibran
-----------------------------------------------------------

Related mailsAuthorDate
mlStoring PDF selection Laurent Cerveau May 16, 08:43
mlRe: Storing PDF selection Antonio Nunes May 16, 09:11
mlRe: Storing PDF selection John Calhoun May 16, 21:40
mlRe: Storing PDF selection Laurent Cerveau May 17, 15:13
mlRe: Storing PDF selection Laurent Cerveau May 17, 15:13
mlRe: Storing PDF selection Antonio Nunes May 17, 18:57
mlRe: Storing PDF selection Laurent Cerveau May 17, 21:10