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

react-pdf-js

Package Overview
Dependencies
Maintainers
1
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-pdf-js - npm Package Compare versions

Comparing version 5.0.6 to 5.1.0

6

dist/react-pdf-js.cjs.development.js

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

var PdfJsLib = _interopDefault(require('pdfjs-dist'));
var pdfjs = _interopDefault(require('@bundled-es-modules/pdfjs-dist/build/pdf'));
var React = require('react');

@@ -57,3 +57,3 @@ var React__default = _interopDefault(React);

React.useEffect(() => {
PdfJsLib.GlobalWorkerOptions.workerSrc = workerSrc;
pdfjs.GlobalWorkerOptions.workerSrc = workerSrc;
}, []);

@@ -71,3 +71,3 @@ React.useEffect(() => {

PdfJsLib.getDocument(config).promise.then(setPdf);
pdfjs.getDocument(config).promise.then(setPdf);
}, [file, withCredentials]); // handle changes

@@ -74,0 +74,0 @@

@@ -1,2 +0,2 @@

"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var t=e(require("pdfjs-dist")),r=require("react"),a=e(r);const c=({file:e,onDocumentComplete:t,page:c,scale:s,rotate:n,cMapUrl:l,cMapPacked:i,workerSrc:u,withCredentials:d})=>{const f=r.useRef(null),[,p]=o({canvasEl:f,file:e,page:c,scale:s,rotate:n,cMapUrl:l,cMapPacked:i,workerSrc:u,withCredentials:d});return r.useEffect(()=>{t(p)},[p]),a.createElement("canvas",{ref:f})};c.defaultProps={onDocumentComplete:()=>{}};const o=({canvasEl:e,file:a,scale:c=1,rotate:o=0,page:s=1,cMapUrl:n,cMapPacked:l,workerSrc:i="//cdnjs.cloudflare.com/ajax/libs/pdf.js/2.1.266/pdf.worker.js",withCredentials:u=!1})=>{const[d,f]=r.useState();r.useEffect(()=>{t.GlobalWorkerOptions.workerSrc=i},[]),r.useEffect(()=>{const e={url:a,withCredentials:u};n&&(e.cMapUrl=n,e.cMapPacked=l),t.getDocument(e).promise.then(f)},[a,u]),r.useEffect(()=>{d&&d.getPage(s).then(e=>p(e))},[d,s,c,o,e]);const p=t=>{const r=0===o?t.rotate:t.rotate+o;let a=1;a=window.devicePixelRatio;const s=c*a,n=t.getViewport({scale:s,rotation:r}),l=e.current;if(!l)return;const i=l.getContext("2d");l.style.width=`${n.width/a}px`,l.style.height=`${n.height/a}px`,l.height=n.height,l.width=n.width;const u={canvasContext:i,viewport:n};t.render(u)},h=r.useMemo(()=>!d,[d]),w=r.useMemo(()=>d?d._pdfInfo.numPages:null,[d]);return[h,w]};exports.default=c,exports.usePdf=o;
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var t=e(require("@bundled-es-modules/pdfjs-dist/build/pdf")),r=require("react"),a=e(r);const c=({file:e,onDocumentComplete:t,page:c,scale:s,rotate:n,cMapUrl:l,cMapPacked:i,workerSrc:d,withCredentials:u})=>{const f=r.useRef(null),[,p]=o({canvasEl:f,file:e,page:c,scale:s,rotate:n,cMapUrl:l,cMapPacked:i,workerSrc:d,withCredentials:u});return r.useEffect(()=>{t(p)},[p]),a.createElement("canvas",{ref:f})};c.defaultProps={onDocumentComplete:()=>{}};const o=({canvasEl:e,file:a,scale:c=1,rotate:o=0,page:s=1,cMapUrl:n,cMapPacked:l,workerSrc:i="//cdnjs.cloudflare.com/ajax/libs/pdf.js/2.1.266/pdf.worker.js",withCredentials:d=!1})=>{const[u,f]=r.useState();r.useEffect(()=>{t.GlobalWorkerOptions.workerSrc=i},[]),r.useEffect(()=>{const e={url:a,withCredentials:d};n&&(e.cMapUrl=n,e.cMapPacked=l),t.getDocument(e).promise.then(f)},[a,d]),r.useEffect(()=>{u&&u.getPage(s).then(e=>p(e))},[u,s,c,o,e]);const p=t=>{const r=0===o?t.rotate:t.rotate+o;let a=1;a=window.devicePixelRatio;const s=c*a,n=t.getViewport({scale:s,rotation:r}),l=e.current;if(!l)return;const i=l.getContext("2d");l.style.width=`${n.width/a}px`,l.style.height=`${n.height/a}px`,l.height=n.height,l.width=n.width;const d={canvasContext:i,viewport:n};t.render(d)},h=r.useMemo(()=>!u,[u]),w=r.useMemo(()=>u?u._pdfInfo.numPages:null,[u]);return[h,w]};exports.default=c,exports.usePdf=o;
//# sourceMappingURL=react-pdf-js.cjs.production.js.map

