Mac Developer Library

Developer

Quartz Framework Reference PDFSelection Class Reference

Options
Deployment Target:

On This Page
Language:

PDFSelection

Inheritance


Conforms To


Import Statement


Swift

import Quartz

Objective-C

@import Quartz;

Availability


Available in OS X v10.4 and later.

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

  • Returns an empty PDFSelection object.

    Declaration

    Swift

    init!(document document: PDFDocument!)

    Objective-C

    - (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.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.5 and later.

  • Returns the array of pages contained in the selection.

    Declaration

    Swift

    func pages() -> [AnyObject]!

    Objective-C

    - (NSArray *)pages

    Discussion

    Pages are sorted by index number.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

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

    Declaration

    Swift

    func string() -> String!

    Objective-C

    - (NSString *)string

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

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

    Declaration

    Swift

    func attributedString() -> NSAttributedString!

    Objective-C

    - (NSAttributedString *)attributedString

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

    See Also

    – string

  • Returns the bounds of the selection on the specified page.

    Declaration

    Swift

    func boundsForPage(_ page: PDFPage!) -> NSRect

    Objective-C

    - (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.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

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

    Declaration

    Swift

    func selectionsByLine() -> [AnyObject]!

    Objective-C

    - (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.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.5 and later.

  • Returns the color used to draw the selection.

    Declaration

    Swift

    func color() -> NSColor!

    Objective-C

    - (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.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.5 and later.

    See Also

    – setColor:

  • Adds the specified selection to the receiving selection.

    Declaration

    Swift

    func addSelection(_ selection: PDFSelection!)

    Objective-C

    - (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.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

  • Adds the specified array of selections to the receiving selection.

    Declaration

    Swift

    func addSelections(_ selections: [AnyObject]!)

    Objective-C

    - (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.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.5 and later.

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

    Declaration

    Swift

    func extendSelectionAtEnd(_ succeed: Int)

    Objective-C

    - (void)extendSelectionAtEnd:(NSInteger)succeed

    Discussion

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

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

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

    Declaration

    Swift

    func extendSelectionAtStart(_ precede: Int)

    Objective-C

    - (void)extendSelectionAtStart:(NSInteger)precede

    Discussion

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

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

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

    Declaration

    Swift

    func drawForPage(_ page: PDFPage!, active active: Bool)

    Objective-C

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

    Discussion

    The default value is kPDFDisplayBoxCropBox. If active is YEStrue, drawing uses selectedTextBackgroundColor. If NOfalse, it uses secondarySelectedControlColor.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

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

    Declaration

    Swift

    func drawForPage(_ page: PDFPage!, withBox box: PDFDisplayBox, active active: Bool)

    Objective-C

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

    Discussion

    The selection is drawn using the current highlight color. If active is YEStrue, drawing uses selectedTextBackgroundColor. If NOfalse, 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.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

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

    Declaration

    Swift

    func setColor(_ color: NSColor!)

    Objective-C

    - (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.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.5 and later.

    See Also

    – color