Skip to content

Commit 555db17

Browse files
committed
use phantomJS paperSize margin property in place of border
margin replaced border six years ago in phantomJS, although backward compatibility still allows the border property to function correctly. This change updates html-pdf to use the margin property and to continue recognizing the border property for backward compatitiblity. fixes: marcbachmann#403 refs: ariya/phantomjs@a638a07
1 parent 89a41e3 commit 555db17

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ config = {
9393
"orientation": "portrait", // portrait or landscape
9494

9595
// Page options
96-
"border": "0", // default is 0, units: mm, cm, in, px
96+
"margin": "0", // default is 0, units: mm, cm, in, px
9797
- or -
98-
"border": {
98+
"margin": {
9999
"top": "2in", // default is 0, units: mm, cm, in, px
100100
"right": "1in",
101101
"bottom": "2in",

lib/pdf.js

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ function PDF (html, options) {
3232
this.script = path.join(__dirname, 'scripts', 'pdf_a4_portrait.js')
3333
}
3434

35+
if (this.options.border && !this.options.margin) this.options.margin = this.options.border;
36+
3537
if (this.options.filename) this.options.filename = path.resolve(this.options.filename)
3638
if (!this.options.phantomPath) this.options.phantomPath = phantomjs && phantomjs.path
3739
this.options.phantomArgs = this.options.phantomArgs || []

lib/scripts/pdf_a4_portrait.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ function createSection (section, content, options) {
192192
// Creates paper with specified options
193193
// ------------------------------------
194194
function definePaperOrientation (options) {
195-
var paper = {border: options.border || '0'}
195+
var paper = {margin: options.margin || '0'}
196196

197197
if (options.height && options.width) {
198198
paper.width = options.width

0 commit comments

Comments
 (0)