Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indent after linebreak #879

Merged
merged 4 commits into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Update linebreak to 1.1
- Add support for spot colors
- Add support to scale text horizontally
- Add an option to keep the indentation after a new line starts and allow to indent a whole paragraph/text element
- Fix sets tab order to "Structure" when a document is tagged
- Fix font cache collision for fonts with missing postscript name or bad TTF metadata
- Fix measuring text when OpenType features are passed in to .text()
Expand Down
1 change: 1 addition & 0 deletions docs/text.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ below.
* `columns` - the number of columns to flow the text into
* `columnGap` - the amount of space between each column (1/4 inch by default)
* `indent` - the amount in PDF points (72 per inch) to indent each paragraph of text
* `indentAllLines` - wheter to indent all lines of a paragraph (`false` by default - indents only the first line)
* `paragraphGap` - the amount of space between each paragraph of text
* `lineGap` - the amount of space between each line of text
* `wordSpacing` - the amount of space between each word in the text
Expand Down
7 changes: 7 additions & 0 deletions lib/line_wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ class LineWrapper extends EventEmitter {
this.document.x += indent;
this.lineWidth -= indent;

// if indentAllLines is set to true
// we're not resetting the indentation for this paragraph after the first line
if (options.indentAllLines) {
return;
}

// otherwise we start the next line without indent
return this.once('line', () => {
this.document.x -= indent;
this.lineWidth += indent;
Expand Down
Loading