setasign\SetaPDF2\Core\Document\Page\Annotation

FreeTextAnnotation Class representing a free text annotation

File: /SetaPDF v2/Core/Document/Page/Annotation/FreeTextAnnotation.php
Old class name (alias): \SetaPDF_Core_Document_Page_Annotation_FreeText

See PDF 32000-1:2008 - 12.5.6.6

Class hierarchy

Summary

Constants

INTENT_FREE_TEXT

public const string FreeTextAnnotation::INTENT_FREE_TEXT = 'FreeText'

Intent constant

INTENT_FREE_TEXT_CALLOUT

public const string FreeTextAnnotation::INTENT_FREE_TEXT_CALLOUT = 'FreeTextCallout'

Intent constant

INTENT_FREE_TEXT_TYPE_WRITER

public const string FreeTextAnnotation::INTENT_FREE_TEXT_TYPE_WRITER = 'FreeTextTypeWriter'

Intent constant

TYPE_3D

public const string Annotation::TYPE_3D = '3D'

Annotation type

TYPE_CARET

public const string Annotation::TYPE_CARET = 'Caret'

Annotation type

TYPE_CIRCLE

public const string Annotation::TYPE_CIRCLE = 'Circle'

Annotation type

TYPE_FILE_ATTACHMENT

public const string Annotation::TYPE_FILE_ATTACHMENT = 'FileAttachment'

Annotation type

TYPE_FREE_TEXT

public const string Annotation::TYPE_FREE_TEXT = 'FreeText'

Annotation type

TYPE_HIGHLIGHT

public const string Annotation::TYPE_HIGHLIGHT = 'Highlight'

Annotation type

TYPE_INK

public const string Annotation::TYPE_INK = 'Ink'

Annotation type

TYPE_LINE

public const string Annotation::TYPE_LINE = 'Line'

Annotation type

TYPE_LINK

public const string Annotation::TYPE_LINK = 'Link'

Annotation type

TYPE_MOVIE

public const string Annotation::TYPE_MOVIE = 'Movie'

Annotation type

TYPE_POLYGON

public const string Annotation::TYPE_POLYGON = 'Polygon'

Annotation type

TYPE_POLY_LINE

public const string Annotation::TYPE_POLY_LINE = 'PolyLine'

Annotation type

TYPE_POPUP

public const string Annotation::TYPE_POPUP = 'Popup'

Annotation type

TYPE_PRINTER_MARK

public const string Annotation::TYPE_PRINTER_MARK = 'PrinterMark'

Annotation type

TYPE_REDACT

public const string Annotation::TYPE_REDACT = 'Redact'

Annotation type

TYPE_SCREEN

public const string Annotation::TYPE_SCREEN = 'Screen'

Annotation type

TYPE_SOUND

public const string Annotation::TYPE_SOUND = 'Sound'

Annotation type

TYPE_SQUARE

public const string Annotation::TYPE_SQUARE = 'Square'

Annotation type

TYPE_SQUIGGLY

public const string Annotation::TYPE_SQUIGGLY = 'Squiggly'

Annotation type

TYPE_STAMP

public const string Annotation::TYPE_STAMP = 'Stamp'

Annotation type

TYPE_STRIKE_OUT

public const string Annotation::TYPE_STRIKE_OUT = 'StrikeOut'

Annotation type

TYPE_TEXT

public const string Annotation::TYPE_TEXT = 'Text'

Annotation type

TYPE_TRAP_NET

public const string Annotation::TYPE_TRAP_NET = 'TrapNet'

Annotation type

TYPE_UNDERLINE

public const string Annotation::TYPE_UNDERLINE = 'Underline'

Annotation type

TYPE_WATERMARK

public const string Annotation::TYPE_WATERMARK = 'Watermark'

Annotation type

TYPE_WIDGET

public const string Annotation::TYPE_WIDGET = 'Widget'

Annotation type


Properties

$_annotationDictionary

The annotation dictionary

$_rect


Static Methods

_createAnnotationDictionary()

Creates an annotation dictionary with default values.

Parameters
$rect : \SetaPDF_Core_DataStructure_Rectangle|array
 
$subtype : string
 

byObjectOrDictionary()

