Re: Creating a PDFSelection...
On May 25, 2010, at 9:37 PM, Matthew Weinstein wrote: Actually, I don't need the tiff; I just need the rectangle! People have to be able to sketch the rectangle over the pdf, and then my program stores and restores those rectangles (with some additional information). PDFSelection has a routine to return each line from the selection as a sub-selection (for a single word selection this generally is just the selection itself, but for selections that span multiple lines you get a new selection for each line). For each line selection you can get its bounds. These you can store/archive along with the page index. With the archived rectangles and page indices you can later create selections again from those rectangles (PDFPage has -[selectionForRect:]). This isn't a perfect solution though — you may have to pad out the rectangle a bit for example to improve fidelity between the original selection and the unarchived one. If you know the range of the original text selected, PDFPage's -[selectionForRange:] is unambiguously specified. John Calhoun—___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Creating a PDFSelection...
António, that's exactly what I needed. But it leads to my next question. The PDFSelection class as far as I can tell basically supports what in Preview.app is the text tool on the toolbar. The selection tool in Preview.app selects an arbitrary rectangle, even if there's no text behind the image. So, is there some way of changing the behavior of the given PDFSelection, or do I have to hand code this (using the Cropped image example code, for instance)? On May 25, 2010, at 11:05 AM, Antonio Nunes wrote: On 25 May 2010, at 18:32, Matthew Weinstein wrote: Thanks for all the help! Onto the next problem... Users need to be able to select sections of a pdfView, and I need to be able to save and analyze the selections (e.g., do they overlap). I also need to be able to restore the selections later. So the question is, can I use PDFSelection to do this. I can't seem to find a way to say create a selection with this NSRect (or part of the string). Is there a way to do this? Is there an alternative? From the PDFPage class reference: - (PDFSelection *)selectionForRect:(NSRect)rect - (PDFSelection *)selectionForRange:(NSRange)range etc. António There is nothing as strong as real gentleness, and there is nothing as gentle as real strength. ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Creating a PDFSelection...
On 26 May 2010, at 03:01, Matthew Weinstein wrote: The PDFSelection class as far as I can tell basically supports what in Preview.app is the text tool on the toolbar. The selection tool in Preview.app selects an arbitrary rectangle, even if there's no text behind the image. So, is there some way of changing the behavior of the given PDFSelection, or do I have to hand code this (using the Cropped image example code, for instance)? The selection tool in Preview just creates a snapshot of the selection. A TIFF image. This has nothing to do with PDFSelection. PDFSelections deal only with text, so I think they are not rich enough for your purposes. I guess you may have to delve deeper; parsing the page streams (you can use Quartz for that), and rolling your own selections. Not a quick and easy task. António --- And you would accept the seasons of your heart, even as you have always accepted the seasons that pass over your field. --Kahlil Gibran --- ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Creating a PDFSelection...
Actually, I don't need the tiff; I just need the rectangle! People have to be able to sketch the rectangle over the pdf, and then my program stores and restores those rectangles (with some additional information). On May 25, 2010, at 9:15 PM, Antonio Nunes wrote: On 26 May 2010, at 03:01, Matthew Weinstein wrote: The PDFSelection class as far as I can tell basically supports what in Preview.app is the text tool on the toolbar. The selection tool in Preview.app selects an arbitrary rectangle, even if there's no text behind the image. So, is there some way of changing the behavior of the given PDFSelection, or do I have to hand code this (using the Cropped image example code, for instance)? The selection tool in Preview just creates a snapshot of the selection. A TIFF image. This has nothing to do with PDFSelection. PDFSelections deal only with text, so I think they are not rich enough for your purposes. I guess you may have to delve deeper; parsing the page streams (you can use Quartz for that), and rolling your own selections. Not a quick and easy task. António --- And you would accept the seasons of your heart, even as you have always accepted the seasons that pass over your field. --Kahlil Gibran --- ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com