modern-pdf-lib / DrawTextOptions
Interface: DrawTextOptions
Defined in: src/core/pdfPage.ts:173
Options for PdfPage.drawText.
Properties
blendMode?
optionalblendMode:BlendMode
Defined in: src/core/pdfPage.ts:199
Blend mode for compositing.
color?
optionalcolor:Color
Defined in: src/core/pdfPage.ts:191
Text colour. Defaults to black.
font?
optionalfont:string|FontRef
Defined in: src/core/pdfPage.ts:187
Font to use for rendering.
Accepts either a FontRef object (returned by doc.embedFont()) or a font resource name string (e.g. 'F1').
When a FontRef is provided, its name property is used as the resource name and its CID encoder (if any) is used automatically.
lineHeight?
optionallineHeight:number
Defined in: src/core/pdfPage.ts:195
Line height for multi-line text.
maxWidth?
optionalmaxWidth:number
Defined in: src/core/pdfPage.ts:216
Maximum width in points before text is automatically wrapped.
When provided with a FontRef font (which has widthOfTextAtSize), the text is broken at word boundaries to fit within this width. If a single word exceeds maxWidth, it is broken at character level.
When the font is a plain string (no measurement available), this option is ignored.
opacity?
optionalopacity:number
Defined in: src/core/pdfPage.ts:197
Opacity [0, 1].
renderingMode?
optionalrenderingMode:TextRenderingMode
Defined in: src/core/pdfPage.ts:201
Text rendering mode (fill, stroke, invisible, clip, etc.).
rotate?
optionalrotate:Angle
Defined in: src/core/pdfPage.ts:193
Rotation angle.
size?
optionalsize:number
Defined in: src/core/pdfPage.ts:189
Font size in points.
wordBreaks?
optionalwordBreaks:string[]
Defined in: src/core/pdfPage.ts:227
Characters at which text may be broken when wrapping.
Defaults to [' '] (space only). Pass additional characters such as [' ', '-', '/'] to allow breaks at hyphens, slashes, etc.
The break character is kept at the end of the preceding line (e.g. 'hello-' / 'world'), except for space which is consumed as in the default behaviour.
x?
optionalx:number
Defined in: src/core/pdfPage.ts:175
X coordinate.
xSkew?
optionalxSkew:Angle
Defined in: src/core/pdfPage.ts:203
Horizontal skew angle (italic-like effect).
y?
optionaly:number
Defined in: src/core/pdfPage.ts:177
Y coordinate.
ySkew?
optionalySkew:Angle
Defined in: src/core/pdfPage.ts:205
Vertical skew angle.