Creates an annotation object by an annotation dictionary or its parent object.

Parameters
$objectOrDictionary : \SetaPDF_Core_Type_Dictionary|\SetaPDF_Core_Type_IndirectObjectInterface
 
Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

Throws \InvalidArgumentException

createAnnotationDictionary()

public static FreeTextAnnotation::createAnnotationDictionary (
\SetaPDF_Core_DataStructure_Rectangle|array $rect,
string $fontName,
int|float $fontSize = 12,
int|float|string|array|\SetaPDF_Core_Type_Array|\SetaPDF_Core_DataStructure_Color $color = 0
): \SetaPDF_Core_Type_Dictionary

Creates an annotation dictionary.

Parameters
$rect : \SetaPDF_Core_DataStructure_Rectangle|array
 
$fontName : string

The font name, which is registered in the AcroForm DR dictionary.

$fontSize : int|float

The font size

$color : int|float|string|array|\SetaPDF_Core_Type_Array|\SetaPDF_Core_DataStructure_Color

See \setasign\SetaPDF2\Core\DataStructure\Color\AbstractColor::createByComponents() for more details.

Exceptions

Throws \InvalidArgumentException


Methods

__construct()

The constructor.

If the parameter cannot be resolved as a dictionary all parameters were passed to the self::createAnnotationDictionary() method.

Parameters
$objectOrDictionary : array|\SetaPDF_Core_Type_AbstractType|\SetaPDF_Core_Type_Dictionary|\SetaPDF_Core_Type_IndirectObjectInterface
 
Exceptions

Throws \InvalidArgumentException

Throws \setasign\SetaPDF2\Core\Type\Exception

_getReplies()

private MarkupAnnotation::_getReplies (
\SetaPDF_Core_Document_Page_Annotations $annotations,
bool $onlyCheckForExistance
): array|bool

Get all replies or checks for their existance.

Parameters
$annotations : \SetaPDF_Core_Document_Page_Annotations
 
$onlyCheckForExistance : bool
 
Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

addReply()

Adds a reply to this annotation.

Parameters
$annotation : \SetaPDF_Core_Document_Page_Annotation_Markup
 

cleanUp()

public FreeTextAnnotation::cleanUp (
void
): void

Release cycled references.

createPopup()

public MarkupAnnotation::createPopup (
int|float $offsetX = 30,
int|float $offsetY = 20,
int|float $width = 150,
int|float $height = 100
): \SetaPDF_Core_Document_Page_Annotation_Popup

Create a popup annotation object for this annotation.

If the x-offset value is less than zero the popup will be created at the left side of the main annotation. Otherwise on the right side. If the y-offset value is less than zero the popup will be create down below the main annotation. Otherwise above.

You need to re-add this new popup annotation to its origin annotation by passing it to the addPopup() method after assigning it to the page object.

Parameters
$offsetX : int|float
 
$offsetY : int|float
 
$width : int|float
 
$height : int|float
 
Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

getAdditionalActions()

Gets the additional actions object instance for this annotation.

getAlign()

public FreeTextAnnotation::getAlign (
void
): mixed|string

Get the form of quadding (justification / align) that shall be used in displaying the annotation’s text.

Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

getAnnotationDictionary()

WARNING: This method is marked as deprecated!

Get the annotation dictionary.

getAppearance()

public Annotation::getAppearance (
string $type = 'N',
?string $subName = null
): ?\SetaPDF_Core_XObject_Form

Get the annotation appearance stream.

Parameters
$type : string
 
$subName : ?string
 
Exceptions

Throws \InvalidArgumentException

getBorderEffect()

Get the border effect object.

Parameters
$create : bool
 

getBorderStyle()

getCalloutLine()

public FreeTextAnnotation::getCalloutLine (
void
): ?array

Get the array of four or six numbers specifying a callout line attached to the free text annotation.

getColor()

Get the color of the annotation.

getContents()

public Annotation::getContents (
string $encoding = 'UTF-8'
): ?string

Get the contents of the annotation.

Parameters
$encoding : string
 

getCreationDate()

public MarkupAnnotation::getCreationDate (
bool $asString = true
): null|mixed|\SetaPDF_Core_DataStructure_Date

