PSPDFTextBlock


@interface PSPDFTextBlock : NSObject <NSCopying, NSSecureCoding>

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

  • Unavailable

    Undocumented

    Declaration

    Objective-C

    PSPDF_EMPTY_INIT_UNAVAILABLE
  • Unavailable

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

    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 PDF coordinates.

  • Frame of the text block, in PDF coordinates. Not rotated.

    Note

    Use convertGlyphRectToViewRect: when converting to view coordinates.

    Declaration

    Objective-C

    @property (readonly, nonatomic) CGRect frame;

    Swift

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

    Declaration

    Objective-C

    @property (readonly, nonatomic) NSRange range;

    Swift

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

    Declaration

    Objective-C

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

    Swift

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

    Declaration

    Objective-C

    @property (readonly, copy, nonatomic) 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: PSPDFTextBlock) -> Bool