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 2.1.0 to 2.2.0

hugeMess.pdf

12

CHANGELOG.md

@@ -7,4 +7,14 @@ # Changelog

## [Unreleased]
## [2.2.0] - 2019-04-02
### Fixed
- Pages from external documents should always be added with their original size #111
- Fix parsing documents with nested /Pages objects #117
- Fix parsing multi-line PDF strings #117
### Changed
- `opentype.js` has been updated to `0.11.0`, which has a minor effect on kerning distances
### Added
- `end` option for `doc.asBuffer` #118
## [2.1.0] - 2018-09-22

@@ -11,0 +21,0 @@ ### Changed

22

lib/document.js

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

}
catalog.prop('Outlines', this._outlines[0].toReference())
catalog.prop('Outlines', this._outlines[0].toReference())
}

@@ -581,3 +581,9 @@ await this._writeObject(catalog)

asBuffer(callback) {
asBuffer(opts, callback) {
if (typeof opts === 'function') {
callback = opts
opts = undefined
}
const shouldEnd = !opts || opts.end !== false
let p = new Promise((resolve, reject) => {

@@ -588,3 +594,5 @@ const chunks = []

this.on('error', reject)
this.end()
if (shouldEnd) {
this.end()
}
})

@@ -658,3 +666,3 @@ if (typeof callback === 'function') {

if (title === undefined || destination === undefined) return
// Create the root outline the first time this method is called

@@ -670,3 +678,3 @@ if (this._outlines.length === 0 ){

// the user provided a valid index number: use it as the parentIndex
parentIndex = parent
parentIndex = parent
} else {

@@ -690,3 +698,3 @@ // the user did not provide a valid index number: search for it in the outline array

}, [])
// Create item

@@ -714,3 +722,3 @@ const outline = new PDF.Object()

}
// Chain to parents

@@ -717,0 +725,0 @@ this._outlines[outlineIndex].data.parentIndex = parentIndex

@@ -15,14 +15,20 @@ 'use strict'

this.pages = pages
this.mediaBox = pages.get('MediaBox')
const kids = pages.get('Kids')
this.pageCount = kids.length
this.pageCount = this._countPagesRecursively(kids, 0)
}
this.objects = []
_countPagesRecursively(kids, i) {
for (const kid of kids) {
const page = kid.object
if (page.properties.get('Type').toString() === '/Pages') {
// encountered nested pages
i = this._countPagesRecursively(page.properties.get('Kids'), i)
} else {
i++
}
}
const objects = []
Parser.addObjectsRecursive(objects, page)
this.objects.push(objects)
}
return i
}

@@ -35,25 +41,47 @@

const kids = this.pages.get('Kids')
const pages = page ? [kids[page - 1]] : kids
const filter = page ? ((i) => i === (page - 1)) : undefined
for (let i = page ? page - 1 : 0, len = page ? page : kids.length; i < len; ++i) {
const page = kids[i].object
const objects = this.objects[i]
await this._addPagesRecursively(doc, kids, 0, filter)
}
doc._registerObject(page, true)
async _addPagesRecursively(doc, kids, i, filter) {
for (const kid of kids) {
const page = kid.object
// first, register objects to assign IDs (for references)
for (const obj of objects) {
doc._registerObject(obj, true)
}
if (page.properties.get('Type').toString() === '/Pages') {
// encountered nested pages
i = await this._addPagesRecursively(doc, page.properties.get('Kids'), i, filter)
continue
} else if (!filter || filter(i)) {
// if the page object does not define its MediaBox, explicitly set its MediaBox to the
// value defined by its parent Pages object
if (!page.properties.has('MediaBox') && this.mediaBox) {
page.properties.set('MediaBox', this.mediaBox)
}
// write objects
for (const obj of objects) {
await doc._writeObject(obj)
// add single page
doc._registerObject(page, true)
// first, register objects to assign IDs (for references)
const objects = []
Parser.addObjectsRecursive(objects, page, 0)
for (const obj of objects) {
doc._registerObject(obj, true)
}
// write objects
for (const obj of objects) {
await doc._writeObject(obj)
}
page.prop('Parent', doc._pagesObj.toReference())
await doc._writeObject(page)
doc._pages.push(page.toReference())
}
page.prop('Parent', doc._pagesObj.toReference())
await doc._writeObject(page)
i++
}
doc._pages.push(page.toReference())
}
return i
}

@@ -68,4 +96,11 @@

}
const first = kids[0].object.properties
const objects = this.objects[0]
const page = kids[0].object
// if the page object does not define its MediaBox, explicitly set its MediaBox to the
// value defined by its parent Pages object
if (!page.properties.has('MediaBox') && this.mediaBox) {
page.properties.set('MediaBox', this.mediaBox)
}
const first = page.properties
const objects = []
Parser.addObjectsRecursive(objects, page, 0)

@@ -125,1 +160,2 @@ // first, register objects to assign IDs (for references)

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

case 0x0a: // LF
lexer.skipEOL(1)
// ignore EOL characters
break

@@ -117,0 +117,0 @@ default:

{
"name": "pdfjs",
"author": "Markus Ast <npm.m@rkusa.st>",
"version": "2.1.0",
"version": "2.2.0",
"description": "A Portable Document Format (PDF) generation library targeting both the server- and client-side.",

@@ -21,12 +21,12 @@ "keywords": [

"@rkusa/linebreak": "^1.0.0",
"opentype.js": "^0.8.0",
"pako": "^1.0.6",
"readable-stream": "^2.3.6",
"opentype.js": "^0.11.0",
"pako": "^1.0.8",
"readable-stream": "^3.1.1",
"unorm": "^1.4.1",
"uuid": "^3.0.1"
"uuid": "^3.3.2"
},
"devDependencies": {
"@types/node": "^9.6.6",
"tape": "^4.6.3",
"typescript": "^2.8.3"
"@types/node": "^10.12.23",
"tape": "^4.9.2",
"typescript": "^3.3.3"
},

@@ -33,0 +33,0 @@ "repository": {

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