Get the creation date.

The date and time when the annotation was created.
Parameters
$asString : bool

Whether receive the value as a string (PDF date string) or as a \setasign\SetaPDF2\Core\DataStructure\Date instance.

Exceptions

Throws \Exception

See

getDictionary()

Get the annotation dictionary.

getDifferencesRect()

Get the rectangle describing the difference between the Rect entry and the inner text rectangle.

getHeight()

public Annotation::getHeight (
void
): float|int

Get the height of the annotation.

Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

getHiddenFlag()

public Annotation::getHiddenFlag (
void
): bool

Checks for the "Hidden" flag.

PDF 32000-1:2008 - Table 165: "If set, do not display or print the annotation or allow it to interact with the user, regardless of its annotation type or whether an annotation handler is available."

getInReplyTo()

Get the in reply to annotation (if available).

Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

See

getIndirectObject()

Get the indirect object of this annotation.

Parameters
$document : ?\SetaPDF_Core_Document
 

getIntent()

public FreeTextAnnotation::getIntent (
void
): string

Get the name describing the intent of the free text annotation.

getInvisibleFlag()

public Annotation::getInvisibleFlag (
void
): bool

Checks for the "Invisible" flag.

PDF 32000-1:2008 - Table 165: "If set, do not display the annotation if it does not belong to one of the standard annotation types and no annotation handler is available. If clear, display such an unknown annotation using an appearance stream specified by its appearance dictionary, if any"

getLineEndingStyle()

public FreeTextAnnotation::getLineEndingStyle (
void
): string

Get the line ending style.

getLockedContents()

public Annotation::getLockedContents (
void
): bool

Checks for the "LockedContents" flag.

PDF 32000-1:2008 - Table 165: "If set, do not allow the contents of the annotation to be modified by the user. This flag does not restrict deletion of the annotation or changes to other annotation properties, such as position and size."

getLockedFlag()

public Annotation::getLockedFlag (
void
): bool

Checks the "Locked" flag.

PDF 32000-1:2008 - Table 165: "If set, do not allow the annotation to be deleted or its properties (including position and size) to be modified by the user. However, this flag does not restrict changes to the annotation’s contents, such as the value of a form field."

getModificationDate()

public Annotation::getModificationDate (
bool $asString = true
): mixed|null|\SetaPDF_Core_DataStructure_Date

Get the modification date.

Parameters
$asString : bool
 
Exceptions

Throws \Exception

getName()

public Annotation::getName (
string $encoding = 'UTF-8'
): ?string

Get the name of the annotation.

Parameters
$encoding : string
 

getNoRotateFlag()

public Annotation::getNoRotateFlag (
void
): bool

Checks fo the "NoRotate" flag.

PDF 32000-1:2008 - Table 165: "If set, do not rotate the annotation’s appearance to match the rotation of the page. The upper-left corner of the annotation rectangle shall remain in a fixed location on the page, regardless of the page rotation."

getNoViewFlag()

public Annotation::getNoViewFlag (
void
): bool

Checks for the "NoView" flag.

PDF 32000-1:2008 - Table 165: "If set, do not display the annotation on the screen or allow it to interact with the user. The annotation may be printed (depending on the setting of the Print flag) but should be considered hidden for purposes of on-screen display and user interaction."

getNoZoomFlag()

public Annotation::getNoZoomFlag (
void
): bool

Checks fo the "NoZoom" flag.

PDF 32000-1:2008 - Table 165: "If set, do not scale the annotation’s appearance to match the magnification of the page. The location of the annotation on the page (defined by the upper- left corner of its annotation rectangle) shall remain fixed, regardless of the page magnification."

getOpacity()

public MarkupAnnotation::getOpacity (
void
): float|mixed

Get the constant opacity value.

getPopup()

Get the associated popup object if available.

Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

getPrintFlag()

public Annotation::getPrintFlag (
void
): bool

Checks for the "Print" flag.

PDF 32000-1:2008 - Table 165: "If set, print the annotation when the page is printed. If clear, never print the annotation, regardless of whether it is displayed on the screen."

getReadOnlyFlag()

public Annotation::getReadOnlyFlag (
void
): bool

