You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/text.md
+7-2Lines changed: 7 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -86,6 +86,7 @@ below.
86
86
*`lineBreak` - set to `false` to disable line wrapping all together
87
87
*`width` - the width that text should be wrapped to (by default, the page width minus the left and right margin)
88
88
*`height` - the maximum height that text should be clipped to
89
+
*`rotation` - the rotation of the text in degrees (by default 0)
89
90
*`ellipsis` - the character to display at the end of the text when it is too long. Set to `true` to use the default character.
90
91
*`columns` - the number of columns to flow the text into
91
92
*`columnGap` - the amount of space between each column (1/4 inch by default)
@@ -132,10 +133,14 @@ The output looks like this:
132
133
## Text measurements
133
134
134
135
If you're working with documents that require precise layout, you may need to know the
135
-
size of a piece of text. PDFKit has two methods to achieve this: `widthOfString(text, options)`
136
-
and`heightOfString(text, options)`. Both methods use the same options described in the
136
+
size of a piece of text. PDFKit has three methods to achieve this: `widthOfString(text, options)`
137
+
,`heightOfString(text, options)` and `boundsOfString(text, options)/boundsOfString(text, x, y, options)`. All methods use the same options described in the
137
138
Text styling section, and take into account the eventual line wrapping.
138
139
140
+
However `boundsOfString` factors in text rotations and multi-line wrapped text,
141
+
effectively producing the bounding box of the text, `{x: number, y: number, width: number, height: number}`.
142
+
If `x` and `y` are not defined they will default to use `this.x` and `this.y`.
143
+
139
144
## Lists
140
145
141
146
The `list` method creates a bulleted list. It accepts as arguments an array of strings,
0 commit comments