
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
[](https://www.npmjs.com/package/pdfjs-box) [](https://travis-ci.org/hhdevelopment/pdfjs-box)
pdfjs-box is a collection of angular directives for include easily pdfjs in angular 1.x application.
<pdf-document pdf ng-items></pdf-document>
<pdf-thumbnails ng-height ng-items removable allow-drag allow-drop selected-item placeholder></pdf-thumbnails>
<pdf-view ng-item ng-scale ng-quality></pdf-view>
<pdf-docscale ng-item ng-scale allow-print></pdf-docscale>
<pdf-commands ng-item pdfview-selector doc-scale ng-scale ng-quality></pdf-commands>
pdf-document : from your document object implementation, computes the url to get pdf and supplies the items collections for other components
items collection describe each page of document.
pdf-thumbnails : is the deck for view thumbnails of pdf-document : it consumes items from pdf-documents. it supplies an item : selected-item
pdf-view : is a deck for view current item supplied by pdf-thumbnails.
pdf-docscale is the supplier for compute default scale for each document
pdf-commands, is a commands panels
npm install pdfjs-box -save
Dependencies
Add files to your build (webpack, gulp...)
node_modules/pdfjs-box/dist/pdfjsbox.js
node_modules/pdfjs-box/dist/pdfjsbox.css
With require : in your main module :
require('pdfjs-box/dist/pdfjsbox.js');
require('pdfjs-box/dist/pdfjsbox.css');
If you use scoped bundle as webback, you have to expose PDFJS Api to your application
For that use ProvidePlugin.
In this following example I expose lodash, jquery and PDFJS.
...
},
plugins: [
new webpack.ProvidePlugin({
_: 'lodash',
'window.jQuery': 'jquery',
'jQuery': 'jquery',
'$': 'jquery',
'PDFJS': 'pdfjs-dist'
}),
...
angular.module("YourApp", [..., 'pdfjs-box', ...]);
PDFjs needs worker (it is recomanded, more efficient).
For use it, you have to expose it directly in the path of your web application. Available/reachable from an url so.
But becarefull, worker can't be bundled in the vendors ou app bundles, it must be bundle in separate bundle
So if you use webpack or other bundler, you have to add pdfjs worker bundle in the path.
This is my solution for webpack.
return [{
context: __dirname,
entry: {
'pdf.worker.bundle.js': 'pdfjs-dist/build/pdf.worker.entry'
},
output: {
filename: '[name]',
path: path.resolve(__dirname, 'public_html')
},
plugins: [new webpack.optimize.UglifyJsPlugin({compressor: {screw_ie8: true, warnings: false}})]
},
Now you can add it with constant 'pdfjsConfig'
angular.module("YourApp", [..., 'pdfjs-box', ...]).
constant('pdfjsConfig', { workerSrc: './pdf.worker.bundle.js', preloadRecursivePages:7 } )
workerSrc : path for worker. preloadRecursivePages : configure balance between preload recursive or sequency. Set value with number of thumbnails visible by default.
Some pdf use specifics fonts. For it, PDFJS needs cmap. These cmap are include in pdfjs src : './node_modules/pdfjs-dist/cmaps/*' Include them in your build
With webpack 2+
const cmapPath = './node_modules/pdfjs-dist/cmaps';
...
return [{
entry: () => new Promise((resolve) => fs.readdir(cmapPath, function(e, files) {
resolve(files.map(function(file) {return cmapPath+'/'+file;}));
})),
output: {
filename: '[name]',
path: path.resolve(__dirname, 'public_html')
},
module: {
rules: [{test: /\.(bcmap)$/, use: [{loader: 'file-loader', options: {name: 'cmaps/[name].[ext]'}}]}]
}
}, {
Now you can add it with constant 'pdfjsConfig'
angular.module("YourApp", [..., 'pdfjs-box', ...]).
constant('pdfjsConfig', { cMapUrl:'cmaps/', cMapPacked:true } )
cMapUrl : the relative url in your site. cMapPacked : Set true if you use bcmap include in pdfjs
FAQs
[](https://www.npmjs.com/package/pdfjs-box) [](https://travis-ci.org/hhdevelopment/pdfjs-box)
The npm package pdfjs-box receives a total of 2 weekly downloads. As such, pdfjs-box popularity was classified as not popular.
We found that pdfjs-box demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.