@@ -1,2 +0,2 @@

import e from"pdfjs-dist";import t,{useRef as r,useEffect as o,useState as a,useMemo as c}from"react";const n=({file:e,onDocumentComplete:a,page:c,scale:n,rotate:s,cMapUrl:i,cMapPacked:p,workerSrc:d,withCredentials:h})=>{const w=r(null),[,f]=l({canvasEl:w,file:e,page:c,scale:n,rotate:s,cMapUrl:i,cMapPacked:p,workerSrc:d,withCredentials:h});return o(()=>{a(f)},[f]),t.createElement("canvas",{ref:w})};n.defaultProps={onDocumentComplete:()=>{}};const l=({canvasEl:t,file:r,scale:n=1,rotate:l=0,page:s=1,cMapUrl:i,cMapPacked:p,workerSrc:d="//cdnjs.cloudflare.com/ajax/libs/pdf.js/2.1.266/pdf.worker.js",withCredentials:h=!1})=>{const[w,f]=a();o(()=>{e.GlobalWorkerOptions.workerSrc=d},[]),o(()=>{const t={url:r,withCredentials:h};i&&(t.cMapUrl=i,t.cMapPacked=p),e.getDocument(t).promise.then(f)},[r,h]),o(()=>{w&&w.getPage(s).then(e=>u(e))},[w,s,n,l,t]);const u=e=>{const r=0===l?e.rotate:e.rotate+l;let o=1;o=window.devicePixelRatio;const a=n*o,c=e.getViewport({scale:a,rotation:r}),s=t.current;if(!s)return;const i=s.getContext("2d");s.style.width=`${c.width/o}px`,s.style.height=`${c.height/o}px`,s.height=c.height,s.width=c.width;const p={canvasContext:i,viewport:c};e.render(p)},g=c(()=>!w,[w]),m=c(()=>w?w._pdfInfo.numPages:null,[w]);return[g,m]};export default n;export{l as usePdf};
import e from"@bundled-es-modules/pdfjs-dist/build/pdf";import t,{useRef as r,useEffect as o,useState as a,useMemo as c}from"react";const n=({file:e,onDocumentComplete:a,page:c,scale:n,rotate:s,cMapUrl:i,cMapPacked:d,workerSrc:p,withCredentials:h})=>{const u=r(null),[,w]=l({canvasEl:u,file:e,page:c,scale:n,rotate:s,cMapUrl:i,cMapPacked:d,workerSrc:p,withCredentials:h});return o(()=>{a(w)},[w]),t.createElement("canvas",{ref:u})};n.defaultProps={onDocumentComplete:()=>{}};const l=({canvasEl:t,file:r,scale:n=1,rotate:l=0,page:s=1,cMapUrl:i,cMapPacked:d,workerSrc:p="//cdnjs.cloudflare.com/ajax/libs/pdf.js/2.1.266/pdf.worker.js",withCredentials:h=!1})=>{const[u,w]=a();o(()=>{e.GlobalWorkerOptions.workerSrc=p},[]),o(()=>{const t={url:r,withCredentials:h};i&&(t.cMapUrl=i,t.cMapPacked=d),e.getDocument(t).promise.then(w)},[r,h]),o(()=>{u&&u.getPage(s).then(e=>f(e))},[u,s,n,l,t]);const f=e=>{const r=0===l?e.rotate:e.rotate+l;let o=1;o=window.devicePixelRatio;const a=n*o,c=e.getViewport({scale:a,rotation:r}),s=t.current;if(!s)return;const i=s.getContext("2d");s.style.width=`${c.width/o}px`,s.style.height=`${c.height/o}px`,s.height=c.height,s.width=c.width;const d={canvasContext:i,viewport:c};e.render(d)},m=c(()=>!u,[u]),g=c(()=>u?u._pdfInfo.numPages:null,[u]);return[m,g]};export default n;export{l as usePdf};
//# sourceMappingURL=react-pdf-js.es.production.js.map
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('pdfjs-dist'), require('react')) :
typeof define === 'function' && define.amd ? define(['exports', 'pdfjs-dist', 'react'], factory) :
(global = global || self, factory(global['react-pdf-js'] = {}, global.PdfJsLib, global.React));
}(this, function (exports, PdfJsLib, React) { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@bundled-es-modules/pdfjs-dist/build/pdf'), require('react')) :
typeof define === 'function' && define.amd ? define(['exports', '@bundled-es-modules/pdfjs-dist/build/pdf', 'react'], factory) :
(global = global || self, factory(global['react-pdf-js'] = {}, global.pdfjs, global.React));
}(this, function (exports, pdfjs, React) { 'use strict';
PdfJsLib = PdfJsLib && PdfJsLib.hasOwnProperty('default') ? PdfJsLib['default'] : PdfJsLib;
pdfjs = pdfjs && pdfjs.hasOwnProperty('default') ? pdfjs['default'] : pdfjs;
var React__default = 'default' in React ? React['default'] : React;

@@ -57,3 +57,3 @@

React.useEffect(() => {
PdfJsLib.GlobalWorkerOptions.workerSrc = workerSrc;
pdfjs.GlobalWorkerOptions.workerSrc = workerSrc;
}, []);

@@ -71,3 +71,3 @@ React.useEffect(() => {

PdfJsLib.getDocument(config).promise.then(setPdf);
pdfjs.getDocument(config).promise.then(setPdf);
}, [file, withCredentials]); // handle changes

@@ -74,0 +74,0 @@

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("pdfjs-dist"),require("react")):"function"==typeof define&&define.amd?define(["exports","pdfjs-dist","react"],t):(e=e||self,t(e["react-pdf-js"]={},e.PdfJsLib,e.React))}(this,function(e,t,r){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t;var a="default"in r?r.default:r;const o=({file:e,onDocumentComplete:t,page:o,scale:s,rotate:n,cMapUrl:i,cMapPacked:l,workerSrc:d,withCredentials:f})=>{const u=r.useRef(null),[,p]=c({canvasEl:u,file:e,page:o,scale:s,rotate:n,cMapUrl:i,cMapPacked:l,workerSrc:d,withCredentials:f});return r.useEffect(()=>{t(p)},[p]),a.createElement("canvas",{ref:u})};o.defaultProps={onDocumentComplete:()=>{}};const c=({canvasEl:e,file:a,scale:o=1,rotate:c=0,page:s=1,cMapUrl:n,cMapPacked:i,workerSrc:l="//cdnjs.cloudflare.com/ajax/libs/pdf.js/2.1.266/pdf.worker.js",withCredentials:d=!1})=>{const[f,u]=r.useState();r.useEffect(()=>{t.GlobalWorkerOptions.workerSrc=l},[]),r.useEffect(()=>{const e={url:a,withCredentials:d};n&&(e.cMapUrl=n,e.cMapPacked=i),t.getDocument(e).promise.then(u)},[a,d]),r.useEffect(()=>{f&&f.getPage(s).then(e=>p(e))},[f,s,o,c,e]);const p=t=>{const r=0===c?t.rotate:t.rotate+c;let a=1;a=window.devicePixelRatio;const s=o*a,n=t.getViewport({scale:s,rotation:r}),i=e.current;if(!i)return;const l=i.getContext("2d");i.style.width=`${n.width/a}px`,i.style.height=`${n.height/a}px`,i.height=n.height,i.width=n.width;const d={canvasContext:l,viewport:n};t.render(d)},h=r.useMemo(()=>!f,[f]),w=r.useMemo(()=>f?f._pdfInfo.numPages:null,[f]);return[h,w]};e.default=o,e.usePdf=c});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@bundled-es-modules/pdfjs-dist/build/pdf"),require("react")):"function"==typeof define&&define.amd?define(["exports","@bundled-es-modules/pdfjs-dist/build/pdf","react"],t):(e=e||self,t(e["react-pdf-js"]={},e.pdfjs,e.React))}(this,function(e,t,r){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t;var a="default"in r?r.default:r;const o=({file:e,onDocumentComplete:t,page:o,scale:c,rotate:n,cMapUrl:d,cMapPacked:l,workerSrc:i,withCredentials:f})=>{const u=r.useRef(null),[,p]=s({canvasEl:u,file:e,page:o,scale:c,rotate:n,cMapUrl:d,cMapPacked:l,workerSrc:i,withCredentials:f});return r.useEffect(()=>{t(p)},[p]),a.createElement("canvas",{ref:u})};o.defaultProps={onDocumentComplete:()=>{}};const s=({canvasEl:e,file:a,scale:o=1,rotate:s=0,page:c=1,cMapUrl:n,cMapPacked:d,workerSrc:l="//cdnjs.cloudflare.com/ajax/libs/pdf.js/2.1.266/pdf.worker.js",withCredentials:i=!1})=>{const[f,u]=r.useState();r.useEffect(()=>{t.GlobalWorkerOptions.workerSrc=l},[]),r.useEffect(()=>{const e={url:a,withCredentials:i};n&&(e.cMapUrl=n,e.cMapPacked=d),t.getDocument(e).promise.then(u)},[a,i]),r.useEffect(()=>{f&&f.getPage(c).then(e=>p(e))},[f,c,o,s,e]);const p=t=>{const r=0===s?t.rotate:t.rotate+s;let a=1;a=window.devicePixelRatio;const c=o*a,n=t.getViewport({scale:c,rotation:r}),d=e.current;if(!d)return;const l=d.getContext("2d");d.style.width=`${n.width/a}px`,d.style.height=`${n.height/a}px`,d.height=n.height,d.width=n.width;const i={canvasContext:l,viewport:n};t.render(i)},h=r.useMemo(()=>!f,[f]),w=r.useMemo(()=>f?f._pdfInfo.numPages:null,[f]);return[h,w]};e.default=o,e.usePdf=s});
//# sourceMappingURL=react-pdf-js.umd.production.js.map
{
"name": "react-pdf-js",
"version": "5.0.6",
"version": "5.1.0",
"description": "Simple React component to wrap up PDF.js. The easiest way to render PDFs in your React app.",

@@ -50,4 +50,4 @@ "author": "mikecousins",

"dependencies": {
"pdfjs-dist": "2.1.266"
"@bundled-es-modules/pdfjs-dist": "2.1.266-rc"
}
}

@@ -35,7 +35,7 @@ # react-pdf-js

}
let previousButton = <li className="previous" onClick={() => setPage(page - 1))}><a href="#"><i className="fa fa-arrow-left"></i> Previous</a></li>;
let previousButton = <li className="previous" onClick={() => setPage(page - 1)}><a href="#"><i className="fa fa-arrow-left"></i> Previous</a></li>;
if (page === 1) {
previousButton = <li className="previous disabled"><a href="#"><i className="fa fa-arrow-left"></i> Previous</a></li>;
}
let nextButton = <li className="next" onClick={() => setPage(page + 1))}><a href="#">Next <i className="fa fa-arrow-right"></i></a></li>;
let nextButton = <li className="next" onClick={() => setPage(page + 1)}><a href="#">Next <i className="fa fa-arrow-right"></i></a></li>;
if (page === pages) {

@@ -42,0 +42,0 @@ nextButton = <li className="next disabled"><a href="#">Next <i className="fa fa-arrow-right"></i></a></li>;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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