Checks the "ReadOnly" flag.

PDF 32000-1:2008 - Table 165: "If set, do not allow the annotation to interact with the user. The annotation may be displayed or printed (depending on the settings of the NoView and Print flags) but should not respond to mouse clicks or change its appearance in response to mouse motions.

This flag shall be ignored for widget annotations; its function is subsumed by the ReadOnly flag of the associated form field"

getRect()

Get the rectangle object of this annotation.

getReplies()

Get all annotations which refer this annotation as an reply.

Parameters
$annotations : \SetaPDF_Core_Document_Page_Annotations
 
Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

getSubject()

public MarkupAnnotation::getSubject (
string $encoding = 'UTF-8'
): ?string

Get the subject.

Text representing a short description of the subject being addressed by the annotation.
Parameters
$encoding : string
 
See

getTextLabel()

public MarkupAnnotation::getTextLabel (
string $encoding = 'UTF-8'
): ?string

Get the text label.

The text label that shall be displayed in the title bar of the annotation’s pop-up window when open and active. This entry shall identify the user who added the annotation.
Parameters
$encoding : string
 
See

getToggleNoView()

public Annotation::getToggleNoView (
void
): bool

Checks for the "ToggleNoView" flag.

PDF 32000-1:2008 - Table 165: "If set, invert the interpretation of the NoView flag for certain events."

getType()

public Annotation::getType (
void
): string

Get the annotation type specified in the Subtype entry.

getWidth()

public Annotation::getWidth (
void
): float|int

Get the width of the annotation.

Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

hasReplies()

Check whether this annotation has a reply or not.

Parameters
$annotations : \SetaPDF_Core_Document_Page_Annotations
 
Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

isAnnotationFlagSet()

public Annotation::isAnnotationFlagSet (
int $flag
): bool

Checks if a specific annotation flag is set.

Parameters
$flag : int
 

isReplyTo()

public MarkupAnnotation::isReplyTo (
void
): bool

Checks if this annotation is a reply to another annotation.

setAlign()

public FreeTextAnnotation::setAlign (
string $align
): void

Set the form of quadding (justification / align) that shall be used in displaying the annotation’s text.

Parameters
$align : string
 
See

setAnnotationFlags()

public Annotation::setAnnotationFlags (
int $flags,
bool $set = true
): void

Sets an annotation flag.

Parameters
$flags : int
 
$set : bool

Set or unset

setAppearance()

public Annotation::setAppearance (
\SetaPDF_Core_XObject_Form $xObject,
string $type = 'N',
?string $subState = null
): void

Set the annotation appearance stream.

Parameters
$xObject : \SetaPDF_Core_XObject_Form
 
$type : string
 
$subState : ?string
 

setCalloutLine()

public FreeTextAnnotation::setCalloutLine (
array<int|float>|false $x1OrPoints,
null|int|float $y1 = null,
null|int|float $x2 = null,
null|int|float $y2 = null,
null|int|float $x3 = null,
null|int|float $y3 = null
): void

Set the array of four or six numbers specifying a callout line attached to the free text annotation.

1    2
<---\
     \
      \
       3
Parameters
$x1OrPoints : array<int|float>|false
 
$y1 : null|int|float
 
$x2 : null|int|float
 
$y2 : null|int|float
 
$x3 : null|int|float
 
$y3 : null|int|float
 

setColor()

public Annotation::setColor (
null|bool|int|float|string|array|\SetaPDF_Core_DataStructure_Color $color
): void

Set the color of the annotation.

Parameters
$color : null|bool|int|float|string|array|\SetaPDF_Core_DataStructure_Color
 

setContents()

public Annotation::setContents (
?string $contents,
string $encoding = 'UTF-8'
): void

Set the contents of the annotation.

Parameters
$contents : ?string
 
$encoding : string
 

setCreationDate()

Set the creation date.

Parameters
$date : null|bool|string|\DateTime|\SetaPDF_Core_Type_String|\SetaPDF_Core_DataStructure_Date
 
Exceptions

Throws \Exception

See

setDifferencesRect()

Set the rectangle describing the difference between the Rect entry and the inner text rectangle.

PDF 32000-1:2008 - Table 174

