Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pdfjs

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pdfjs - npm Package Compare versions

Comparing version 1.0.0-alpha.1 to 1.0.0-alpha.2

4

lib/element/container.js

@@ -27,3 +27,3 @@ 'use strict'

Container.prototype.box = function(opts) {
var box = new Box(this.style.merge(ContainerStyle.paddingReset), opts)
var box = new Box(this.style.merge(ContainerStyle.reset), opts)
this.children.push(box)

@@ -35,3 +35,3 @@ return box

Container.prototype.table = function(opts) {
var table = new Table(this.style.merge(ContainerStyle.paddingReset), opts)
var table = new Table(this.style.merge(ContainerStyle.reset), opts)
this.children.push(table)

@@ -38,0 +38,0 @@ return table

@@ -31,3 +31,3 @@ 'use strict'

this._header = new Box(this.style.merge(DocumentStyle.super_.paddingReset), opts)
this._header = new Box(this.style.merge(DocumentStyle.super_.reset), opts)
return this._header

@@ -45,3 +45,3 @@ }

this._footer = new Box(this.style.merge(DocumentStyle.super_.paddingReset), opts)
this._footer = new Box(this.style.merge(DocumentStyle.super_.reset), opts)
return this._footer

@@ -48,0 +48,0 @@ }

@@ -11,4 +11,8 @@ 'use strict'

