//--------------------------------------------------------------------------------------- // Copyright (c) 2001-2025 by Apryse Software Inc. All Rights Reserved. // Consult legal.txt regarding legal and license information. //--------------------------------------------------------------------------------------- #ifndef PDFTRON_H_CPPPDFAnnotsFreeText #define PDFTRON_H_CPPPDFAnnotsFreeText #include #include #ifdef SWIG #define Line LineAnnot #endif namespace pdftron { namespace PDF { namespace Annots { /** * 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. */ class FreeText : public Markup { public: /** * Creates a FreeText annotation and initializes it using given Cos/SDF object. * @param d The Cos/SDF object to initialze the annotation with. * @note The constructor does not copy any data, but is instead the logical * equivalent of a type cast. */ FreeText(SDF::Obj d = 0); /** * Creates a FreeText annotation and initializes it using given annotation object. * @param ann Annot object used to initialize the FreeText annotation. * @note The constructor does not copy any data, but is instead the logical * equivalent of a type cast. */ FreeText(const Annot& ann) : Markup(ann.GetSDFObj()) {} /** * Creates a new FreeText annotation in the specified document. * * @param doc A document to which the FreeText annotation is added. * @param pos A rectangle specifying the FreeText annotation's bounds in default user space units. * * @return A newly created blank FreeText annotation. */ static FreeText Create(SDF::SDFDoc& doc, const Rect& pos); static FreeText CreateAnnot(SDF::SDFDoc& doc, const Rect& pos); /** * Returns the default appearance of the FreeText annotation. * * @return A string representing the default appearance of the 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. */ UString GetDefaultAppearance() const; /** * Sets the default appearance of the FreeText annotation. * * @param app_str A string representing the default appearance of the 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. */ void SetDefaultAppearance(const char* app_str); /** * Returns the quading format of the FreeText annotation. * (PDF 1.4) * * @return A int (code) indicating the quading format of the FreeText annotation. * @note The following are the quading formats corresponding to each int code. * 0 Left-justified * 1 Centered * 2 Right-justified */ int GetQuaddingFormat() const; /** * Sets the quading format of the FreeText annotation. * (Optional; PDF 1.4) * * @param format A int code indicating the quading format of the FreeText annotation. * Default value: 0 (left-justified). * @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 */ void SetQuaddingFormat(const int format); /** * Returns the callout line points of the FreeText annotation. * (PDF 1.6) * * @param p1 The target point. (where the ending style is used) * @param p2 The ending point. * @param p3 The knee point. * @return Three point objects if the line is bent or two point objects if * the line is straight. * @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. */ Point GetCalloutLinePoint1() const; Point GetCalloutLinePoint2() const; Point GetCalloutLinePoint3() const; #ifndef SWIG /** * Returns the callout line points of the FreeText annotation. * (PDF 1.6) * * @param p1 The target point. (where the ending style is used) * @param p2 The ending point. * @param p3 The knee point. * @return Three point objects if the line is bent or two point objects if * the line is straight. * @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. */ void GetCalloutLinePoints(Point& p1, Point& p2, Point& p3) const; #endif /** * Sets the callout line points of the FreeText annotation. * (Optional; meaningful only if IT is FreeTextCallout; PDF 1.6) * * @param p1 The target point. (where the ending style is used) * @param p2 The knee point. * @param p3 The ending point. * @note The coordinates are defined in default user space. */ void SetCalloutLinePoints(const Point& p1, const Point& p2, const Point& p3); /** * Sets the callout line points of the FreeText annotation. * (Optional; meaningful only if IT is FreeTextCallout; PDF 1.6) * * @param p1 The target point. (where the ending style is used) * @param p2 The ending point. * @note The coordinates are defined in default user space. */ void SetCalloutLinePoints(const Point& p1, const Point& p2); /** * This enum defines the intention of the FreeText annotation */ enum IntentName { e_FreeText, /// #endif // PDFTRON_H_CPPPDFAnnotsFreeText