PSPDFTextBlock

Objective-C


@interface PSPDFTextBlock : NSObject <NSCopying, NSSecureCoding>

Swift

class TextBlock : NSObject, NSCopying, NSSecureCoding

Represents multiple words forming a text block. (e.g. a Column)

  • Unavailable

    Not the designated initializer

    Undocumented

    Declaration

    Objective-C

    PSPDF_EMPTY_INIT_UNAVAILABLE
  • Unavailable

    Not the designated initializer

    Undocumented

    Declaration

    Objective-C

    PSPDF_EMPTY_INIT_UNAVAILABLE
  • Convenience initializer to create a text block. The initializer will fail if there are no glyphs in glyphs.

    Declaration

    Objective-C

    - (nullable instancetype)initWithGlyphs:(nonnull NSArray<PSPDFGlyph *> *)glyphs
                                      frame:(CGRect)frame;

    Swift

    convenience init?(glyphs: [PSPDFGlyph], frame: CGRect)

    Parameters

    glyphs

    The glyphs that are a part of the text block that is being instantiated.

    frame

    The frame of the text block, in normalized PDF coordinates. Pass in CGRectNull if you want the frame to be calculated from the values in glyphs.

  • Designated initializer to create a text block. The initializer will fail if the range of text is invalid (NSNotFound for its location/length). Note that the glyphs array will be empty when using this initializer.

    Declaration

    Objective-C

    - (nullable instancetype)initWithRange:(NSRange)textRange
                                      text:(nonnull NSString *)text
                                     frame:(CGRect)frame;

    Swift

    init?(range textRange: NSRange, text: String, frame: CGRect)

    Parameters

    textRange

    The range of text (in PSPDFTextParser.text) that the receiver is representing.

    text

    The text that is contained by the receiver. It is the caller’s responsibility to ensure that the text matches the passed in range. @frame The frame of the text block, in normalized PDF coordinates.

  • Frame of the text block, in normalized PDF coordinates.

    Declaration

    Objective-C

    @property (nonatomic, readonly) CGRect frame;

    Swift

    var frame: CGRect { get }
  • The range of glyphs (in PSPDFTextParser.glyphs) that the receiver is representing.

    Declaration

    Objective-C

    @property (nonatomic, readonly) NSRange range;

    Swift

    var range: NSRange { get }
  • All words of the current text block. Evaluated lazily.

    Declaration

    Objective-C

    @property (nonatomic, copy, readonly) NSArray<PSPDFWord *> *_Nonnull words;

    Swift

    var words: [Word] { get }
  • Returns the content of the text block (all words merged together)

    Declaration

    Objective-C

    @property (nonatomic, copy, readonly) NSString *_Nonnull content;

    Swift

    var content: String { get }
  • Compare to another text block.

    Declaration

    Objective-C

    - (BOOL)isEqualToTextBlock:(nonnull PSPDFTextBlock *)otherBlock;

    Swift

    func isEqual(to otherBlock: TextBlock) -> Bool