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.3.2 to 2.3.3

lib/image/image.js

7

CHANGELOG.md

@@ -7,2 +7,9 @@ # Changelog

## [2.3.3] - 2020-01-07
### Fixed
- fix `text.br()`s not being added if a page break happens right at their position #159
- fix font opts inheritance when creating a text object from a text object (`.text('...').text('...')`) #175
- fix various EOL and `undefined` props errors when parsing existing PDFs
- extend `Font.isFont` check to accept fonts that are not an instance of `Font`, but still provide the expected font methods #182
## [2.3.2] - 2019-10-09

@@ -9,0 +16,0 @@ ### Fixed

8

lib/external.js

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

doc._template = {
contents: contents.map(c => c.toString()),
contents: contents.map(c => ((c && c.toString()) || '')),
colorSpaces: {},

@@ -139,3 +139,3 @@ fonts: {},

const colorSpaces = resources.get('ColorSpace')
const colorSpaces = resources && resources.get('ColorSpace')
if (colorSpaces) {

@@ -148,3 +148,3 @@ for (const alias in colorSpaces.dictionary) {

const fonts = resources.get('Font')
const fonts = resources && resources.get('Font')
if (fonts) {

@@ -157,3 +157,3 @@ for (const alias in fonts.dictionary) {

const xobjects = resources.get('XObject')
const xobjects = resources && resources.get('XObject')
if (xobjects) {

@@ -160,0 +160,0 @@ for (const alias in xobjects.dictionary) {

@@ -5,3 +5,13 @@ 'use strict'

static isFont(font) {
return font && font instanceof Font
return font && (font instanceof Font || (
typeof font === 'object'
&& typeof font.encode === 'function'
&& typeof font.stringWidth === 'function'
&& typeof font.lineHeight === 'function'
&& typeof font.ascent === 'function'
&& typeof font.descent === 'function'
&& typeof font.underlinePosition === 'function'
&& typeof font.underlineThickness === 'function'
&& typeof font.write === 'function'
))
}

@@ -8,0 +18,0 @@ }

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

const renderImage = require('./image/render')
const PDFImage = require('./image/pdf')
const JPEGImage = require('./image/jpeg')

@@ -139,2 +141,5 @@ const ALREADY_ENDED_ERROR = new Error('already ended')

image(img, opts) {
if (!(img instanceof JPEGImage) && !(img instanceof PDFImage)) {
throw new TypeError('Expected an image object')
}
if (!opts || typeof opts !== 'object') {

@@ -141,0 +146,0 @@ opts = {}

'use strict'
const util = require('./util')
exports.Document = require('./document')
exports.Font = require('./font/otf')
const PDFImage = require('./image/pdf')
const JPEGImage = require('./image/jpeg')
exports.Image = require('./image/image')
exports.Image = class Image {
constructor(b) {
const src = util.toArrayBuffer(b)
switch (determineType(src)) {
case 'pdf':
return new PDFImage(src)
case 'jpeg':
return new JPEGImage(src)
default:
throw new TypeError('Unsupported image type')
}
}
}
function determineType(buffer) {
const pdf = String.fromCharCode.apply(null, new Uint8Array(buffer, 0, 5))
if (pdf === '%PDF-') {
return 'pdf'
}
const view = new DataView(buffer)
if (view.getUint8(0) === 0xff || view.getUint8(1) === 0xd8) {
return 'jpeg'
}
return null
}
exports.ExternalDocument = require('./external')

@@ -41,0 +9,0 @@

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

lexer.skipEOL(1)
lexer.skipEOL(1, true)
lexer.skipWhitespace(null, true)

@@ -115,3 +115,3 @@

lexer.skipEOL(1)
lexer.skipEOL(1, true)
}

@@ -118,0 +118,0 @@ } else {

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

this.opts = opts
this.defaultFont = opts.font || this._doc.defaultFont

@@ -216,3 +217,9 @@ this.defaultFontSize = opts.fontSize || this._doc.defaultFontSize

// add remaining text as new text to the queue of pending operations
const remainingText = bk ? ((word ? (word + ' ') : '') + text.substring(bk.position)) : ''
let remainingText = bk ? ((word ? (word + ' ') : '') + text.substring(bk.position)) : ''
if (bk && bk.required) {
// if the page break happened due to a line break, we have to make sure to add it back
// to the queue as well
remainingText += '\n';
}
this._pending.unshift(() => {

@@ -219,0 +226,0 @@ this._parts++

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

@@ -6,0 +6,0 @@ "keywords": [

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