Comparing version 0.2.2 to 0.2.3
@@ -147,2 +147,7 @@ module.exports = function(opts, definition) { | ||
Row.prototype.td = function(text, opts) { | ||
if (typeof text === 'object') { | ||
var fn = opts | ||
opts = text | ||
text = fn | ||
} | ||
var cell = new Cell(this, text, opts) | ||
@@ -149,0 +154,0 @@ this.cells.push(cell) |
@@ -8,3 +8,3 @@ var PDFObject = require('./objects/object') | ||
var Document = module.exports = function Document(font) { | ||
var Document = module.exports = function Document(font, opts) { | ||
this.version = 1.7 | ||
@@ -22,4 +22,4 @@ | ||
// call parents constructor | ||
Document.super_.call(this, this) | ||
this.height = 792 | ||
Document.super_.call(this, this, opts) | ||
this.height = this.opts.height || 792 | ||
@@ -26,0 +26,0 @@ // the catalog and pages tree |
@@ -6,3 +6,3 @@ var Fragment = module.exports = function(doc, opts) { | ||
this.width = this.opts.width || 612 | ||
this.width = this.opts.width || 612 | ||
if (!this.opts.padding) this.opts.padding = { top: 20, right: 40, bottom: 20, left: 40 } | ||
@@ -65,3 +65,3 @@ this.padding = new Padding(this) | ||
get: function() { | ||
return Math.max.apply(Math, this.contents.map(function(content) { | ||
return this.opts.width || Math.max.apply(Math, this.contents.map(function(content) { | ||
return content.maxWidth | ||
@@ -86,6 +86,12 @@ })) | ||
Fragment.prototype.render = function(page, width) { | ||
var self = this | ||
if ('top' in this.opts && ((this.doc.height - this.opts.top) < this.doc.cursor.cursor.y || this.opts.position === 'force')) { | ||
this.doc.cursor.cursor.y = this.doc.height - this.opts.top | ||
} | ||
var self = this, cursor = this.doc.cursor, y = cursor.cursor.y | ||
this.contents.forEach(function(content) { | ||
content.render(self.doc.cursor, width || self.innerWidth) | ||
}) | ||
if ('minHeight' in this.opts && this.doc.cursor === cursor && (y - this.opts.minHeight) < cursor.cursor.y) { | ||
cursor.cursor.y = y - this.opts.minHeight | ||
} | ||
} | ||
@@ -113,3 +119,3 @@ | ||
var fragment = new Fragment(this, opts) | ||
var fragment = new Fragment(this.doc, opts) | ||
definition.call(fragment, fragment) | ||
@@ -116,0 +122,0 @@ this.contents.push(fragment) |
@@ -7,3 +7,3 @@ { | ||
}, | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"homepage": "https://github.com/rkusa/pdfjs", | ||
@@ -16,3 +16,3 @@ "keywords": ["pdf", "generator"], | ||
"bundle": "browserify lib/document.js --standalone Pdfjs --detect-globals false > pdfjs.js && npm run-script minify", | ||
"minify": "uglifyjs -o pdfjs.min.js pdfjs.js" | ||
"minify": "uglifyjs --source-map pdfjs.min.map -o pdfjs.min.js pdfjs.js" | ||
}, | ||
@@ -23,6 +23,6 @@ "dependencies": { | ||
"devDependencies": { | ||
"mocha": "1.9.x", | ||
"chai": "1.7.x", | ||
"mocha": "1.13.x", | ||
"chai": "1.8.x", | ||
"browserify": "2.x.x", | ||
"uglify-js": "1.x.x" | ||
"uglify-js": "2.x.x" | ||
}, | ||
@@ -29,0 +29,0 @@ "bugs": "https://github.com/rkusa/pdfjs/issues", |
@@ -6,3 +6,3 @@ # pdfjs | ||
{ "name": "pdfjs", | ||
"version": "0.2.2" } | ||
"version": "0.2.3" } | ||
``` | ||
@@ -9,0 +9,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
278735
24
4192
9