Operations.prototype.op = function() {
this.ops.push(Array.prototype.slice.call(arguments))
Operations.prototype.op = function(fn) {
if (fn && typeof fn === 'function') {
this.ops.push(fn)
} else {
this.ops.push(Array.prototype.slice.call(arguments))
}
}

@@ -18,3 +18,3 @@ 'use strict'

Table.prototype.tr = function(opts) {
var tr = new Row(this.style.merge(opts))
var tr = new Row(this.style.merge(TableStyle.reset, opts))
this.children.push(tr)

@@ -26,6 +26,6 @@ return tr

if (typeof fnOrOpts === 'function') {
fnOrOpts.opts = this.style.merge(opts)
fnOrOpts.opts = this.style.merge(TableStyle.reset, opts)
this.beforeBreakChildren.push(fnOrOpts)
} else {
var tr = new Row(this.style.merge(fnOrOpts))
var tr = new Row(this.style.merge(TableStyle.reset, fnOrOpts))
this.beforeBreakChildren.push(tr)

@@ -32,0 +32,0 @@ return tr

@@ -226,2 +226,8 @@ 'use strict'

function toFixed(num, precision) {
if (isNaN(num)) {
var stack = (new Error).stack.split('\n')
stack.splice(0, 5)
stack = stack.join('\n')
console.warn("Writing NaN - there probably went something wrong.\nPlease report this issue to http://github.com/rkusa/pdfjs/issues\nStack Trace:\n" + stack)
}
return (+(Math.floor(+(num + 'e' + precision)) + 'e' + -precision)).toFixed(precision)

@@ -228,0 +234,0 @@ }

@@ -28,4 +28,4 @@ 'use strict'

.reduce(function(lhs, rhs) { return lhs + rhs }, 0)
+ this.style.borderTopWidth + this.style.paddingTop
+ this.style.paddingBottom + this.style.borderBottomWidth
+ this.style.getBorderTopWidth() + this.style.paddingTop
+ this.style.paddingBottom + this.style.getBorderBottomWidth()

@@ -39,3 +39,3 @@ return height < this.style.minHeight ? this.style.minHeight : height

get: function() {
return this.style.paddingBottom + this.style.borderBottomWidth
return this.style.paddingBottom + this.style.getBorderBottomWidth()
}

@@ -46,3 +46,3 @@ }

BoxNode.prototype.beforeContent = function(cursor) {
var top = this.style.borderTopWidth + this.style.paddingTop
var top = this.style.getBorderTopWidth() + this.style.paddingTop
if (top > 0) {

@@ -57,3 +57,3 @@ cursor.y -= top

var left = this.style.borderLeftWidth + this.style.paddingLeft
var left = this.style.getBorderLeftWidth() + this.style.paddingLeft
if (left > 0) {

@@ -67,3 +67,3 @@ cursor.x += left

BoxNode.prototype.afterContent = function(cursor) {
var bottom = this.style.borderBottomWidth + this.style.paddingBottom
var bottom = this.style.getBorderBottomWidth() + this.style.paddingBottom
if (bottom > 0) {

@@ -89,4 +89,4 @@ cursor.y -= bottom

this.width = utils.resolveWidth(this.style.width, maxWidth)
- this.style.paddingLeft - this.style.borderLeftWidth
- this.style.paddingRight - this.style.borderRightWidth
- this.style.paddingLeft - this.style.getBorderLeftWidth()
- this.style.paddingRight - this.style.getBorderRightWidth()
}

@@ -96,12 +96,12 @@

var height = this.height
var width = this.style.borderLeftWidth + this.style.paddingLeft + this.width + this.style.paddingRight + this.style.borderRightWidth
var left = this.x + (this.style.borderLeftWidth / 2)
var top = this.y - (this.style.borderTopWidth / 2)
var right = this.x + width - (this.style.borderRightWidth / 2)
var bottom = this.y - height + (this.style.borderBottomWidth / 2)
var width = this.style.getBorderLeftWidth() + this.style.paddingLeft + this.width + this.style.paddingRight + this.style.getBorderRightWidth()
var left = this.x + (this.style.getBorderLeftWidth() / 2)
var top = this.y - (this.style.getBorderTopWidth() / 2)
var right = this.x + width - (this.style.getBorderRightWidth() / 2)
var bottom = this.y - height + (this.style.getBorderBottomWidth() / 2)
// backogrund color
if (this.style.backgroundColor !== null) {
drawBackground(doc, left - (this.style.borderLeftWidth / 2),
bottom - (this.style.borderBottomWidth / 2),
drawBackground(doc, left - (this.style.getBorderLeftWidth() / 2),
bottom - (this.style.getBorderBottomWidth() / 2),
width, height,

@@ -112,7 +112,7 @@ this.style.backgroundColor)

// border top
if (this.style.borderTopWidth > 0) {
drawLine(doc, this.style.borderTopWidth,
[left - (this.style.borderLeftWidth / 2), top],
[right + (this.style.borderRightWidth / 2), top],
this.style.borderTopColor)
if (this.style.getBorderTopWidth() > 0) {
drawLine(doc, this.style.getBorderTopWidth(),
[left - (this.style.getBorderLeftWidth() / 2), top],
[right + (this.style.getBorderRightWidth() / 2), top],
this.style.getBorderTopColor())
}

@@ -122,23 +122,23 @@

// border right
if (this.style.borderRightWidth > 0) {
drawLine(doc, this.style.borderRightWidth,
[right, top + (this.style.borderTopWidth / 2)],
[right, bottom - (this.style.borderBottomWidth / 2)],
this.style.borderRightColor)
if (this.style.getBorderRightWidth() > 0) {
drawLine(doc, this.style.getBorderRightWidth(),
[right, top + (this.style.getBorderTopWidth() / 2)],
[right, bottom - (this.style.getBorderBottomWidth() / 2)],
this.style.getBorderRightColor())
}
// border bottom
if (this.style.borderBottomWidth > 0) {
drawLine(doc, this.style.borderBottomWidth,
[right + (this.style.borderRightWidth / 2), bottom],
[left - (this.style.borderLeftWidth / 2), bottom],
this.style.borderBottomColor)
if (this.style.getBorderBottomWidth() > 0) {
drawLine(doc, this.style.getBorderBottomWidth(),
[right + (this.style.getBorderRightWidth() / 2), bottom],
[left - (this.style.getBorderLeftWidth() / 2), bottom],
this.style.getBorderBottomColor())
}
// border left
if (this.style.borderLeftWidth > 0) {
drawLine(doc, this.style.borderLeftWidth,
[left, bottom - (this.style.borderBottomWidth / 2)],
[left, top + (this.style.borderTopWidth / 2)],
this.style.borderLeftColor)
if (this.style.getBorderLeftWidth() > 0) {
drawLine(doc, this.style.getBorderLeftWidth(),
[left, bottom - (this.style.getBorderBottomWidth() / 2)],
[left, top + (this.style.getBorderTopWidth() / 2)],
this.style.getBorderLeftColor())
}

@@ -145,0 +145,0 @@ }

@@ -23,4 +23,7 @@ 'use strict'

get: function() {
return this.children.map(function(child) { return child.height })
.reduce(function(lhs, rhs) { return lhs + rhs }, 0)
return Math.max(
this.style.height || 0,
this.children.map(function(child) { return child.height })
.reduce(function(lhs, rhs) { return lhs + rhs }, 0)
)
}

@@ -63,4 +66,4 @@ },

// this.width = resolveWidth(this.style.width, cursor.width)
// - this.style.paddingLeft - this.style.borderLeftWidth
// - this.style.paddingRight - this.style.borderRightWidth
// - this.style.paddingLeft - this.style.getBorderLeftWidth()
// - this.style.paddingRight - this.style.getBorderRightWidth()
}

@@ -10,2 +10,3 @@ 'use strict'

this.height = this.width = 0
this.ops = ops.ops

@@ -16,6 +17,24 @@ }

OperationsNode.prototype._compute = function(cursor) {
this.ops.forEach(function(op) {
if (typeof op === 'function') {
op.x = cursor.x
op.y = cursor.y
}
})
}
OperationsNode.prototype.render = function(doc) {
this.ops.forEach(function(op) {
doc.write.apply(doc, op)
if (typeof op === 'function') {
var args = op(op.x, op.y)
if (!Array.isArray(args)) {
args = [args]
}
} else {
args = op
}
doc.write.apply(doc, args)
})
}

@@ -41,3 +41,3 @@ 'use strict'

+ child.style.paddingTop + child.style.paddingBottom
+ child.style.borderTopWidth + child.style.borderBottomWidth
+ child.style.getBorderTopWidth() + child.style.getBorderBottomWidth()

@@ -79,4 +79,4 @@ return height

child.width = (this.widths[index++] || 0)
- child.style.borderLeftWidth - child.style.paddingLeft
- child.style.paddingRight - child.style.borderRightWidth
- child.style.getBorderLeftWidth() - child.style.paddingLeft
- child.style.paddingRight - child.style.getBorderRightWidth()

@@ -93,3 +93,3 @@ if (child.style.colspan > 1) {

+ child.style.paddingLeft + child.style.paddingRight
+ child.style.borderRightWidth + child.style.borderLeftWidth
+ child.style.getBorderRightWidth() + child.style.getBorderLeftWidth()
}, this)

@@ -96,0 +96,0 @@ }

@@ -105,32 +105,34 @@ 'use strict'

var horizontalWidth, horizontalColor
if (cell.style.getBorderTopWidth()) {
var horizontalWidth, horizontalColor
if (cell.style.borderTopWidth > onTop.style.borderBottomWidth) {
horizontalWidth = cell.style.borderTopWidth / 2
horizontalColor = cell.style.borderTopColor
} else {
horizontalWidth = onTop.style.borderBottomWidth / 2
horizontalColor = onTop.style.borderBottomColor
}
if (cell.style.getBorderTopWidth() > onTop.style.getBorderBottomWidth()) {
horizontalWidth = cell.style.getBorderTopWidth() / 2
horizontalColor = cell.style.getBorderTopColor()
} else {
horizontalWidth = onTop.style.getBorderBottomWidth() / 2
horizontalColor = onTop.style.getBorderBottomColor()
}
onTop.style = onTop.style.merge({
borderBottomWidth: horizontalWidth,
borderBottomColor: horizontalColor
})
onTop.style = onTop.style.merge({
borderBottomWidth: horizontalWidth,
borderBottomColor: horizontalColor
})
cell.style = cell.style.merge({
borderTopWidth: horizontalWidth,
borderTopColor: horizontalColor
})
cell.style = cell.style.merge({
borderTopWidth: horizontalWidth,
borderTopColor: horizontalColor
})
if (cell.style.colspan > 1) {
for (var k = 1; k < cell.style.colspan; ++k) {
var next = this.children[j - 1].children[index++]
if (!next) {
break
if (cell.style.colspan > 1) {
for (var k = 1; k < cell.style.colspan; ++k) {
var next = this.children[j - 1].children[index++]
if (!next) {
break
}
next.style = next.style.merge({
borderBottomWidth: horizontalWidth,
borderBottomColor: horizontalColor
})
}
next.style = next.style.merge({
borderBottomWidth: horizontalWidth,
borderBottomColor: horizontalColor
})
}

@@ -142,21 +144,24 @@ }

var onLeft = row.children[i - 1]
var verticalWidth, verticalColor
if (cell.style.borderLeftWidth > onLeft.style.borderRightWidth) {
verticalWidth = cell.style.borderLeftWidth / 2
verticalColor = cell.style.borderLeftColor
} else {
verticalWidth = onLeft.style.borderRightWidth / 2
verticalColor = onLeft.style.borderRightColor
}
if (cell.style.getBorderLeftWidth() > 0) {
var verticalWidth, verticalColor
onLeft.style = onLeft.style.merge({
borderRightWidth: verticalWidth,
borderRightColor: verticalColor
})
if (cell.style.getBorderLeftWidth() > onLeft.style.getBorderRightWidth()) {
verticalWidth = cell.style.getBorderLeftWidth() / 2
verticalColor = cell.style.getBorderLeftColor()
} else {
verticalWidth = onLeft.style.getBorderRightWidth() / 2
verticalColor = onLeft.style.getBorderRightColor()
}
cell.style = cell.style.merge({
borderLeftWidth: verticalWidth,
borderLeftColor: verticalColor
})
onLeft.style = onLeft.style.merge({
borderRightWidth: verticalWidth,
borderRightColor: verticalColor
})
cell.style = cell.style.merge({
borderLeftWidth: verticalWidth,
borderLeftColor: verticalColor
})
}
}

@@ -163,0 +168,0 @@ }, this)

'use strict'
var SIDES = ['Top', 'Right', 'Bottom', 'Left']
var BoxStyle = module.exports = function() {

@@ -9,22 +11,7 @@ this.backgroundColor = null

var sides = ['Top', 'Right', 'Bottom', 'Left']
this.borderWidth = 0
sides.forEach(function(side) {
var value = null
Object.defineProperty(this, 'border' + side + 'Width', {
enumerable: true,
get: function() { return Math.max(0, value != null ? value : this.borderWidth || 0) },
set: function(val) { value = val }
})
}, this)
this.borderColor = 0x000000
sides.forEach(function(side) {
var value = null
Object.defineProperty(this, 'border' + side + 'Color', {
enumerable: true,
get: function() { return value != null ? value : this.borderColor || 0x000000 },
set: function(val) { value = val }
})
SIDES.forEach(function(side) {
this['border' + side + 'Width'] = null
this['border' + side + 'Color'] = null
}, this)

@@ -36,1 +23,13 @@

require('../pdf/utils').inherits(BoxStyle, require('./container'))
SIDES.forEach(function(side) {
BoxStyle.prototype['getBorder' + side + 'Width'] = function() {
var value = this['border' + side + 'Width']
return Math.max(0, value != null ? value : this.borderWidth || 0)
}
BoxStyle.prototype['getBorder' + side + 'Color'] = function() {
var value = this['border' + side + 'Color']
return value != null ? value : this.borderColor || 0x000000
}
})

@@ -24,3 +24,3 @@ 'use strict'

ContainerStyle.paddingReset = {
ContainerStyle.reset = {
padding: 0,

@@ -30,3 +30,4 @@ paddingTop: 0,

paddingBottom: 0,
paddingLeft: 0
paddingLeft: 0,
height: null
}

@@ -33,0 +34,0 @@

'use strict'
var DIRECTIONS = ['Vertical', 'Horizontal']
var SIDES = ['Top', 'Right', 'Bottom', 'Left']
var TableStyle = module.exports = function() {

@@ -12,46 +15,12 @@ this.tableLayout = 'fixed'

var directions = ['Vertical', 'Horizontal']
directions.forEach(function(direction) {
var value = null
Object.defineProperty(this, 'border' + direction + 'Width', {
enumerable: true,
get: function() { return Math.max(0, value != null ? value : this.borderWidth || 0) },
set: function(val) { value = val }
})
DIRECTIONS.forEach(function(direction) {
this['border' + direction + 'Width'] = null
this[ 'border' + direction + 'Color'] = null
}, this)
directions.forEach(function(direction) {
var value = null
Object.defineProperty(this, 'border' + direction + 'Color', {
enumerable: true,
get: function() { return value != null ? value : this.borderColor || 0x000000 },
set: function(val) { value = val }
})
SIDES.forEach(function(side) {
this['border' + side + 'Width'] = null
this['border' + side + 'Color'] = null
}, this)
var sides = ['Top', 'Right', 'Bottom', 'Left']
sides.forEach(function(side) {
var value = null
var direction = side === 'Right' || side === 'Left' ? 'Vertical' : 'Horizontal'
var directionProperty = 'border' + direction + 'Width'
Object.defineProperty(this, 'border' + side + 'Width', {
enumerable: true,
get: function() { return Math.max(0, value !== null ? value : this[directionProperty] || this.borderWidth || 0) },
set: function(val) { value = val }
})
}, this)
sides.forEach(function(side) {
var value = null
var direction = side === 'Right' || side === 'Left' ? 'Vertical' : 'Horizontal'
var directionProperty = 'border' + direction + 'Color'
Object.defineProperty(this, 'border' + side + 'Color', {
enumerable: true,
get: function() { return value != null ? value : this[directionProperty] || this.borderColor || 0x000000 },
set: function(val) { value = val }
})
}, this)
TableStyle.super_.apply(this, arguments)

@@ -62,5 +31,32 @@ }

DIRECTIONS.forEach(function(direction) {
TableStyle.prototype['getBorder' + direction + 'Width'] = function() {
var value = this['border' + direction + 'Width']
return Math.max(0, value != null ? value : (this.borderWidth || 0))
}
TableStyle.prototype['getBorder' + direction + 'Color'] = function() {
var value = this['border' + direction + 'Color']
return value != null ? value : (this.borderColor || 0x000000)
}
})
SIDES.forEach(function(side) {
var direction = side === 'Right' || side === 'Left' ? 'Vertical' : 'Horizontal'
TableStyle.prototype['getBorder' + side + 'Width'] = function() {
var value = this['border' + side + 'Width']
return Math.max(0, value !== null ? value : this['border' + direction + 'Width'] || this.borderWidth || 0)
}
TableStyle.prototype['getBorder' + side + 'Color'] = function() {
var value = this['border' + side + 'Color']
return value != null ? value : (this['border' + direction + 'Color'] || this.borderColor || 0x000000)
}
})
TableStyle.reset = {
colspan: 1,
allowBreak: false
allowBreak: false,
// height: null
}

@@ -7,3 +7,3 @@ {

},
"version": "1.0.0-alpha.1",
"version": "1.0.0-alpha.2",
"homepage": "https://github.com/rkusa/pdfjs",

@@ -26,3 +26,3 @@ "description": "A Portable Document Format (PDF) generation library targeting both the server- and client-side.",

"node-uuid": "^1.4",
"ttfjs": "^0.3.0",
"ttfjs": "^0.4.0",
"unorm": "^1.3"

@@ -29,0 +29,0 @@ },

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc