Skip to content
Open
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 @@ -3,6 +3,7 @@
### Unreleased

- Allow applying 'underline' and 'strike' text styling together on a text
- Text will flow to the following page instead of always appending a new page at the end

### [v0.12.0] - 2021-04-04

Expand Down
27 changes: 21 additions & 6 deletions lib/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,25 @@ class PDFDocument extends stream.Readable {
return this;
}

continueOnNewPage(options) {
const pageMarkings = this.endPageMarkings(this.page);

this.addPage(options);
continueOnNextPage(options) {
let pageIndex;

if (
this._pageBuffer &&
(pageIndex = this._pageBuffer.indexOf(this.page)) !==
this._pageBuffer.length - 1
) {
// The page isn't the last in the buffer, so jump to the next page
this.switchToPage(pageIndex + 1);
// Now position the cursor at the top margin
this.y = this.page.margins.top;
} else {
const pageMarkings = this.endPageMarkings(this.page);
// If the page is the last one in the buffer, add a new page.
this.addPage(options);

this.initPageMarkings(pageMarkings);
this.initPageMarkings(pageMarkings);
}

return this;
}
Expand Down Expand Up @@ -216,7 +229,9 @@ class PDFDocument extends stream.Readable {
addNamedEmbeddedFile(name, ref) {
if (!this._root.data.Names.data.EmbeddedFiles) {
// disabling /Limits for this tree fixes attachments not showing in Adobe Reader
this._root.data.Names.data.EmbeddedFiles = new PDFNameTree({ limits: false });
this._root.data.Names.data.EmbeddedFiles = new PDFNameTree({
limits: false
});
}

// add filespec to EmbeddedFiles
Expand Down
2 changes: 1 addition & 1 deletion lib/line_wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ class LineWrapper extends EventEmitter {
return false;
}

this.document.continueOnNewPage();
this.document.continueOnNextPage();
this.column = 1;
this.startY = this.document.page.margins.top;
this.maxY = this.document.page.maxY();
Expand Down
Loading