Socket
Socket
Sign inDemoInstall

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 0.2.3 to 0.3.0

17

lib/content/table.js
module.exports = function(opts, definition) {
this.contents.push(new Table(this, opts, definition))
return this
var table = new Table(this, opts, definition)
this.contents.push(table)
return table
}

@@ -27,3 +28,3 @@

this.doc = doc.doc || doc
this.opts = opts
this.opts = opts || {}

@@ -34,7 +35,9 @@ mergeOption(defaults, this.opts)

definition.call(this, this)
if (definition) definition.call(this, this)
}
Table.prototype.tr = function(opts, definition) {
this.rows.push(new Row(this, opts, definition))
var row = new Row(this, opts, definition)
this.rows.push(row)
return row
}

@@ -124,3 +127,3 @@

this.doc = table.doc
this.opts = mergeOption(table.opts, opts)
this.opts = mergeOption(table.opts, opts || {})

@@ -131,3 +134,3 @@ this.cells = []

definition.call(this, this)
if (definition) definition.call(this, this)
}

@@ -134,0 +137,0 @@

@@ -13,3 +13,3 @@ var PDFString = require('../objects/string')

return this
return text.textFn
}

@@ -133,3 +133,3 @@

}
this.contents.forEach(function(word, i) {

@@ -136,0 +136,0 @@ var wordWidth = word.width, wordSpacing = !line.length || word.isStartingWithPunctuation ? 0 : word.spacing

@@ -13,3 +13,2 @@ var PDFObject = require('./objects/object')

this.objects = []
this.nextObjId = 1

@@ -22,2 +21,4 @@ // list of all fonts in this document

// call parents constructor
if (!opts) opts = {}
if (!opts.padding) opts.padding = { top: 20, right: 40, bottom: 20, left: 40 }
Document.super_.call(this, this, opts)

@@ -45,2 +46,3 @@ this.height = this.opts.height || 792

}
if (!opts.padding) opts.padding = { top: 0, right: this.padding.right, bottom: 0, left: this.padding.left }
this.areas[area] = new Fragment(this, opts)

@@ -65,3 +67,3 @@ if (typeof definition === 'function') {

Document.prototype.createObject = function(type) {
var object = new PDFObject(this.nextObjId++, 0)
var object = new PDFObject()
if (type) object.addProperty('Type', type)

@@ -83,3 +85,3 @@ this.objects.push(object)

this.areas.header.height = 0
this.areas.header.render(page, this.innerWidth)
this.areas.header.render(page, this.idth)
this.areas.header.height = this.height - page.cursor.y - this.opts.padding.top

@@ -92,7 +94,7 @@ }

footer.height = 0
footer.render(page, this.innerWidth)
footer.render(page, this.width)
var height = y - page.cursor.y
transaction.rollback()
page.cursor.y = this.padding.bottom + height
footer.render(page, this.innerWidth)
footer.render(page, this.width)
page.cursor.y = y

@@ -117,3 +119,3 @@ footer.height = height

this.pagebreak()
this.render()
this.render(this.cursor)
this.subsets.forEach(function(subset) {

@@ -134,2 +136,6 @@ subset.embed(self)

buf += '\n'
this.objects.forEach(function(obj, i) {
obj.id = i + 1
})

@@ -247,4 +253,4 @@ // body

// TODO: improve ...
// utftext += String.fromCharCode(Math.min(c, 0xff))
// continue
utftext += String.fromCharCode(Math.min(c, 0xff))
continue

@@ -251,0 +257,0 @@ if (c < 128) {

@@ -92,6 +92,6 @@ var TTFFont = module.exports = require('ttfjs')

var file = new PDFStream(doc.createObject())
file.object.prop('Length', hex.length)
file.object.prop('Length', hex.length + 1)
file.object.prop('Length1', data.byteLength)
file.object.prop('Filter', 'ASCIIHexDecode')
file.content = hex + '\n'
file.content = hex + '>\n'
descriptor.prop('FontFile2', file.toReference())

@@ -98,0 +98,0 @@ }

@@ -7,3 +7,3 @@ var Fragment = module.exports = function(doc, opts) {

this.width = this.opts.width || 612
if (!this.opts.padding) this.opts.padding = { top: 20, right: 40, bottom: 20, left: 40 }
if (!this.opts.padding) this.opts.padding = { top: 0, right: 0, bottom: 0, left: 0 }
this.padding = new Padding(this)

@@ -81,16 +81,24 @@

Fragment.prototype.pagebreak = function() {
return this.doc.pagebreak()
var page = this.doc.pagebreak()
this.doc.cursor.cursor.x += this.padding.left
return page
}
Fragment.prototype.render = function(page, width) {
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 x = page.cursor.x
page.cursor.x += this.padding.left
if (width) width = width - this.padding.right - this.padding.left
if ('top' in this.opts && ((this.doc.height - this.opts.top) < page.cursor.y || this.opts.position === 'force')) {
page.cursor.y = this.doc.height - this.opts.top
}
var self = this, cursor = this.doc.cursor, y = cursor.cursor.y
var self = this, y = page.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
if ('minHeight' in this.opts && this.doc.cursor === page && (y - this.opts.minHeight) < page.cursor.y) {
page.cursor.y = y - this.opts.minHeight
}
page.cursor.x = x
}

@@ -97,0 +105,0 @@

@@ -9,3 +9,3 @@ // > Objects may be labeled so that they can be referred to by other objects.

var PDFObject = module.exports = function(id, rev) {
this.id = id
this.id = id || null
this.rev = rev || 0

@@ -12,0 +12,0 @@ this.properties = new PDFDictionary()

@@ -14,3 +14,3 @@ // page 60

this.content += str + '\n'
this.object.prop('Length', this.content.length)
this.object.prop('Length', this.content.length - 1)
}

@@ -17,0 +17,0 @@

@@ -15,3 +15,3 @@ var PDFStream = require('./objects/stream')

y: this.doc.height - this.doc.opts.padding.top,
x: this.doc.padding.left
x: 0
}

@@ -18,0 +18,0 @@

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

},
"version": "0.2.3",
"version": "0.3.0",
"homepage": "https://github.com/rkusa/pdfjs",

@@ -10,0 +10,0 @@ "keywords": ["pdf", "generator"],

@@ -6,3 +6,3 @@ # pdfjs

{ "name": "pdfjs",
"version": "0.2.3" }
"version": "0.3.0" }
```

@@ -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

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