The four numbers correspond to the differences in default user space between the left, top, right, and bottom coordinates of Rect and those of the inner rectangle, respectively. Each value shall be greater than or equal to 0. The sum of the top and bottom differences shall be less than the height of Rect, and the sum of the left and right differences shall be less than the width of Rect.
Parameters
$differencesRect : \SetaPDF_Core_DataStructure_Rectangle
 

setHiddenFlag()

public Annotation::setHiddenFlag (
bool $hidden = true
): void

Set the "Hidden" flag.

Parameters
$hidden : bool
 
See

setInReplyTo()

Set the in reply to annotation object.

Parameters
$annotation : \SetaPDF_Core_Document_Page_Annotation_Markup
 
Exceptions

Throws \InvalidArgumentException

See

setIntent()

public FreeTextAnnotation::setIntent (
string $intent
): void

Set the name describing the intent of the free text annotation.

Parameters
$intent : string
 

setInvisibleFlag()

public Annotation::setInvisibleFlag (
bool $invisible = true
): void

Set the "Invisible" flag.

Parameters
$invisible : bool
 
See

setLineEndingStyle()

public FreeTextAnnotation::setLineEndingStyle (
string $lineEndingStyle
): void

Set the line ending styles.

Parameters
$lineEndingStyle : string
 
See

setLocked()

public Annotation::setLocked (
bool $locked = true
): void

Set the "Locked" flag.

Parameters
$locked : bool
 
See

setLockedContents()

public Annotation::setLockedContents (
bool $lockedContents = true
): void

Set the "LockedContents" flag.

Parameters
$lockedContents : bool
 
See

setModificationDate()

Set the modification date.

Parameters
$date : \SetaPDF_Core_DataStructure_Date|\DateTime|string|bool

If true is passed, the current date and time will be used.

Exceptions

Throws \Exception

setName()

public Annotation::setName (
?string $name,
string $encoding = 'UTF-8'
): void

Set the name of the annotation.

The annotation name, a text string uniquely identifying it among all the annotations on its page.

Parameters
$name : ?string
 
$encoding : string
 

setNoRotateFlag()

public Annotation::setNoRotateFlag (
bool $noRotate = true
): void

Set the "NoRotate" flag.

Parameters
$noRotate : bool
 
See

setNoViewFlag()

public Annotation::setNoViewFlag (
bool $noView = true
): void

Set the "NoView" flag.

Parameters
$noView : bool
 
See

setNoZoomFlag()

public Annotation::setNoZoomFlag (
bool $noZoom = true
): void

Set the "NoZoom" flag.

Parameters
$noZoom : bool
 
See

setOpacity()

public MarkupAnnotation::setOpacity (
?float $opacity
): void

Set the constant opacity value.

Parameters
$opacity : ?float
 

setPopup()

Set the pop-up annotation object.

Parameters
$annotation : \SetaPDF_Core_Document_Page_Annotation_Popup
 
Exceptions

Throws \InvalidArgumentException

setPrintFlag()

public Annotation::setPrintFlag (
bool $print = true
): void

Set the "Print" flag.

Parameters
$print : bool
 
See

setReadOnlyFlag()

public Annotation::setReadOnlyFlag (
bool $readOnly = true
): void

Set the "ReadOnly" flag.

Parameters
$readOnly : bool
 
See

setRect()

Set the rectangle object.

Parameters
$rect : \SetaPDF_Core_DataStructure_Rectangle
 

setSubject()

public MarkupAnnotation::setSubject (
?string $subject,
string $encoding = 'UTF-8'
): void

Get the subject.

Parameters
$subject : ?string
 
$encoding : string
 
See

setTextLabel()

public MarkupAnnotation::setTextLabel (
?string $textLabel,
string $encoding = 'UTF-8'
): void

Set the text label.

Parameters
$textLabel : ?string
 
$encoding : string
 
See

setToggleNoView()

public Annotation::setToggleNoView (
bool $toggleNoView = true
): void

Set the "ToggleNoView" flag.

Parameters
$toggleNoView : bool
 
See

unsetAnnotationFlags()

public Annotation::unsetAnnotationFlags (
int $flags
): void

Removes a field flag.

Parameters
$flags : int