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

@jsreport/pdfjs

Package Overview
Dependencies
Maintainers
0
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jsreport/pdfjs - npm Package Compare versions

Comparing version 1.6.0 to 1.6.1

test/page-contents-array.pdf

29

lib/mixins/processText.js

@@ -6,2 +6,3 @@ const CMapFactory = require('../pdfjs-ext/core/cmap.js').CMapFactory

const zlib = require('zlib')
const PDF = require('../object')

@@ -20,3 +21,10 @@ module.exports = (doc) => {

for (const pageObject of pages) {
const streamObject = pageObject.properties.get('Contents').object.content
let streamObject
if (Array.isArray(pageObject.properties.get('Contents'))) {
streamObject = concatStreams(pageObject.properties.get('Contents'))
} else {
const contentsObject = pageObject.properties.get('Contents').object
streamObject = contentsObject.content
}
await processStream({

@@ -295,1 +303,20 @@ doc,

}
function concatStreams (streams) {
const buffers = []
for (const content of streams) {
const pageStreamObject = content.object?.content?.object
if (pageStreamObject) {
const filterProp = pageStreamObject.properties.get('Filter')
if (filterProp && filterProp.name === 'FlateDecode') {
buffers.push(zlib.unzipSync(pageStreamObject.content.content))
}
}
}
const contentsObject = new PDF.Object('Contents')
const streamObject = new PDF.Stream(contentsObject)
streamObject.content = zlib.deflateSync(Buffer.concat(buffers))
contentsObject.prop('Length', streamObject.content.length)
contentsObject.prop('Filter', 'FlateDecode')
return streamObject
}

2

package.json
{
"name": "@jsreport/pdfjs",
"version": "1.6.0",
"version": "1.6.1",
"description": "",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -509,2 +509,21 @@ const { Document, External } = require('../')

it('processText should support page Contents as array', async () => {
const document = new Document()
const external = new External(fs.readFileSync(path.join(__dirname, 'page-contents-array.pdf')))
document.append(external)
let docText = ''
await document.processText({
resolver: (text) => {
docText += text
}
})
await document.asBuffer()
// the external PDF contains unsuported text commands like
// [(pement \351lectrique ou \351lectr)6.1 (onique usag\351 dans la limite de la quantit\351)-15 ( )]TJ
// in future we may support it, but at this moment it isn't important because text parsing is primarily used for embedding hidden marks with chrome
docText.should.containEql('amiable')
})
it('acroform with text type', async () => {

@@ -511,0 +530,0 @@ const document = new Document()

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