PDFSelection Class Reference

Inherits from
Conforms to
Framework
Library/Frameworks/Quartz.framework/Frameworks/PDFKit.framework
Availability
Available in OS X v10.4 and later.
Declared in
PDFSelection.h
Related sample code

Overview

A PDFSelection object identifies a contiguous or noncontiguous selection of text in a PDF document.

Tasks

Initializing a Selection

Getting Information About a Selection

Modifying a Selection

Managing Selection Drawing

Instance Methods

addSelection:

Adds the specified selection to the receiving selection.

- (void)addSelection:(PDFSelection *)selection
Discussion

Selections do not have to be contiguous. If the selection to be added overlaps with the receiving selection, the overlap is removed in a process called normalization.

Availability
  • Available in OS X v10.4 and later.
Declared In
PDFSelection.h

addSelections:

Adds the specified array of selections to the receiving selection.

- (void)addSelections:(NSArray *)selections
Discussion

This method provides better performance than multiple calls to addSelection if you need to add several selections to an existing selection. This is because the normalization of the selection (the removal of any overlaps between selections) occurs only once, after all selections have been added.

Availability
  • Available in OS X v10.5 and later.
See Also
  • – addSelection:
Declared In
PDFSelection.h

attributedString

Returns an NSAttributedString object representing the text contained in the selection (may contain linefeed characters).

- (NSAttributedString *)attributedString
Availability
  • Available in OS X v10.4 and later.
See Also
Declared In
PDFSelection.h

boundsForPage:

Returns the bounds of the selection on the specified page.

- (NSRect)boundsForPage:(PDFPage *)page
Discussion

The selection rectangle is given in page space.

Page space is a 72 dpi coordinate system with the origin at the lower-left corner of the current page.

Availability
  • Available in OS X v10.4 and later.
Related Sample Code
Declared In
PDFSelection.h

color

Returns the color used to draw the selection.

- (NSColor *)color
Discussion

Note that when no color has been specified for the PDFSelection objects in a document, the selections are drawn using [NSColor selectedTextBackgroundColor] for the active state and [NSColor secondarySelectedControlColor] for the inactive state.

Availability
  • Available in OS X v10.5 and later.
See Also
  • – setColor:
Declared In
PDFSelection.h

drawForPage:active:

Calls drawForPage:withBox:active: with a default value for box parameter.

- (void)drawForPage:(PDFPage *)page active:(BOOL)active
Discussion

The default value is kPDFDisplayBoxCropBox. If active is YES, drawing uses selectedTextBackgroundColor. If NO, it uses secondarySelectedControlColor.

Availability
  • Available in OS X v10.4 and later.
Declared In
PDFSelection.h

drawForPage:withBox:active:

Draws the selection relative to the origin of the specified box in page space.

- (void)drawForPage:(PDFPage *)page withBox:(PDFDisplayBox)box active:(BOOL)active
Discussion

The selection is drawn using the current highlight color. If active is YES, drawing uses selectedTextBackgroundColor. If NO, it uses secondarySelectedControlColor. Refer to the PDFPage class for the list of available box types.

Page space is a 72 dpi coordinate system with the origin at the lower-left corner of the current page.

Availability
  • Available in OS X v10.4 and later.
Declared In
PDFSelection.h

extendSelectionAtEnd:

Extends the selection from its end toward the end of the document.

- (void)extendSelectionAtEnd:(NSInteger)chars
Discussion

The selection may be extended by any amount, up to and including the end of the document.

Availability
  • Available in OS X v10.4 and later.
Declared In
PDFSelection.h

extendSelectionAtStart:

Extends the selection from its start toward the beginning of the document.

- (void)extendSelectionAtStart:(NSInteger)chars
Discussion

The selection may be extended by any amount, up to and including the beginning of the document.

Availability
  • Available in OS X v10.4 and later.
Declared In
PDFSelection.h

initWithDocument:

Returns an empty PDFSelection object.

- (id)initWithDocument:(PDFDocument *)document
Discussion

Typically, you don’t need to create a PDFSelection object, but you can use an empty PDFSelection object as a container into which you can place selections, using addSelection: and addSelections.

Availability
  • Available in OS X v10.5 and later.
Declared In
PDFSelection.h

pages

Returns the array of pages contained in the selection.

- (NSArray *)pages
Discussion

Pages are sorted by index number.

Availability
  • Available in OS X v10.4 and later.
Related Sample Code
Declared In
PDFSelection.h

selectionsByLine

Returns an array of selections, one for each line of text covered by the receiver.

- (NSArray *)selectionsByLine
Discussion

If you call this method on a PDFSelection object that represents a paragraph, for example, selectionsByLine returns an array that contains one PDFSelection object for each line of text in the paragraph.

Availability
  • Available in OS X v10.5 and later.
Declared In
PDFSelection.h

setColor:

Sets the color used for the drawing of a selection in both active and inactive states.

- (void)setColor:(NSColor *)color
Discussion

When no color has been specified for the PDFSelection objects in a document, the selections are drawn using [NSColor selectedTextBackgroundColor] for the active state and [NSColor secondarySelectedControlColor] for the inactive state. Use the setColor method to supply a color you want to be used for the drawing of both active and inactive selections.

Availability
  • Available in OS X v10.5 and later.
See Also
  • – color
Declared In
PDFSelection.h

string

Returns an NSString object representing the text contained in the selection (may contain linefeed characters).

- (NSString *)string
Availability
  • Available in OS X v10.4 and later.
See Also
  • – attributedString
Declared In
PDFSelection.h