PSPDFTextBlock


@interface PSPDFTextBlock : NSObject <NSCopying, NSSecureCoding>

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

  • Undocumented

    Declaration

    Objective-C

    
    @interface PSPDFTextBlock : NSObject <NSCopying, NSSecureCoding>
  • Undocumented

    Declaration

    Objective-C

    
    @interface PSPDFTextBlock : NSObject <NSCopying, NSSecureCoding>
  • 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
  • Convenience initializer to create a text block. The initializer will fail if there are no glyphs in the array.

    Note

    Use CGRectNull to indicate that the frame should be calculated automatically.

    Declaration

    Objective-C

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

    Swift

    convenience init?(glyphs: [PSPDFGlyph], frame: CGRect, pageRotation: UInt)
  • Convenience initializer to create a text block. The initializer will fail if there are no glyphs in the array.

    Calculates frame automatically by building the union of all glyph frames.

    Declaration

    Objective-C

    - (nullable instancetype)initWithGlyphs:(nonnull NSArray<PSPDFGlyph *> *)glyphs
                               pageRotation:(NSUInteger)pageRotation;

    Swift

    convenience init?(glyphs: [PSPDFGlyph], pageRotation: UInt)
  • All glyphs of the current text block.

    Declaration

    Objective-C

    @property (readonly, copy, nonatomic) NSArray<PSPDFGlyph *> *_Nonnull glyphs;

    Swift

    var glyphs: [PSPDFGlyph] { get }
  • The page rotation of the page this word is from.

    Declaration

    Objective-C

    @property (readonly, nonatomic) NSUInteger pageRotation;

    Swift

    var pageRotation: UInt { get }