PTFreeText

@interface PTFreeText : PTMarkup

A FreeText annotation (PDF 1.3) displays text directly on the page. Unlike an ordinary Text annotation, a FreeText annotation has no open or closed state; The content of the FreeText annotation is always visible instead of being displayed in a popup window.

  • Creates a FreeText annotation and initializes it using given Cos/SDF object.

    Note

    The constructor does not copy any data, but is instead the logical equivalent of a type cast.

    Declaration

    Objective-C

    - (instancetype)initWithD:(PTObj *)d;

    Swift

    init!(d: PTObj!)

    Parameters

    d

    The Cos/SDF object to initialze the annotation with.

  • Undocumented

    Declaration

    Objective-C

    - (instancetype)init;

    Swift

    init!()
  • Undocumented

    Declaration

    Objective-C

    - (instancetype)initWithAnn: (PTAnnot*)ann;

    Swift

    init!(ann: PTAnnot!)
  • Creates a new FreeText annotation in the specified document.

    Declaration

    Objective-C

    + (PTFreeText *)Create:(PTSDFDoc *)doc pos:(PTPDFRect *)pos;

    Swift

    class func create(_ doc: PTSDFDoc!, pos: PTPDFRect!) -> PTFreeText!

    Parameters

    doc

    A document to which the FreeText annotation is added.

    pos

    A rectangle specifying the FreeText annotation’s bounds in default user space units.

    Return Value

    A newly created blank FreeText annotation.

  • Undocumented

    Declaration

    Objective-C

    + (PTFreeText*)CreateAnnot: (PTSDFDoc*)doc pos:  (PTPDFRect*)pos;

    Swift

    class func createAnnot(_ doc: PTSDFDoc!, pos: PTPDFRect!) -> PTFreeText!
  • Returns the default appearance of the FreeText annotation.

    Note

    The default appearance string is used to format the text. The annotation dictionary’s Appearance entry, if present, will take precedence over this entry.

    Note

    this method corresponds to the ‘DA’ entry in the annotation dictionary.

    Declaration

    Objective-C

    - (NSString *)GetDefaultAppearance;

    Swift

    func getDefaultAppearance() -> String!

    Return Value

    A string representing the default appearance of the annotation.

  • Sets the default appearance of the FreeText annotation.

    Note

    The default appearance string is used to format the text. The annotation dictionary’s Appearance entry, if present, will take precedence over this entry.

    Note

    this method corresponds to the ‘DA’ entry in the annotation dictionary.

    Declaration

    Objective-C

    - (void)SetDefaultAppearance:(NSString *)app_str;

    Swift

    func setDefaultAppearance(_ app_str: String!)

    Parameters

    app_str

    A string representing the default appearance of the annotation.

  • Returns the quading format of the FreeText annotation. (PDF 1.4)

    Note

    The following are the quading formats corresponding to each int code. 0 Left-justified 1 Centered 2 Right-justified

    Declaration

    Objective-C

    - (int)GetQuaddingFormat;

    Swift

    func getQuaddingFormat() -> Int32

    Return Value

    A int (code) indicating the quading format of the FreeText annotation.

  • Sets the quading format of the FreeText annotation. (Optional; PDF 1.4)

    Note

    The int code specifies the form of quadding (justification) that shall be used in displaying the annotation’s text: 0 Left-justified 1 Centered 2 Right-justified

    Declaration

    Objective-C

    - (void)SetQuaddingFormat:(int)format;

    Swift

    func setQuaddingFormat(_ format: Int32)

    Parameters

    format

    A int code indicating the quading format of the FreeText annotation. Default value: 0 (left-justified).

  • Returns the callout line points of the FreeText annotation. (PDF 1.6)

    Note

    If the line is straight, i.e. only has two points, two points will be returned in p1 and p2, and p3 will be the same as p2. The coordinates are given in default user space.

    Declaration

    Objective-C

    - (PTPDFPoint *)GetCalloutLinePoint1;

    Swift

    func getCalloutLinePoint1() -> PTPDFPoint!

    Parameters

    p1

    The target point. (where the ending style is used)

    p2

    The ending point.

    p3

    The knee point.

    Return Value

    Three point objects if the line is bent or two point objects if the line is straight.

  • Undocumented

    Declaration

    Objective-C

    - (PTPDFPoint*)GetCalloutLinePoint2;

    Swift

    func getCalloutLinePoint2() -> PTPDFPoint!
  • Undocumented

    Declaration

    Objective-C

    - (PTPDFPoint*)GetCalloutLinePoint3;

    Swift

    func getCalloutLinePoint3() -> PTPDFPoint!
  • Sets the callout line points of the FreeText annotation. (Optional; meaningful only if IT is FreeTextCallout; PDF 1.6)

    Note

    The coordinates are defined in default user space.

    Declaration

    Objective-C

    - (void)SetCalloutLinePointsWithKneePoint:(PTPDFPoint *)p1
                                           p2:(PTPDFPoint *)p2
                                           p3:(PTPDFPoint *)p3;

    Swift

    func setCalloutLinePoints(withKneePoint p1: PTPDFPoint!, p2: PTPDFPoint!, p3: PTPDFPoint!)

    Parameters

    p1

    The target point. (where the ending style is used)

    p2

    The knee point.

    p3

    The ending point.

  • Sets the callout line points of the FreeText annotation. (Optional; meaningful only if IT is FreeTextCallout; PDF 1.6)

    Note

    The coordinates are defined in default user space.

    Declaration

    Objective-C

    - (void)SetCalloutLinePoints:(PTPDFPoint *)p1 p2:(PTPDFPoint *)p2;

    Swift

    func setCalloutLinePoints(_ p1: PTPDFPoint!, p2: PTPDFPoint!)

    Parameters

    p1

    The target point. (where the ending style is used)

    p2

    The ending point.

  • Returns Intent name of the FreeText annotation. (PDF 1.4)

    Declaration

    Objective-C

    - (PTIntentName)GetIntentName;

    Swift

    func getIntentName() -> PTIntentName

    Return Value

    The intent name of the annotation as an entry from the enum “IntentName”.

  • Sets the Intent name of the FreeText annotation. (Optional; PDF 1.4)

    Declaration

    Objective-C

    - (void)SetIntentName:(PTIntentName)mode;

    Swift

    func setIntentName(_ mode: PTIntentName)

    Parameters

    mode

    The intent name of the annotation as an entry from the enum “IntentName”.

  • Returns the ending style of the callout line of the FreeText Annotation.

    Note

    The ending style specifies the line ending style that shall be used in drawing the callout line specified in CallOut LineAnnot Points (CL). The enum entry shall specify the line ending style for the endpoint defined by the target point(p1) of the CallOut LineAnnot Points. Default value: e_None.

    Declaration

    Objective-C

    - (PTEndingStyle)GetEndingStyle;

    Swift

    func getEndingStyle() -> PTEndingStyle

    Return Value

    The ending style represented as one of the entries of the enum “EndingStyle”

  • Sets the ending style of the callout line of the FreeText Annotation. (Optional; meaningful only if CL is present; PDF 1.6)

    Note

    The ending style specifies the line ending style that shall be used in drawing the callout line specified in CallOut LineAnnot Points (CL). The enum entry shall specify the line ending style for the endpoint defined by the target point(p1) of the CallOut LineAnnot Points. Default value: e_None.

    Declaration

    Objective-C

    - (void)SetEndingStyle:(PTEndingStyle)style;

    Swift

    func setEndingStyle(_ style: PTEndingStyle)

    Parameters

    style

    The ending style represented using one of the entries of the enum “EndingStyle”

  • Sets the ending style of the callout line of the FreeText Annotation. (Optional; meaningful only if CL is present; PDF 1.6)

    Note

    The ending style specifies the line ending style that shall be used in drawing the callout line specified in CallOut LineAnnot Points (CL). The enum entry shall specify the line ending style for the endpoint defined by the target point(p1) of the CallOut LineAnnot Points. Default value: “None”.

    Declaration

    Objective-C

    - (void)SetEndingStyleWithString:(NSString *)est;

    Swift

    func setEndingStyle(with est: String!)

    Parameters

    est

    The ending style represented using a string.

  • Sets the text color of the FreeText Annotation.

    Note

    Current implementation of this method creates a non-standard entry in the annotation dictionary and uses it to generate the appearance stream. Make sure you call RefreshAppearance() after changing text or line color, and remember that editing the annotation in other PDF applications will produce different appearance.

    Declaration

    Objective-C

    - (void)SetTextColor:(PTColorPt *)color col_comp:(int)col_comp;

    Swift

    func setTextColor(_ color: PTColorPt!, col_comp: Int32)

    Parameters

    color

    ColorPt object representing the color.

    col_comp

    number of colorant components in ColorPt object.

  • Returns the text color of the FreeText Annotation.

    Note

    Current implementation of this method uses a non-standard entry in the annotation dictionary and will not return meaningful results when called on annotations not created with PDFTron software.

    Declaration

    Objective-C

    - (PTColorPt *)GetTextColor;

    Swift

    func getColor() -> PTColorPt!
  • Undocumented

    Declaration

    Objective-C

    - (int)GetTextColorCompNum;

    Swift

    func getColorCompNum() -> Int32
  • Sets the line and border color of the FreeText Annotation.

    Note

    Current implementation of this method creates a non-standard entry in the annotation dictionary and uses it to generate the appearance stream. Make sure you call RefreshAppearance() after changing text or line color, and remember that editing the annotation in other PDF applications will produce different appearance.

    Declaration

    Objective-C

    - (void)SetLineColor:(PTColorPt *)color col_comp:(int)col_comp;

    Swift

    func setLineColor(_ color: PTColorPt!, col_comp: Int32)

    Parameters

    color

    ColorPt object representing the color.

    col_comp

    number of colorant components in ColorPt object.

  • Returns the line and border color of the FreeText Annotation.

    Note

    Current implementation of this method uses a non-standard entry in the annotation dictionary and will not return meaningful results when called on annotations not created with PDFTron software.

    Declaration

    Objective-C

    - (PTColorPt *)GetLineColor;

    Swift

    func getLineColor() -> PTColorPt!

    Parameters

    color

    reference to ColorPt object, where results will be saved.

    col_comp

    reference to an integer, where number of colorant components will be written.

  • Undocumented

    Declaration

    Objective-C

    - (int)GetLineColorCompNum;

    Swift

    func getLineColorCompNum() -> Int32
  • Sets the default appearance font name.

    Declaration

    Objective-C

    - (void)SetFontName:(NSString *)fontName;

    Swift

    func setFontName(_ fontName: String!)

    Parameters

    fontName

    Set the default name name.

  • Sets the default appearance font size. A value of zero specifies that the font size should should adjust so that the text uses as much of the FreeText bounding box as possible.

    Declaration

    Objective-C

    - (void)SetFontSize:(double)font_size;

    Swift

    func setFontSize(_ font_size: Double)

    Parameters

    font_size

    Set the default font size. A value of zero means auto resize font.

  • Get the default appearance font size. To get the actual font size used, call RefreshAppearance and then use ElementReader on the content stream of this annotation.

    Declaration

    Objective-C

    - (double)GetFontSize;

    Swift

    func getFontSize() -> Double

    Return Value

    the default font size, where a value of zero indicates auto sizing.

  • Returns the default style string.

    Declaration

    Objective-C

    - (nullable NSString *)GetDefaultStyle;

    Swift

    func getDefaultStyle() -> String?

    Return Value

    the default style string, or nil if the annotation does not have a default style.

  • Sets the default style string.

    Declaration

    Objective-C

    - (void)SetDefaultStyle:(nullable NSString *)defaultStyle;

    Swift

    func setDefaultStyle(_ defaultStyle: String?)

    Parameters

    defaultStyle

    The default style string, or nil to clear the default style.

  • Returns the name of the font specified in the default style of the annotation.

    See

    GetDefaultStyle

    Declaration

    Objective-C

    - (nullable NSString *)GetDefaultStyleFontName;

    Swift

    func getDefaultStyleFontName() -> String?

    Return Value

    the name of the font specified in the default style of the annotation

  • Returns the color specified in the default style of the annotation.

    See

    GetDefaultStyle

    Declaration

    Objective-C

    - (nullable UIColor *)GetDefaultStyleColor;

    Swift

    func getDefaultStyleColor() -> UIColor?

    Return Value

    The color specified in the default style of the annotation, or nil if the default style has no color.

  • Returns the rich contents of the free text annotation.

    Declaration

    Objective-C

    - (nullable NSString *)GetRichContents;

    Swift

    func getRichContents() -> String?

    Return Value

    The rich contents of the annotation as a string, or nil if the annotation does not have its rich contents set.

  • Sets the rich contents for the free text annotation.

    Declaration

    Objective-C

    - (void)SetRichContents:(nullable NSString *)richContents;

    Swift

    func setRichContents(_ richContents: String?)

    Parameters

    richContents

    The rich contents for the annotation, or nil to clear the rich contents.

  • Determines whether the border color of the free text annotation is using a non-standard format.

    Declaration

    Objective-C

    - (BOOL)HasNonStandardBorderColor;

    Swift

    func hasNonStandardBorderColor() -> Bool

    Return Value

    YES if the border color is using a non-standard format, NO otherwise.

  • Undocumented

    Declaration

    Objective-C

    - (NSAttributedString *)GetAttributedStringContents;

    Swift

    func getAttributedStringContents() -> NSAttributedString
  • Undocumented

    Declaration

    Objective-C

    - (NSInteger)GetDefaultStyleVerticalAlignment;

    Swift

    func getDefaultStyleVerticalAlignment() -> Int
  • Undocumented

    Declaration

    Objective-C

    - (void)SetDefaultStyleVerticalAlignment:(NSInteger)verticalAlignment;

    Swift

    func setDefaultStyleVerticalAlignment(_ verticalAlignment: Int)
  • Sets the free text annotation to use the font specified. The font must be available on the device https://developer.apple.com/fonts/system-fonts/

    Note

    -RefreshAppearance must be called after this method to generate the new appearance.

    Note

    This method writes to the PDFDoc, so a write lock is required if the document is displayed in a viewer or otherwise accessible via multiple threads. Without a write lock, undefined behaviour including crashing is likely to occur.

    Declaration

    Objective-C

    - (void)setFontWithName:(nonnull NSString *)fontName
                     pdfDoc:(nonnull PTPDFDoc *)doc;

    Swift

    func setFontWithName(_ fontName: String, pdfDoc doc: PTPDFDoc)

    Parameters

    fontName

    The name of the font.

    doc

    The PDF document that the annotation is part of.

  • Returns the name of the font used by this annotation.

    Declaration

    Objective-C

    - (nullable NSString *)getFontName;

    Swift

    func getFontName() -> String?

    Return Value

    The name of the font. If no font name is specified, this method returns nil.