Skip to content
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 @@
- Fix fonts without a postscriptName
- Add support for dynamic sizing
- Add support for rotatable text
- Fix page cascade options when text overflows

### [v0.16.0] - 2024-12-29

Expand Down
2 changes: 1 addition & 1 deletion lib/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class PDFDocument extends stream.Readable {
continueOnNewPage(options) {
const pageMarkings = this.endPageMarkings(this.page);

this.addPage(options);
this.addPage(options ?? this.page._options);

this.initPageMarkings(pageMarkings);

Expand Down
1 change: 1 addition & 0 deletions lib/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ const SIZES = {
class PDFPage {
constructor(document, options = {}) {
this.document = document;
this._options = options;
this.size = options.size || 'letter';
this.layout = options.layout || 'portrait';

Expand Down
16 changes: 16 additions & 0 deletions tests/unit/page.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import PDFDocument from '../../lib/document';

describe('page', function () {
test('cascade page options', function () {
const doc = new PDFDocument({
autoFirstPage: false,
bufferPages: true,
});
doc.addPage({ size: [50, 50], margin: 0 });
doc.text(Array(10).fill('TEST').join('\n'));
doc._pageBuffer.forEach((page) => {
expect(page.size).toEqual([50, 50]);
expect(page.margins).toEqual({ top: 0, right: 0, bottom: 0, left: 0 });
});
});
});