modern-pdf-lib / PdfFreeTextAnnotation
Class: PdfFreeTextAnnotation
Defined in: src/annotation/types/freeTextAnnotation.ts:51
A free text annotation (subtype /FreeText).
Displays text directly on the page as if it were part of the page content. Does not require opening a popup.
Extends
Constructors
Constructor
new PdfFreeTextAnnotation(
dict):PdfFreeTextAnnotation
Defined in: src/annotation/types/freeTextAnnotation.ts:52
Parameters
dict
Returns
PdfFreeTextAnnotation
Overrides
Properties
annotationType
readonlyannotationType:AnnotationType
Defined in: src/annotation/pdfAnnotation.ts:227
The annotation subtype.
Inherited from
dict
protecteddict:PdfDict
Defined in: src/annotation/pdfAnnotation.ts:230
The underlying annotation dictionary.
Inherited from
Methods
generateAppearance()
generateAppearance():
PdfStream
Defined in: src/annotation/types/freeTextAnnotation.ts:181
Generate the appearance stream for this free text annotation.
Returns
Overrides
PdfAnnotation.generateAppearance
getAlignment()
getAlignment():
FreeTextAlignment
Defined in: src/annotation/types/freeTextAnnotation.ts:145
Get the text alignment. Defaults to 'left'.
Returns
getAuthor()
getAuthor():
string|undefined
Defined in: src/annotation/pdfAnnotation.ts:293
Get the author (PDF /T entry).
Returns
string | undefined
Inherited from
getColor()
getColor(): {
b:number;g:number;r:number; } |undefined
Defined in: src/annotation/pdfAnnotation.ts:311
Get the annotation colour.
Returns
{ b: number; g: number; r: number; } | undefined
Inherited from
getContents()
getContents():
string|undefined
Defined in: src/annotation/pdfAnnotation.ts:275
Get the text contents (tooltip / popup text).
Returns
string | undefined
Inherited from
getDefaultAppearance()
getDefaultAppearance():
string
Defined in: src/annotation/types/freeTextAnnotation.ts:163
Get the default appearance string (/DA).
Returns
string
getFontSize()
getFontSize():
number
Defined in: src/annotation/types/freeTextAnnotation.ts:114
Get the font size from the default appearance string.
Returns
number
getOpacity()
getOpacity():
number
Defined in: src/annotation/pdfAnnotation.ts:333
Get the annotation opacity (0-1). Defaults to 1.
Returns
number
Inherited from
getRect()
getRect(): [
number,number,number,number]
Defined in: src/annotation/pdfAnnotation.ts:251
Get the annotation rectangle [x1, y1, x2, y2].
Returns
[number, number, number, number]
Inherited from
getText()
getText():
string
Defined in: src/annotation/types/freeTextAnnotation.ts:100
Get the displayed text.
Returns
string
getType()
getType():
AnnotationType
Defined in: src/annotation/pdfAnnotation.ts:242
Get the annotation subtype.
Returns
Inherited from
isHidden()
isHidden():
boolean
Defined in: src/annotation/pdfAnnotation.ts:381
Whether the annotation is hidden.
Returns
boolean
Inherited from
isLocked()
isLocked():
boolean
Defined in: src/annotation/pdfAnnotation.ts:401
Whether the annotation is locked (cannot be moved/resized).
Returns
boolean
Inherited from
isPrintable()
isPrintable():
boolean
Defined in: src/annotation/pdfAnnotation.ts:391
Whether the annotation should be printed.
Returns
boolean
Inherited from
setAlignment()
setAlignment(
align):void
Defined in: src/annotation/types/freeTextAnnotation.ts:154
Set the text alignment.
Parameters
align
Returns
void
setAuthor()
setAuthor(
author):void
Defined in: src/annotation/pdfAnnotation.ts:302
Set the author.
Parameters
author
string
Returns
void
Inherited from
setColor()
setColor(
color):void
Defined in: src/annotation/pdfAnnotation.ts:324
Set the annotation colour.
Parameters
color
b
number
g
number
r
number
Returns
void
Inherited from
setContents()
setContents(
contents):void
Defined in: src/annotation/pdfAnnotation.ts:284
Set the text contents.
Parameters
contents
string
Returns
void
Inherited from
setDefaultAppearance()
setDefaultAppearance(
da):void
Defined in: src/annotation/types/freeTextAnnotation.ts:172
Set the default appearance string.
Parameters
da
string
Returns
void
setFontSize()
setFontSize(
size):void
Defined in: src/annotation/types/freeTextAnnotation.ts:125
Set the font size (rebuilds the default appearance string).
Parameters
size
number
Returns
void
setHidden()
setHidden(
hidden):void
Defined in: src/annotation/pdfAnnotation.ts:386
Set the hidden flag.
Parameters
hidden
boolean
Returns
void
Inherited from
setLocked()
setLocked(
locked):void
Defined in: src/annotation/pdfAnnotation.ts:406
Set the locked flag.
Parameters
locked
boolean
Returns
void
Inherited from
setOpacity()
setOpacity(
opacity):void
Defined in: src/annotation/pdfAnnotation.ts:342
Set the annotation opacity.
Parameters
opacity
number
Returns
void
Inherited from
setPrintable()
setPrintable(
printable):void
Defined in: src/annotation/pdfAnnotation.ts:396
Set the print flag.
Parameters
printable
boolean
Returns
void
Inherited from
setRect()
setRect(
rect):void
Defined in: src/annotation/pdfAnnotation.ts:266
Set the annotation rectangle.
Parameters
rect
[number, number, number, number]
Returns
void
Inherited from
setText()
setText(
text):void
Defined in: src/annotation/types/freeTextAnnotation.ts:105
Set the displayed text.
Parameters
text
string
Returns
void
toDict()
toDict(
registry):PdfDict
Defined in: src/annotation/pdfAnnotation.ts:420
Convert this annotation to a PdfDict suitable for embedding in a PDF.
Parameters
registry
The object registry (used to register sub-objects).
Returns
The annotation dictionary.
Inherited from
create()
staticcreate(options):PdfFreeTextAnnotation
Defined in: src/annotation/types/freeTextAnnotation.ts:59
Create a new free text annotation.
Parameters
options
AnnotationOptions & object
Returns
PdfFreeTextAnnotation
fromDict()
staticfromDict(dict,resolver?):PdfFreeTextAnnotation
Defined in: src/annotation/types/freeTextAnnotation.ts:88
Create from an existing dictionary.
Parameters
dict
resolver?
(ref) => PdfObject | undefined
Returns
PdfFreeTextAnnotation