Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (typeof options.max !== 'number') {
options.max = DEFAULT_OPTIONS.max;
}
if (typeof options.version !== 'string') {
options.version = DEFAULT_OPTIONS.version;
}
if (options.version === 'default') {
options.version = DEFAULT_OPTIONS.version;
}
ret.version = PDFJS.version;
// Disable workers to avoid yet another cross-origin issue (workers need
// the URL of the script to be loaded, and dynamically loading a cross-origin
// script does not work).
PDFJS.disableWorker = true;
let doc;
return new Promise((resolve, reject) => {
PDFJS.getDocument(dataBuffer)
.promise.then(document => {
doc = document;
ret.numpages = doc.numPages;
let metaData;
doc.getMetadata()
.then(metadata => {
metaData = metadata;
ret.info = metaData ? metaData.info : undefined;
ret.metadata = metaData ? metaData.metadata : undefined;
import PDFJS from 'pdfjs-dist';
// Import our styles
import 'bootstrap-colorpicker/dist/css/bootstrap-colorpicker.css';
import 'sass/styles.scss';
import 'katex/dist/katex.min.css';
import {browserHistory} from 'utils/browser_history';
import {isDevMode, setCSRFFromCookie} from 'utils/utils';
import {makeAsyncComponent} from 'components/async_load';
import store from 'stores/redux_store.jsx';
import loadRoot from 'bundle-loader?lazy!components/root';
const Root = makeAsyncComponent(loadRoot);
PDFJS.disableWorker = true;
// This is for anything that needs to be done for ALL react components.
// This runs before we start to render anything.
function preRenderSetup(callwhendone) {
window.onerror = (msg, url, line, column, stack) => {
if (msg === 'ResizeObserver loop limit exceeded') {
return;
}
var l = {};
l.level = 'ERROR';
l.message = 'msg: ' + msg + ' row: ' + line + ' col: ' + column + ' stack: ' + stack + ' url: ' + url;
const req = new XMLHttpRequest();
req.open('POST', '/api/v4/logs');
req.setRequestHeader('Content-Type', 'application/json');
req.send(JSON.stringify(l));
const pdfJs = require("pdfjs-dist");
pdfJs.disableWorker = true;
const fs = require("fs");
module.exports = (filename) => {
const book = {
_book: undefined,
_init: () => {
return new Promise((resolve) => {
fs.readFile(filename, function (err, data) {
var data_array = new Uint8Array(data);
pdfJs.getDocument(data_array).promise.then(function (pdf) {
book._book = pdf;
resolve(book);
});