Move the workerSrc
option from the global PDFJS
object and into GlobalWorkerOptions
instead
This commit is contained in:
parent
45adf33187
commit
c3c1fc511d
@ -15,7 +15,8 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
PDFJS.workerSrc = '../../node_modules/pdfjs-dist/build/pdf.worker.js';
|
PDFJS.GlobalWorkerOptions.workerSrc =
|
||||||
|
'../../node_modules/pdfjs-dist/build/pdf.worker.js';
|
||||||
|
|
||||||
var DEFAULT_URL = '../../test/pdfs/f1040.pdf';
|
var DEFAULT_URL = '../../test/pdfs/f1040.pdf';
|
||||||
var DEFAULT_SCALE = 1.0;
|
var DEFAULT_SCALE = 1.0;
|
||||||
|
@ -8,7 +8,8 @@ require('pdfjs-dist');
|
|||||||
var pdfPath = '../helloworld/helloworld.pdf';
|
var pdfPath = '../helloworld/helloworld.pdf';
|
||||||
|
|
||||||
// Setting worker path to worker bundle.
|
// Setting worker path to worker bundle.
|
||||||
PDFJS.workerSrc = '../../build/browserify/pdf.worker.bundle.js';
|
PDFJS.GlobalWorkerOptions.workerSrc =
|
||||||
|
'../../build/browserify/pdf.worker.bundle.js';
|
||||||
|
|
||||||
// Loading a document.
|
// Loading a document.
|
||||||
var loadingTask = PDFJS.getDocument(pdfPath);
|
var loadingTask = PDFJS.getDocument(pdfPath);
|
||||||
|
@ -22,7 +22,8 @@ if (!PDFJS.PDFViewer || !PDFJS.getDocument) {
|
|||||||
|
|
||||||
// The workerSrc property shall be specified.
|
// The workerSrc property shall be specified.
|
||||||
//
|
//
|
||||||
PDFJS.workerSrc = '../../node_modules/pdfjs-dist/build/pdf.worker.js';
|
PDFJS.GlobalWorkerOptions.workerSrc =
|
||||||
|
'../../node_modules/pdfjs-dist/build/pdf.worker.js';
|
||||||
|
|
||||||
// Some PDFs need external cmaps.
|
// Some PDFs need external cmaps.
|
||||||
//
|
//
|
||||||
|
@ -22,7 +22,8 @@ if (!PDFJS.PDFViewer || !PDFJS.getDocument) {
|
|||||||
|
|
||||||
// The workerSrc property shall be specified.
|
// The workerSrc property shall be specified.
|
||||||
//
|
//
|
||||||
PDFJS.workerSrc = '../../node_modules/pdfjs-dist/build/pdf.worker.js';
|
PDFJS.GlobalWorkerOptions.workerSrc =
|
||||||
|
'../../node_modules/pdfjs-dist/build/pdf.worker.js';
|
||||||
|
|
||||||
// Some PDFs need external cmaps.
|
// Some PDFs need external cmaps.
|
||||||
//
|
//
|
||||||
|
@ -22,7 +22,8 @@ if (!PDFJS.PDFSinglePageViewer || !PDFJS.getDocument) {
|
|||||||
|
|
||||||
// The workerSrc property shall be specified.
|
// The workerSrc property shall be specified.
|
||||||
//
|
//
|
||||||
PDFJS.workerSrc = '../../node_modules/pdfjs-dist/build/pdf.worker.js';
|
PDFJS.GlobalWorkerOptions.workerSrc =
|
||||||
|
'../../node_modules/pdfjs-dist/build/pdf.worker.js';
|
||||||
|
|
||||||
// Some PDFs need external cmaps.
|
// Some PDFs need external cmaps.
|
||||||
//
|
//
|
||||||
|
@ -2,17 +2,19 @@
|
|||||||
|
|
||||||
// In production, the bundled pdf.js shall be used instead of SystemJS.
|
// In production, the bundled pdf.js shall be used instead of SystemJS.
|
||||||
Promise.all([System.import('pdfjs/display/api'),
|
Promise.all([System.import('pdfjs/display/api'),
|
||||||
System.import('pdfjs/display/global'),
|
System.import('pdfjs/display/worker_options'),
|
||||||
System.import('pdfjs/display/network'),
|
System.import('pdfjs/display/network'),
|
||||||
System.resolve('pdfjs/worker_loader')])
|
System.resolve('pdfjs/worker_loader')])
|
||||||
.then(function (modules) {
|
.then(function (modules) {
|
||||||
var api = modules[0], global = modules[1], network = modules[2];
|
var api = modules[0];
|
||||||
|
var GlobalWorkerOptions = modules[1].GlobalWorkerOptions;
|
||||||
|
var network = modules[2];
|
||||||
api.setPDFNetworkStreamFactory((params) => {
|
api.setPDFNetworkStreamFactory((params) => {
|
||||||
return new network.PDFNetworkStream(params);
|
return new network.PDFNetworkStream(params);
|
||||||
});
|
});
|
||||||
|
|
||||||
// In production, change this to point to the built `pdf.worker.js` file.
|
// In production, change this to point to the built `pdf.worker.js` file.
|
||||||
global.PDFJS.workerSrc = modules[3];
|
GlobalWorkerOptions.workerSrc = modules[3];
|
||||||
|
|
||||||
// Fetch the PDF document from the URL using promises.
|
// Fetch the PDF document from the URL using promises.
|
||||||
api.getDocument('helloworld.pdf').then(function (pdf) {
|
api.getDocument('helloworld.pdf').then(function (pdf) {
|
||||||
|
@ -22,7 +22,8 @@
|
|||||||
//
|
//
|
||||||
// The workerSrc property shall be specified.
|
// The workerSrc property shall be specified.
|
||||||
//
|
//
|
||||||
PDFJS.workerSrc = '../../node_modules/pdfjs-dist/build/pdf.worker.js';
|
PDFJS.GlobalWorkerOptions.workerSrc =
|
||||||
|
'../../node_modules/pdfjs-dist/build/pdf.worker.js';
|
||||||
|
|
||||||
//
|
//
|
||||||
// Asynchronous download PDF
|
// Asynchronous download PDF
|
||||||
|
@ -34,7 +34,8 @@
|
|||||||
//
|
//
|
||||||
// The workerSrc property shall be specified.
|
// The workerSrc property shall be specified.
|
||||||
//
|
//
|
||||||
PDFJS.workerSrc = '../../node_modules/pdfjs-dist/build/pdf.worker.js';
|
PDFJS.GlobalWorkerOptions.workerSrc =
|
||||||
|
'../../node_modules/pdfjs-dist/build/pdf.worker.js';
|
||||||
|
|
||||||
// Opening PDF by passing its binary data as a string. It is still preferable
|
// Opening PDF by passing its binary data as a string. It is still preferable
|
||||||
// to use Uint8Array, but string or array-like structure will work too.
|
// to use Uint8Array, but string or array-like structure will work too.
|
||||||
|
@ -33,7 +33,8 @@
|
|||||||
// pdf.js's one, or the pdf.js is executed via eval(), the workerSrc property
|
// pdf.js's one, or the pdf.js is executed via eval(), the workerSrc property
|
||||||
// shall be specified.
|
// shall be specified.
|
||||||
//
|
//
|
||||||
// PDFJS.workerSrc = '../../node_modules/pdfjs-dist/build/pdf.worker.js';
|
// PDFJS.GlobalWorkerOptions.workerSrc =
|
||||||
|
// '../../node_modules/pdfjs-dist/build/pdf.worker.js';
|
||||||
|
|
||||||
var pdfDoc = null,
|
var pdfDoc = null,
|
||||||
pageNum = 1,
|
pageNum = 1,
|
||||||
|
@ -24,10 +24,12 @@ if (typeof PDFJS === 'undefined' || !PDFJS.PDFViewer || !PDFJS.getDocument) {
|
|||||||
var USE_ONLY_CSS_ZOOM = true;
|
var USE_ONLY_CSS_ZOOM = true;
|
||||||
var TEXT_LAYER_MODE = 0; // DISABLE
|
var TEXT_LAYER_MODE = 0; // DISABLE
|
||||||
PDFJS.maxImageSize = 1024 * 1024;
|
PDFJS.maxImageSize = 1024 * 1024;
|
||||||
PDFJS.workerSrc = '../../node_modules/pdfjs-dist/build/pdf.worker.js';
|
|
||||||
PDFJS.cMapUrl = '../../node_modules/pdfjs-dist/cmaps/';
|
PDFJS.cMapUrl = '../../node_modules/pdfjs-dist/cmaps/';
|
||||||
PDFJS.cMapPacked = true;
|
PDFJS.cMapPacked = true;
|
||||||
|
|
||||||
|
PDFJS.GlobalWorkerOptions.workerSrc =
|
||||||
|
'../../node_modules/pdfjs-dist/build/pdf.worker.js';
|
||||||
|
|
||||||
var DEFAULT_URL = '../../web/compressed.tracemonkey-pldi-09.pdf';
|
var DEFAULT_URL = '../../web/compressed.tracemonkey-pldi-09.pdf';
|
||||||
var DEFAULT_SCALE_DELTA = 1.1;
|
var DEFAULT_SCALE_DELTA = 1.1;
|
||||||
var MIN_SCALE = 0.25;
|
var MIN_SCALE = 0.25;
|
||||||
|
@ -39,16 +39,21 @@ function renderDocument(pdf, svgLib) {
|
|||||||
Promise.all([System.import('pdfjs/display/api'),
|
Promise.all([System.import('pdfjs/display/api'),
|
||||||
System.import('pdfjs/display/svg'),
|
System.import('pdfjs/display/svg'),
|
||||||
System.import('pdfjs/display/global'),
|
System.import('pdfjs/display/global'),
|
||||||
|
System.import('pdfjs/display/worker_options'),
|
||||||
System.import('pdfjs/display/network'),
|
System.import('pdfjs/display/network'),
|
||||||
System.resolve('pdfjs/worker_loader')])
|
System.resolve('pdfjs/worker_loader')])
|
||||||
.then(function (modules) {
|
.then(function (modules) {
|
||||||
var api = modules[0], svg = modules[1], global = modules[2], network = modules[3];
|
var api = modules[0];
|
||||||
|
var svg = modules[1];
|
||||||
|
var global = modules[2];
|
||||||
|
var GlobalWorkerOptions = modules[3].GlobalWorkerOptions;
|
||||||
|
var network = modules[4];
|
||||||
api.setPDFNetworkStreamFactory((params) => {
|
api.setPDFNetworkStreamFactory((params) => {
|
||||||
return new network.PDFNetworkStream(params);
|
return new network.PDFNetworkStream(params);
|
||||||
});
|
});
|
||||||
|
|
||||||
// In production, change this to point to the built `pdf.worker.js` file.
|
// In production, change this to point to the built `pdf.worker.js` file.
|
||||||
global.PDFJS.workerSrc = modules[4];
|
GlobalWorkerOptions.workerSrc = modules[5];
|
||||||
|
|
||||||
// In production, change this to point to where the cMaps are placed.
|
// In production, change this to point to where the cMaps are placed.
|
||||||
global.PDFJS.cMapUrl = '../../external/bcmaps/';
|
global.PDFJS.cMapUrl = '../../external/bcmaps/';
|
||||||
|
@ -18,7 +18,8 @@ var PAGE_NUMBER = 1;
|
|||||||
var PAGE_SCALE = 1.5;
|
var PAGE_SCALE = 1.5;
|
||||||
var SVG_NS = 'http://www.w3.org/2000/svg';
|
var SVG_NS = 'http://www.w3.org/2000/svg';
|
||||||
|
|
||||||
PDFJS.workerSrc = '../../node_modules/pdfjs-dist/build/pdf.worker.js';
|
PDFJS.GlobalWorkerOptions.workerSrc =
|
||||||
|
'../../node_modules/pdfjs-dist/build/pdf.worker.js';
|
||||||
|
|
||||||
function buildSVG(viewport, textContent) {
|
function buildSVG(viewport, textContent) {
|
||||||
// Building SVG with size of the viewport (for simplicity)
|
// Building SVG with size of the viewport (for simplicity)
|
||||||
|
@ -8,7 +8,8 @@ var pdfjsLib = require('pdfjs-dist');
|
|||||||
var pdfPath = '../helloworld/helloworld.pdf';
|
var pdfPath = '../helloworld/helloworld.pdf';
|
||||||
|
|
||||||
// Setting worker path to worker bundle.
|
// Setting worker path to worker bundle.
|
||||||
pdfjsLib.PDFJS.workerSrc = '../../build/webpack/pdf.worker.bundle.js';
|
pdfjsLib.GlobalWorkerOptions.workerSrc =
|
||||||
|
'../../build/webpack/pdf.worker.bundle.js';
|
||||||
|
|
||||||
// Loading a document.
|
// Loading a document.
|
||||||
var loadingTask = pdfjsLib.getDocument(pdfPath);
|
var loadingTask = pdfjsLib.getDocument(pdfPath);
|
||||||
|
@ -34,11 +34,11 @@ import { WebGLContext } from './webgl';
|
|||||||
|
|
||||||
var DEFAULT_RANGE_CHUNK_SIZE = 65536; // 2^16 = 65536
|
var DEFAULT_RANGE_CHUNK_SIZE = 65536; // 2^16 = 65536
|
||||||
|
|
||||||
var isWorkerDisabled = false;
|
let isWorkerDisabled = false;
|
||||||
var workerSrc;
|
let workerSrc;
|
||||||
var isPostMessageTransfersDisabled = false;
|
var isPostMessageTransfersDisabled = false;
|
||||||
|
|
||||||
var pdfjsFilePath =
|
const pdfjsFilePath =
|
||||||
typeof PDFJSDev !== 'undefined' &&
|
typeof PDFJSDev !== 'undefined' &&
|
||||||
PDFJSDev.test('PRODUCTION && !(MOZCENTRAL || FIREFOX)') &&
|
PDFJSDev.test('PRODUCTION && !(MOZCENTRAL || FIREFOX)') &&
|
||||||
typeof document !== 'undefined' && document.currentScript ?
|
typeof document !== 'undefined' && document.currentScript ?
|
||||||
@ -47,8 +47,8 @@ var pdfjsFilePath =
|
|||||||
var fakeWorkerFilesLoader = null;
|
var fakeWorkerFilesLoader = null;
|
||||||
var useRequireEnsure = false;
|
var useRequireEnsure = false;
|
||||||
if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('GENERIC')) {
|
if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('GENERIC')) {
|
||||||
// For GENERIC build we need add support of different fake file loaders
|
// For GENERIC build we need to add support for different fake file loaders
|
||||||
// for different frameworks.
|
// for different frameworks.
|
||||||
if (typeof window === 'undefined') {
|
if (typeof window === 'undefined') {
|
||||||
// node.js - disable worker and set require.ensure.
|
// node.js - disable worker and set require.ensure.
|
||||||
isWorkerDisabled = true;
|
isWorkerDisabled = true;
|
||||||
@ -1202,8 +1202,8 @@ var PDFWorker = (function PDFWorkerClosure() {
|
|||||||
let nextFakeWorkerId = 0;
|
let nextFakeWorkerId = 0;
|
||||||
|
|
||||||
function getWorkerSrc() {
|
function getWorkerSrc() {
|
||||||
if (getDefaultSetting('workerSrc')) {
|
if (GlobalWorkerOptions.workerSrc) {
|
||||||
return getDefaultSetting('workerSrc');
|
return GlobalWorkerOptions.workerSrc;
|
||||||
}
|
}
|
||||||
if (typeof workerSrc !== 'undefined') {
|
if (typeof workerSrc !== 'undefined') {
|
||||||
return workerSrc;
|
return workerSrc;
|
||||||
@ -1213,7 +1213,7 @@ var PDFWorker = (function PDFWorkerClosure() {
|
|||||||
pdfjsFilePath) {
|
pdfjsFilePath) {
|
||||||
return pdfjsFilePath.replace(/(\.(?:min\.)?js)(\?.*)?$/i, '.worker$1$2');
|
return pdfjsFilePath.replace(/(\.(?:min\.)?js)(\?.*)?$/i, '.worker$1$2');
|
||||||
}
|
}
|
||||||
throw new Error('No PDFJS.workerSrc specified');
|
throw new Error('No "GlobalWorkerOptions.workerSrc" specified.');
|
||||||
}
|
}
|
||||||
|
|
||||||
function getMainThreadWorkerMessageHandler() {
|
function getMainThreadWorkerMessageHandler() {
|
||||||
|
@ -351,8 +351,6 @@ function getDefaultSetting(id) {
|
|||||||
return globalSettings ? globalSettings.cMapPacked : false;
|
return globalSettings ? globalSettings.cMapPacked : false;
|
||||||
case 'postMessageTransfers':
|
case 'postMessageTransfers':
|
||||||
return globalSettings ? globalSettings.postMessageTransfers : true;
|
return globalSettings ? globalSettings.postMessageTransfers : true;
|
||||||
case 'workerSrc':
|
|
||||||
return globalSettings ? globalSettings.workerSrc : null;
|
|
||||||
case 'maxImageSize':
|
case 'maxImageSize':
|
||||||
return globalSettings ? globalSettings.maxImageSize : -1;
|
return globalSettings ? globalSettings.maxImageSize : -1;
|
||||||
case 'isEvalSupported':
|
case 'isEvalSupported':
|
||||||
|
@ -112,16 +112,6 @@ PDFJS.cMapPacked = PDFJS.cMapPacked === undefined ? false : PDFJS.cMapPacked;
|
|||||||
PDFJS.disableFontFace = (PDFJS.disableFontFace === undefined ?
|
PDFJS.disableFontFace = (PDFJS.disableFontFace === undefined ?
|
||||||
false : PDFJS.disableFontFace);
|
false : PDFJS.disableFontFace);
|
||||||
|
|
||||||
/**
|
|
||||||
* Path and filename of the worker file. Required when the worker is enabled
|
|
||||||
* in development mode. If unspecified in the production build, the worker
|
|
||||||
* will be loaded based on the location of the pdf.js file. It is recommended
|
|
||||||
* that the workerSrc is set in a custom application to prevent issues caused
|
|
||||||
* by third-party frameworks and libraries.
|
|
||||||
* @var {string}
|
|
||||||
*/
|
|
||||||
PDFJS.workerSrc = (PDFJS.workerSrc === undefined ? null : PDFJS.workerSrc);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disable range request loading of PDF files. When enabled and if the server
|
* Disable range request loading of PDF files. When enabled and if the server
|
||||||
* supports partial content requests then the PDF will be fetched in chunks.
|
* supports partial content requests then the PDF will be fetched in chunks.
|
||||||
|
@ -16,9 +16,10 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var WAITING_TIME = 100; // ms
|
const WAITING_TIME = 100; // ms
|
||||||
var PDF_TO_CSS_UNITS = 96.0 / 72.0;
|
const PDF_TO_CSS_UNITS = 96.0 / 72.0;
|
||||||
const IMAGE_RESOURCES_PATH = '/web/images/';
|
const IMAGE_RESOURCES_PATH = '/web/images/';
|
||||||
|
const WORKER_SRC = '../build/generic/build/pdf.worker.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class
|
* @class
|
||||||
@ -267,8 +268,9 @@ var Driver = (function DriverClosure() { // eslint-disable-line no-unused-vars
|
|||||||
* @param {DriverOptions} options
|
* @param {DriverOptions} options
|
||||||
*/
|
*/
|
||||||
function Driver(options) {
|
function Driver(options) {
|
||||||
// Configure the global PDFJS object
|
// Configure the global worker options.
|
||||||
PDFJS.workerSrc = '../build/generic/build/pdf.worker.js';
|
PDFJS.GlobalWorkerOptions.workerSrc = WORKER_SRC;
|
||||||
|
|
||||||
PDFJS.cMapPacked = true;
|
PDFJS.cMapPacked = true;
|
||||||
PDFJS.cMapUrl = '../external/bcmaps/';
|
PDFJS.cMapUrl = '../external/bcmaps/';
|
||||||
PDFJS.pdfBug = true;
|
PDFJS.pdfBug = true;
|
||||||
|
@ -24,10 +24,10 @@ import {
|
|||||||
DOMCanvasFactory, RenderingCancelledException
|
DOMCanvasFactory, RenderingCancelledException
|
||||||
} from '../../src/display/dom_utils';
|
} from '../../src/display/dom_utils';
|
||||||
import {
|
import {
|
||||||
getDocument, PDFDocumentProxy, PDFPageProxy, PDFWorker
|
getDocument, PDFDataRangeTransport, PDFDocumentProxy, PDFPageProxy, PDFWorker
|
||||||
} from '../../src/display/api';
|
} from '../../src/display/api';
|
||||||
|
import { GlobalWorkerOptions } from '../../src/display/worker_options';
|
||||||
import isNodeJS from '../../src/shared/is_node';
|
import isNodeJS from '../../src/shared/is_node';
|
||||||
import { PDFJS } from '../../src/display/global';
|
|
||||||
|
|
||||||
describe('api', function() {
|
describe('api', function() {
|
||||||
let basicApiFileName = 'basicapi.pdf';
|
let basicApiFileName = 'basicapi.pdf';
|
||||||
@ -324,7 +324,7 @@ describe('api', function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
it('worker created or destroyed', function (done) {
|
it('worker created or destroyed', function (done) {
|
||||||
var worker = new PDFJS.PDFWorker('test1');
|
var worker = new PDFWorker('test1');
|
||||||
worker.promise.then(function () {
|
worker.promise.then(function () {
|
||||||
expect(worker.name).toEqual('test1');
|
expect(worker.name).toEqual('test1');
|
||||||
expect(!!worker.port).toEqual(true);
|
expect(!!worker.port).toEqual(true);
|
||||||
@ -361,7 +361,7 @@ describe('api', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
it('worker created and can be used in getDocument', function (done) {
|
it('worker created and can be used in getDocument', function (done) {
|
||||||
var worker = new PDFJS.PDFWorker('test1');
|
var worker = new PDFWorker('test1');
|
||||||
var loadingTask = getDocument(
|
var loadingTask = getDocument(
|
||||||
buildGetDocumentParams(basicApiFileName, {
|
buildGetDocumentParams(basicApiFileName, {
|
||||||
worker,
|
worker,
|
||||||
@ -386,9 +386,9 @@ describe('api', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
it('creates more than one worker', function (done) {
|
it('creates more than one worker', function (done) {
|
||||||
var worker1 = new PDFJS.PDFWorker('test1');
|
var worker1 = new PDFWorker('test1');
|
||||||
var worker2 = new PDFJS.PDFWorker('test2');
|
var worker2 = new PDFWorker('test2');
|
||||||
var worker3 = new PDFJS.PDFWorker('test3');
|
var worker3 = new PDFWorker('test3');
|
||||||
var ready = Promise.all([worker1.promise, worker2.promise,
|
var ready = Promise.all([worker1.promise, worker2.promise,
|
||||||
worker3.promise]);
|
worker3.promise]);
|
||||||
ready.then(function () {
|
ready.then(function () {
|
||||||
@ -406,7 +406,7 @@ describe('api', function() {
|
|||||||
it('gets current workerSrc', function() {
|
it('gets current workerSrc', function() {
|
||||||
let workerSrc = PDFWorker.getWorkerSrc();
|
let workerSrc = PDFWorker.getWorkerSrc();
|
||||||
expect(typeof workerSrc).toEqual('string');
|
expect(typeof workerSrc).toEqual('string');
|
||||||
expect(workerSrc).toEqual(PDFJS.workerSrc);
|
expect(workerSrc).toEqual(GlobalWorkerOptions.workerSrc);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe('PDFDocument', function() {
|
describe('PDFDocument', function() {
|
||||||
@ -1305,7 +1305,7 @@ describe('api', function() {
|
|||||||
var fetches = 0;
|
var fetches = 0;
|
||||||
var getDocumentPromise = getDocumentData().then(function (data) {
|
var getDocumentPromise = getDocumentData().then(function (data) {
|
||||||
var initialData = data.subarray(0, initialDataLength);
|
var initialData = data.subarray(0, initialDataLength);
|
||||||
transport = new PDFJS.PDFDataRangeTransport(data.length, initialData);
|
transport = new PDFDataRangeTransport(data.length, initialData);
|
||||||
transport.requestDataRange = function (begin, end) {
|
transport.requestDataRange = function (begin, end) {
|
||||||
fetches++;
|
fetches++;
|
||||||
waitSome(function () {
|
waitSome(function () {
|
||||||
@ -1339,7 +1339,7 @@ describe('api', function() {
|
|||||||
var fetches = 0;
|
var fetches = 0;
|
||||||
var getDocumentPromise = getDocumentData().then(function (data) {
|
var getDocumentPromise = getDocumentData().then(function (data) {
|
||||||
var initialData = data.subarray(0, initialDataLength);
|
var initialData = data.subarray(0, initialDataLength);
|
||||||
transport = new PDFJS.PDFDataRangeTransport(data.length, initialData);
|
transport = new PDFDataRangeTransport(data.length, initialData);
|
||||||
transport.requestDataRange = function (begin, end) {
|
transport.requestDataRange = function (begin, end) {
|
||||||
fetches++;
|
fetches++;
|
||||||
if (fetches === 1) {
|
if (fetches === 1) {
|
||||||
|
@ -42,8 +42,8 @@
|
|||||||
|
|
||||||
function initializePDFJS(callback) {
|
function initializePDFJS(callback) {
|
||||||
Promise.all([
|
Promise.all([
|
||||||
'pdfjs/display/global',
|
|
||||||
'pdfjs/display/api',
|
'pdfjs/display/api',
|
||||||
|
'pdfjs/display/worker_options',
|
||||||
'pdfjs/display/network',
|
'pdfjs/display/network',
|
||||||
'pdfjs/display/fetch_stream',
|
'pdfjs/display/fetch_stream',
|
||||||
'pdfjs/shared/is_node',
|
'pdfjs/shared/is_node',
|
||||||
@ -77,9 +77,9 @@ function initializePDFJS(callback) {
|
|||||||
'pdfjs-test/unit/util_stream_spec',
|
'pdfjs-test/unit/util_stream_spec',
|
||||||
].map(function (moduleName) {
|
].map(function (moduleName) {
|
||||||
return SystemJS.import(moduleName);
|
return SystemJS.import(moduleName);
|
||||||
})).then(function (modules) {
|
})).then(function(modules) {
|
||||||
var displayGlobal = modules[0];
|
var displayApi = modules[0];
|
||||||
var displayApi = modules[1];
|
const GlobalWorkerOptions = modules[1].GlobalWorkerOptions;
|
||||||
var PDFNetworkStream = modules[2].PDFNetworkStream;
|
var PDFNetworkStream = modules[2].PDFNetworkStream;
|
||||||
var PDFFetchStream = modules[3].PDFFetchStream;
|
var PDFFetchStream = modules[3].PDFFetchStream;
|
||||||
const isNodeJS = modules[4];
|
const isNodeJS = modules[4];
|
||||||
@ -101,7 +101,7 @@ function initializePDFJS(callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Configure the worker.
|
// Configure the worker.
|
||||||
displayGlobal.PDFJS.workerSrc = '../../build/generic/build/pdf.worker.js';
|
GlobalWorkerOptions.workerSrc = '../../build/generic/build/pdf.worker.js';
|
||||||
|
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
|
10
web/app.js
10
web/app.js
@ -21,9 +21,9 @@ import {
|
|||||||
ProgressBar, RendererType, TextLayerMode
|
ProgressBar, RendererType, TextLayerMode
|
||||||
} from './ui_utils';
|
} from './ui_utils';
|
||||||
import {
|
import {
|
||||||
build, createBlob, getDocument, getFilenameFromUrl, InvalidPDFException,
|
build, createBlob, getDocument, getFilenameFromUrl, GlobalWorkerOptions,
|
||||||
LinkTarget, MissingPDFException, OPS, PDFJS, PDFWorker, shadow,
|
InvalidPDFException, LinkTarget, MissingPDFException, OPS, PDFJS, PDFWorker,
|
||||||
UnexpectedResponseException, UNSUPPORTED_FEATURES, version
|
shadow, UnexpectedResponseException, UNSUPPORTED_FEATURES, version
|
||||||
} from 'pdfjs-lib';
|
} from 'pdfjs-lib';
|
||||||
import { CursorTool, PDFCursorTools } from './pdf_cursor_tools';
|
import { CursorTool, PDFCursorTools } from './pdf_cursor_tools';
|
||||||
import { PDFRenderingQueue, RenderingStates } from './pdf_rendering_queue';
|
import { PDFRenderingQueue, RenderingStates } from './pdf_rendering_queue';
|
||||||
@ -54,11 +54,11 @@ function configure(PDFJS) {
|
|||||||
PDFJS.imageResourcesPath = './images/';
|
PDFJS.imageResourcesPath = './images/';
|
||||||
if (typeof PDFJSDev !== 'undefined' &&
|
if (typeof PDFJSDev !== 'undefined' &&
|
||||||
PDFJSDev.test('FIREFOX || MOZCENTRAL || GENERIC || CHROME')) {
|
PDFJSDev.test('FIREFOX || MOZCENTRAL || GENERIC || CHROME')) {
|
||||||
PDFJS.workerSrc = '../build/pdf.worker.js';
|
GlobalWorkerOptions.workerSrc = '../build/pdf.worker.js';
|
||||||
}
|
}
|
||||||
if (typeof PDFJSDev === 'undefined' || !PDFJSDev.test('PRODUCTION')) {
|
if (typeof PDFJSDev === 'undefined' || !PDFJSDev.test('PRODUCTION')) {
|
||||||
PDFJS.cMapUrl = '../external/bcmaps/';
|
PDFJS.cMapUrl = '../external/bcmaps/';
|
||||||
PDFJS.workerSrc = '../src/worker_loader.js';
|
GlobalWorkerOptions.workerSrc = '../src/worker_loader.js';
|
||||||
} else {
|
} else {
|
||||||
PDFJS.cMapUrl = '../web/cmaps/';
|
PDFJS.cMapUrl = '../web/cmaps/';
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user