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

do not change page layout on page break #1403

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ js/
coverage
package-lock.json
/examples/browserify/bundle.js
/yarn-error.log
5 changes: 4 additions & 1 deletion lib/line_wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ class LineWrapper extends EventEmitter {
this.features = options.features;

// calculate the maximum Y position the text can appear at
if (options.height != null) {
//console.log("LineWrapper.constructor, options="+JSON.stringify(options));
if (options.height != null && options.height != Infinity) {
this.height = options.height;
this.maxY = this.startY + options.height;
} else {
this.maxY = this.document.page.maxY();
}
//console.log("LineWrapper.constructor, maxY="+this.maxY);

// handle paragraph indents
this.on('firstLine', options => {
Expand Down Expand Up @@ -301,6 +303,7 @@ class LineWrapper extends EventEmitter {
}

nextSection(options) {
console.log("LineWrapper.nextSection, options="+JSON.stringify(options));
this.emit('sectionEnd', options, this);

if (++this.column > this.columns) {
Expand Down
4 changes: 2 additions & 2 deletions lib/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ const SIZES = {
class PDFPage {
constructor(document, options = {}) {
this.document = document;
this.size = options.size || 'letter';
this.layout = options.layout || 'portrait';
this.size = options.size || (document.page && document.page?.size) || 'letter';
this.layout = options.layout || (document.page && document.page != null && document.page?.layout) || 'portrait';

// process margins
if (typeof options.margin === 'number') {
Expand Down
22 changes: 13 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,17 @@
"document",
"vector"
],
"version": "0.13.0",
"version": "0.13.1",
"homepage": "http://pdfkit.org/",
"author": {
"name": "Devon Govett",
"email": "[email protected]",
"url": "http://badassjs.com/"
},
"author": "Devon Govett <[email protected]> (http://badassjs.com/)",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/foliojs/pdfkit.git"
"url": "git+https://github.com/foliojs/pdfkit.git"
},
"bugs": {
"url": "https://github.com/foliojs/pdfkit/issues"
},
"bugs": "https://github.com/foliojs/pdfkit/issues",
"devDependencies": {
"@babel/core": "^7.11.6",
"@babel/plugin-external-helpers": "^7.10.4",
Expand Down Expand Up @@ -90,5 +88,11 @@
"default",
"jest-screenshot/reporter"
]
},
"directories": {
"doc": "docs",
"example": "examples",
"lib": "lib",
"test": "tests"
}
}
}
Loading