Skip to content

Commit 1b678c3

Browse files
kevinhendliborm85
andauthored
Indent after linebreak (#879)
* add indentAllLines option to indent all lines of a paragraph instead of only the first one * update comments * Update CHANGELOG.md --------- Co-authored-by: Libor M. <[email protected]>
1 parent 133a321 commit 1b678c3

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- Update linebreak to 1.1
77
- Add support for spot colors
88
- Add support to scale text horizontally
9+
- Add an option to keep the indentation after a new line starts and allow to indent a whole paragraph/text element
910
- Fix sets tab order to "Structure" when a document is tagged
1011
- Fix font cache collision for fonts with missing postscript name or bad TTF metadata
1112
- Fix measuring text when OpenType features are passed in to .text()

docs/text.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ below.
9090
* `columns` - the number of columns to flow the text into
9191
* `columnGap` - the amount of space between each column (1/4 inch by default)
9292
* `indent` - the amount in PDF points (72 per inch) to indent each paragraph of text
93+
* `indentAllLines` - wheter to indent all lines of a paragraph (`false` by default - indents only the first line)
9394
* `paragraphGap` - the amount of space between each paragraph of text
9495
* `lineGap` - the amount of space between each line of text
9596
* `wordSpacing` - the amount of space between each word in the text

lib/line_wrapper.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ class LineWrapper extends EventEmitter {
4040
this.document.x += indent;
4141
this.lineWidth -= indent;
4242

43+
// if indentAllLines is set to true
44+
// we're not resetting the indentation for this paragraph after the first line
45+
if (options.indentAllLines) {
46+
return;
47+
}
48+
49+
// otherwise we start the next line without indent
4350
return this.once('line', () => {
4451
this.document.x -= indent;
4552
this.lineWidth += indent;

0 commit comments

Comments
 (0)