diff --git a/CHANGELOG.md b/CHANGELOG.md index d740143e..69a5f3fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ - Add robust handling of null byte padding in JPEG images - Replace outdated jpeg-exif with minimal implementation - Replace outdated crypto-js with maintained small alternatives +- Fix issue with indentation with `indentAllLines: true` when a new page is created ### [v0.17.2] - 2025-08-30 diff --git a/lib/line_wrapper.js b/lib/line_wrapper.js index b2f0e5cf..66aaeb90 100644 --- a/lib/line_wrapper.js +++ b/lib/line_wrapper.js @@ -11,6 +11,7 @@ class LineWrapper extends EventEmitter { this.document = document; this.horizontalScaling = options.horizontalScaling || 100; this.indent = ((options.indent || 0) * this.horizontalScaling) / 100; + this.indentAllLines = options.indentAllLines || false; this.characterSpacing = ((options.characterSpacing || 0) * this.horizontalScaling) / 100; this.wordSpacing = @@ -348,7 +349,13 @@ class LineWrapper extends EventEmitter { this.column = 1; this.startY = this.document.page.margins.top; this.maxY = this.document.page.maxY(); - this.document.x = this.startX; + if (this.indentAllLines) { + const indent = this.continuedX || this.indent; + this.document.x += indent; + this.lineWidth -= indent; + } else { + this.document.x = this.startX; + } if (this.document._fillColor) { this.document.fillColor(...this.document._fillColor); }