Merge pull request #6771 from yurydelendik/requirejs
Removes hardcoded module loading order
This commit is contained in:
commit
e8db825512
@ -5,6 +5,9 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
// Specify the PDF with AcroForm here
|
||||||
|
var pdfWithFormsPath = '../../test/pdfs/f1040.pdf';
|
||||||
|
|
||||||
var formFields = {};
|
var formFields = {};
|
||||||
|
|
||||||
function setupForm(div, content, viewport) {
|
function setupForm(div, content, viewport) {
|
||||||
@ -135,16 +138,23 @@ function renderPage(div, pdf, pageNumber, callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch the PDF document from the URL using promices
|
// In production, the bundled pdf.js shall be used instead of RequireJS.
|
||||||
PDFJS.getDocument(pdfWithFormsPath).then(function getPdfForm(pdf) {
|
require.config({paths: {'pdfjs': '../../src'}});
|
||||||
// Rendering all pages starting from first
|
require(['pdfjs/display/api'], function (api) {
|
||||||
var viewer = document.getElementById('viewer');
|
// In production, change this to point to the built `pdf.worker.js` file.
|
||||||
var pageNumber = 1;
|
PDFJS.workerSrc = '../../src/worker_loader.js';
|
||||||
renderPage(viewer, pdf, pageNumber++, function pageRenderingComplete() {
|
|
||||||
if (pageNumber > pdf.numPages) {
|
// Fetch the PDF document from the URL using promises.
|
||||||
return; // All pages rendered
|
api.getDocument(pdfWithFormsPath).then(function getPdfForm(pdf) {
|
||||||
}
|
// Rendering all pages starting from first
|
||||||
// Continue rendering of the next page
|
var viewer = document.getElementById('viewer');
|
||||||
renderPage(viewer, pdf, pageNumber++, pageRenderingComplete);
|
var pageNumber = 1;
|
||||||
|
renderPage(viewer, pdf, pageNumber++, function pageRenderingComplete() {
|
||||||
|
if (pageNumber > pdf.numPages) {
|
||||||
|
return; // All pages rendered
|
||||||
|
}
|
||||||
|
// Continue rendering of the next page
|
||||||
|
renderPage(viewer, pdf, pageNumber++, pageRenderingComplete);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -2,27 +2,7 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<!-- In production, only one script (pdf.js) is necessary -->
|
<script src="../../node_modules/requirejs/require.js"></script>
|
||||||
<!-- In production, change the content of PDFJS.workerSrc below -->
|
|
||||||
<script src="../../src/shared/global.js"></script>
|
|
||||||
<script src="../../src/display/dom_utils.js"></script>
|
|
||||||
<script src="../../src/shared/util.js"></script>
|
|
||||||
<script src="../../src/display/annotation_layer.js"></script>
|
|
||||||
<script src="../../src/display/font_loader.js"></script>
|
|
||||||
<script src="../../src/display/metadata.js"></script>
|
|
||||||
<script src="../../src/display/text_layer.js"></script>
|
|
||||||
<script src="../../src/display/webgl.js"></script>
|
|
||||||
<script src="../../src/display/pattern_helper.js"></script>
|
|
||||||
<script src="../../src/display/canvas.js"></script>
|
|
||||||
<script src="../../src/display/api.js"></script>
|
|
||||||
<script>
|
|
||||||
// Specify the main script used to create a new PDF.JS web worker.
|
|
||||||
// In production, change this to point to the combined `pdf.js` file.
|
|
||||||
PDFJS.workerSrc = '../../src/worker_loader.js';
|
|
||||||
|
|
||||||
// Specify the PDF with AcroForm here
|
|
||||||
var pdfWithFormsPath = '../../test/pdfs/f1040.pdf';
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.pdfpage { position:relative; top: 0; left: 0; border: solid 1px black; margin: 10px; }
|
.pdfpage { position:relative; top: 0; left: 0; border: solid 1px black; margin: 10px; }
|
||||||
|
@ -1,34 +1,30 @@
|
|||||||
|
|
||||||
//
|
|
||||||
// See README for overview
|
|
||||||
//
|
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
//
|
// In production, the bundled pdf.js shall be used instead of RequireJS.
|
||||||
// Fetch the PDF document from the URL using promises
|
require.config({paths: {'pdfjs': '../../src'}});
|
||||||
//
|
require(['pdfjs/display/api'], function (api) {
|
||||||
PDFJS.getDocument('helloworld.pdf').then(function(pdf) {
|
// In production, change this to point to the built `pdf.worker.js` file.
|
||||||
// Using promise to fetch the page
|
PDFJS.workerSrc = '../../src/worker_loader.js';
|
||||||
pdf.getPage(1).then(function(page) {
|
|
||||||
var scale = 1.5;
|
|
||||||
var viewport = page.getViewport(scale);
|
|
||||||
|
|
||||||
//
|
// Fetch the PDF document from the URL using promises.
|
||||||
// Prepare canvas using PDF page dimensions
|
api.getDocument('helloworld.pdf').then(function (pdf) {
|
||||||
//
|
// Fetch the page.
|
||||||
var canvas = document.getElementById('the-canvas');
|
pdf.getPage(1).then(function (page) {
|
||||||
var context = canvas.getContext('2d');
|
var scale = 1.5;
|
||||||
canvas.height = viewport.height;
|
var viewport = page.getViewport(scale);
|
||||||
canvas.width = viewport.width;
|
|
||||||
|
|
||||||
//
|
// Prepare canvas using PDF page dimensions.
|
||||||
// Render PDF page into canvas context
|
var canvas = document.getElementById('the-canvas');
|
||||||
//
|
var context = canvas.getContext('2d');
|
||||||
var renderContext = {
|
canvas.height = viewport.height;
|
||||||
canvasContext: context,
|
canvas.width = viewport.width;
|
||||||
viewport: viewport
|
|
||||||
};
|
// Render PDF page into canvas context.
|
||||||
page.render(renderContext);
|
var renderContext = {
|
||||||
|
canvasContext: context,
|
||||||
|
viewport: viewport
|
||||||
|
};
|
||||||
|
page.render(renderContext);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -2,26 +2,7 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<!-- In production, only one script (pdf.js) is necessary -->
|
<script src="../../node_modules/requirejs/require.js"></script>
|
||||||
<!-- In production, change the content of PDFJS.workerSrc below -->
|
|
||||||
<script src="../../src/shared/global.js"></script>
|
|
||||||
<script src="../../src/display/dom_utils.js"></script>
|
|
||||||
<script src="../../src/shared/util.js"></script>
|
|
||||||
<script src="../../src/display/annotation_layer.js"></script>
|
|
||||||
<script src="../../src/display/font_loader.js"></script>
|
|
||||||
<script src="../../src/display/metadata.js"></script>
|
|
||||||
<script src="../../src/display/text_layer.js"></script>
|
|
||||||
<script src="../../src/display/webgl.js"></script>
|
|
||||||
<script src="../../src/display/pattern_helper.js"></script>
|
|
||||||
<script src="../../src/display/canvas.js"></script>
|
|
||||||
<script src="../../src/display/api.js"></script>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
// Specify the main script used to create a new PDF.JS web worker.
|
|
||||||
// In production, leave this undefined or change it to point to the
|
|
||||||
// combined `pdf.worker.js` file.
|
|
||||||
PDFJS.workerSrc = '../../src/worker_loader.js';
|
|
||||||
</script>
|
|
||||||
<script src="hello.js"></script>
|
<script src="hello.js"></script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
@ -2,24 +2,7 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<!-- In production, only one script (pdf.js) is necessary -->
|
<script src="../../node_modules/requirejs/require.js"></script>
|
||||||
<!-- In production, change the content of PDFJS.workerSrc below -->
|
|
||||||
<script src="../../src/shared/global.js"></script>
|
|
||||||
<script src="../../src/shared/util.js"></script>
|
|
||||||
<script src="../../src/display/font_loader.js"></script>
|
|
||||||
<script src="../../src/display/metadata.js"></script>
|
|
||||||
<script src="../../src/display/svg.js"></script>
|
|
||||||
<script src="../../src/display/webgl.js"></script>
|
|
||||||
<script src="../../src/display/pattern_helper.js"></script>
|
|
||||||
<script src="../../src/display/canvas.js"></script>
|
|
||||||
<script src="../../src/display/api.js"></script>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
// Specify the main script used to create a new PDF.JS web worker.
|
|
||||||
// In production, leave this undefined or change it to point to the
|
|
||||||
// combined `pdf.worker.js` file.
|
|
||||||
PDFJS.workerSrc = '../../src/worker_loader.js';
|
|
||||||
</script>
|
|
||||||
<script src="viewer.js"></script>
|
<script src="viewer.js"></script>
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
|
@ -1,8 +1,3 @@
|
|||||||
|
|
||||||
//
|
|
||||||
// See README for overview
|
|
||||||
//
|
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
// Parse query string to extract some parameters (it can fail for some input)
|
// Parse query string to extract some parameters (it can fail for some input)
|
||||||
@ -14,10 +9,7 @@ var queryParams = query ? JSON.parse('{' + query.split('&').map(function (a) {
|
|||||||
var url = queryParams.file || '../../test/pdfs/liveprogramming.pdf';
|
var url = queryParams.file || '../../test/pdfs/liveprogramming.pdf';
|
||||||
var scale = +queryParams.scale || 1.5;
|
var scale = +queryParams.scale || 1.5;
|
||||||
|
|
||||||
//
|
function renderDocument(pdf) {
|
||||||
// Fetch the PDF document from the URL using promises
|
|
||||||
//
|
|
||||||
PDFJS.getDocument(url).then(function(pdf) {
|
|
||||||
var numPages = pdf.numPages;
|
var numPages = pdf.numPages;
|
||||||
// Using promise to fetch the page
|
// Using promise to fetch the page
|
||||||
|
|
||||||
@ -53,4 +45,14 @@ PDFJS.getDocument(url).then(function(pdf) {
|
|||||||
});
|
});
|
||||||
}.bind(null, i, anchor));
|
}.bind(null, i, anchor));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// In production, the bundled pdf.js shall be used instead of RequireJS.
|
||||||
|
require.config({paths: {'pdfjs': '../../src'}});
|
||||||
|
require(['pdfjs/display/api', 'pdfjs/display/svg'], function (api, svg) {
|
||||||
|
// In production, change this to point to the built `pdf.worker.js` file.
|
||||||
|
PDFJS.workerSrc = '../../src/worker_loader.js';
|
||||||
|
|
||||||
|
// Fetch the PDF document from the URL using promises.
|
||||||
|
api.getDocument(url).then(renderDocument);
|
||||||
});
|
});
|
||||||
|
30
external/builder/builder.js
vendored
30
external/builder/builder.js
vendored
@ -303,36 +303,6 @@ function build(setup) {
|
|||||||
}
|
}
|
||||||
exports.build = build;
|
exports.build = build;
|
||||||
|
|
||||||
function getWorkerSrcFiles(filePath) {
|
|
||||||
var src = fs.readFileSync(filePath).toString();
|
|
||||||
var reSrcFiles = /var\s+otherFiles\s*=\s*(\[[^\]]*\])/;
|
|
||||||
var match = reSrcFiles.exec(src);
|
|
||||||
if (!match) {
|
|
||||||
throw new Error('Cannot find otherFiles array in ' + filePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
var files = match[1].replace(/'/g, '"').replace(/^\s*\/\/.*/gm, '')
|
|
||||||
.replace(/,\s*]$/, ']');
|
|
||||||
try {
|
|
||||||
files = JSON.parse(files);
|
|
||||||
} catch (e) {
|
|
||||||
throw new Error('Failed to parse otherFiles in ' + filePath + ' as JSON, ' +
|
|
||||||
e);
|
|
||||||
}
|
|
||||||
|
|
||||||
var srcFiles = files.filter(function(name) {
|
|
||||||
return name.indexOf('external') === -1;
|
|
||||||
});
|
|
||||||
var externalSrcFiles = files.filter(function(name) {
|
|
||||||
return name.indexOf('external') > -1;
|
|
||||||
});
|
|
||||||
return {
|
|
||||||
srcFiles: srcFiles,
|
|
||||||
externalSrcFiles: externalSrcFiles
|
|
||||||
};
|
|
||||||
}
|
|
||||||
exports.getWorkerSrcFiles = getWorkerSrcFiles;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Merge two defines arrays. Values in the second param will override values in
|
* Merge two defines arrays. Values in the second param will override values in
|
||||||
* the first.
|
* the first.
|
||||||
|
51
external/umdutils/genhtml.js
vendored
51
external/umdutils/genhtml.js
vendored
@ -1,51 +0,0 @@
|
|||||||
/* Copyright 2015 Mozilla Foundation
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
/* jshint node:true */
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
// Simple util to re-generate HTML module references in right load order.
|
|
||||||
|
|
||||||
var fs = require('fs');
|
|
||||||
var path = require('path');
|
|
||||||
var umd = require('./verifier.js');
|
|
||||||
|
|
||||||
var filePath = process.argv[2];
|
|
||||||
if (!filePath) {
|
|
||||||
console.log('USAGE: node ./external/umdutils/genhtml.js <html-file-path>');
|
|
||||||
process.exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
var content = fs.readFileSync(filePath).toString();
|
|
||||||
var m, re = /<script\s+src=['"]([^'"]+)/g;
|
|
||||||
var filesFound = [];
|
|
||||||
while ((m = re.exec(content))) {
|
|
||||||
var jsPath = m[1];
|
|
||||||
if (!/\bsrc\/.*?\.js$/.test(jsPath)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
filesFound.push(jsPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
var srcPrefix = filesFound[0].substring(0, filesFound[0].indexOf('src/') + 4);
|
|
||||||
|
|
||||||
var dependencies = umd.readDependencies(filesFound.map(function (p) {
|
|
||||||
return path.join(path.dirname(filePath), p);
|
|
||||||
}));
|
|
||||||
|
|
||||||
dependencies.loadOrder.forEach(function (i) {
|
|
||||||
console.log('<script src="' + i.replace('pdfjs/', srcPrefix) + '.js">'+
|
|
||||||
'</script>');
|
|
||||||
});
|
|
2
external/umdutils/verifier.js
vendored
2
external/umdutils/verifier.js
vendored
@ -59,7 +59,7 @@ function parseUmd(filePath) {
|
|||||||
var umdStart = '\\(function\\s\\(root,\\sfactory\\)\\s\\{';
|
var umdStart = '\\(function\\s\\(root,\\sfactory\\)\\s\\{';
|
||||||
var umdImports = '\\}\\(this,\\sfunction\\s\\(exports\\b';
|
var umdImports = '\\}\\(this,\\sfunction\\s\\(exports\\b';
|
||||||
var umdBody = '\\)\\s\\{';
|
var umdBody = '\\)\\s\\{';
|
||||||
var umdEnd = '\\}\\)\\);\\s*$';
|
var umdEnd = '\\}\\)\\);\\s*(//#endif\\s*)?$';
|
||||||
var m, re;
|
var m, re;
|
||||||
m = new RegExp(umdStart + '([\\s\\S]*?)' + umdImports + '([\\s\\S]*?)' +
|
m = new RegExp(umdStart + '([\\s\\S]*?)' + umdImports + '([\\s\\S]*?)' +
|
||||||
umdBody + '([\\s\\S]*?)' + umdEnd).exec(jscode);
|
umdBody + '([\\s\\S]*?)' + umdEnd).exec(jscode);
|
||||||
|
92
make.js
92
make.js
@ -477,7 +477,6 @@ target.cmaps = function () {
|
|||||||
target.bundle = function(args) {
|
target.bundle = function(args) {
|
||||||
args = args || {};
|
args = args || {};
|
||||||
var defines = args.defines || DEFINES;
|
var defines = args.defines || DEFINES;
|
||||||
var excludes = args.excludes || [];
|
|
||||||
|
|
||||||
target.buildnumber();
|
target.buildnumber();
|
||||||
|
|
||||||
@ -485,21 +484,13 @@ target.bundle = function(args) {
|
|||||||
echo();
|
echo();
|
||||||
echo('### Bundling files into ' + BUILD_TARGET);
|
echo('### Bundling files into ' + BUILD_TARGET);
|
||||||
|
|
||||||
function bundle(filename, outfilename, SRC_FILES, EXT_SRC_FILES) {
|
function bundle(filename, outfilename, files) {
|
||||||
for (var i = 0, length = excludes.length; i < length; ++i) {
|
var bundleContent = cat(files),
|
||||||
var exclude = excludes[i];
|
|
||||||
var index = SRC_FILES.indexOf(exclude);
|
|
||||||
if (index >= 0) {
|
|
||||||
SRC_FILES.splice(index, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var bundleContent = cat(SRC_FILES),
|
|
||||||
bundleVersion = VERSION,
|
bundleVersion = VERSION,
|
||||||
bundleBuild = exec('git log --format="%h" -n 1',
|
bundleBuild = exec('git log --format="%h" -n 1',
|
||||||
{silent: true}).output.replace('\n', '');
|
{silent: true}).output.replace('\n', '');
|
||||||
|
|
||||||
crlfchecker.checkIfCrlfIsPresent(SRC_FILES);
|
crlfchecker.checkIfCrlfIsPresent(files);
|
||||||
|
|
||||||
// Prepend a newline because stripCommentHeaders only strips comments that
|
// Prepend a newline because stripCommentHeaders only strips comments that
|
||||||
// follow a line feed. The file where bundleContent is inserted already
|
// follow a line feed. The file where bundleContent is inserted already
|
||||||
@ -509,9 +500,6 @@ target.bundle = function(args) {
|
|||||||
// Removes AMD and CommonJS branches from UMD headers.
|
// Removes AMD and CommonJS branches from UMD headers.
|
||||||
bundleContent = stripUMDHeaders(bundleContent);
|
bundleContent = stripUMDHeaders(bundleContent);
|
||||||
|
|
||||||
// Append external files last since we don't want to modify them.
|
|
||||||
bundleContent += cat(EXT_SRC_FILES);
|
|
||||||
|
|
||||||
// This just preprocesses the empty pdf.js file, we don't actually want to
|
// This just preprocesses the empty pdf.js file, we don't actually want to
|
||||||
// preprocess everything yet since other build targets use this file.
|
// preprocess everything yet since other build targets use this file.
|
||||||
builder.preprocess(filename, outfilename, builder.merge(defines,
|
builder.preprocess(filename, outfilename, builder.merge(defines,
|
||||||
@ -524,47 +512,51 @@ target.bundle = function(args) {
|
|||||||
mkdir(BUILD_DIR);
|
mkdir(BUILD_DIR);
|
||||||
}
|
}
|
||||||
|
|
||||||
var SHARED_SRC_FILES = [
|
var umd = require('./external/umdutils/verifier.js');
|
||||||
'shared/global.js',
|
var MAIN_SRC_FILES = [
|
||||||
'shared/util.js'
|
SRC_DIR + 'display/annotation_layer.js',
|
||||||
|
SRC_DIR + 'display/metadata.js',
|
||||||
|
SRC_DIR + 'display/text_layer.js',
|
||||||
|
SRC_DIR + 'display/api.js'
|
||||||
];
|
];
|
||||||
|
|
||||||
var MAIN_SRC_FILES = SHARED_SRC_FILES.concat([
|
var WORKER_SRC_FILES = [
|
||||||
'display/dom_utils.js',
|
SRC_DIR + 'core/worker.js'
|
||||||
'display/annotation_layer.js',
|
];
|
||||||
'display/font_loader.js',
|
|
||||||
'display/metadata.js',
|
|
||||||
'display/text_layer.js',
|
|
||||||
'display/webgl.js',
|
|
||||||
'display/pattern_helper.js',
|
|
||||||
'display/canvas.js',
|
|
||||||
'display/api.js',
|
|
||||||
'display/svg.js'
|
|
||||||
]);
|
|
||||||
|
|
||||||
var srcFiles = builder.getWorkerSrcFiles('src/worker_loader.js');
|
// Extension does not need svg.js and network.js files.
|
||||||
var WORKER_SRC_FILES = srcFiles.srcFiles;
|
if (!defines.FIREFOX && !defines.MOZCENTRAL) {
|
||||||
|
MAIN_SRC_FILES.push(SRC_DIR + 'display/svg.js');
|
||||||
if (!defines.SINGLE_FILE) {
|
WORKER_SRC_FILES.push(SRC_DIR + 'core/network.js');
|
||||||
// We want shared_src_files in both pdf.js and pdf.worker.js
|
|
||||||
// unless it's being built in singlefile mode.
|
|
||||||
WORKER_SRC_FILES = SHARED_SRC_FILES.concat(WORKER_SRC_FILES);
|
|
||||||
} else {
|
|
||||||
// In singlefile mode, all of the src files will be bundled into
|
|
||||||
// the main pdf.js outuput.
|
|
||||||
MAIN_SRC_FILES = MAIN_SRC_FILES.concat(WORKER_SRC_FILES);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var EXT_SRC_FILES = srcFiles.externalSrcFiles;
|
if (defines.SINGLE_FILE) {
|
||||||
|
// In singlefile mode, all of the src files will be bundled into
|
||||||
|
// the main pdf.js output.
|
||||||
|
MAIN_SRC_FILES = MAIN_SRC_FILES.concat(WORKER_SRC_FILES);
|
||||||
|
WORKER_SRC_FILES = null; // no need for worker file
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reading UMD headers and building loading orders of modules. The
|
||||||
|
// readDependencies returns AMD module names: removing 'pdfjs' prefix and
|
||||||
|
// adding '.js' extensions to the name.
|
||||||
|
var mainFiles = umd.readDependencies(MAIN_SRC_FILES).loadOrder.map(
|
||||||
|
function (name) { return name.replace('pdfjs/', '') + '.js'; });
|
||||||
|
|
||||||
|
var workerFiles = WORKER_SRC_FILES &&
|
||||||
|
umd.readDependencies(WORKER_SRC_FILES).loadOrder.map(
|
||||||
|
function (name) { return name.replace('pdfjs/', '') + '.js'; });
|
||||||
|
|
||||||
cd(SRC_DIR);
|
cd(SRC_DIR);
|
||||||
|
|
||||||
bundle('pdf.js', ROOT_DIR + BUILD_TARGET, MAIN_SRC_FILES, []);
|
bundle('pdf.js', ROOT_DIR + BUILD_TARGET, mainFiles);
|
||||||
var srcCopy = ROOT_DIR + BUILD_DIR + 'pdf.worker.js.temp';
|
|
||||||
cp('pdf.js', srcCopy);
|
if (workerFiles) {
|
||||||
bundle(srcCopy, ROOT_DIR + BUILD_WORKER_TARGET, WORKER_SRC_FILES,
|
var srcCopy = ROOT_DIR + BUILD_DIR + 'pdf.worker.js.temp';
|
||||||
EXT_SRC_FILES);
|
cp('pdf.js', srcCopy);
|
||||||
rm(srcCopy);
|
bundle(srcCopy, ROOT_DIR + BUILD_WORKER_TARGET, workerFiles);
|
||||||
|
rm(srcCopy);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -796,7 +788,7 @@ target.firefox = function() {
|
|||||||
FIREFOX_AMO_EXTENSION_NAME = 'pdf.js.amo.xpi';
|
FIREFOX_AMO_EXTENSION_NAME = 'pdf.js.amo.xpi';
|
||||||
|
|
||||||
target.locale();
|
target.locale();
|
||||||
target.bundle({ excludes: ['core/network.js'], defines: defines });
|
target.bundle({ defines: defines });
|
||||||
cd(ROOT_DIR);
|
cd(ROOT_DIR);
|
||||||
|
|
||||||
// Clear out everything in the firefox extension build directory
|
// Clear out everything in the firefox extension build directory
|
||||||
@ -923,7 +915,7 @@ target.mozcentral = function() {
|
|||||||
['icon.png',
|
['icon.png',
|
||||||
'icon64.png'];
|
'icon64.png'];
|
||||||
|
|
||||||
target.bundle({ excludes: ['core/network.js'], defines: defines });
|
target.bundle({ defines: defines });
|
||||||
cd(ROOT_DIR);
|
cd(ROOT_DIR);
|
||||||
|
|
||||||
// Clear out everything in the firefox extension build directory
|
// Clear out everything in the firefox extension build directory
|
||||||
|
@ -4,11 +4,12 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"jsdoc": "^3.3.0-alpha9",
|
"jsdoc": "^3.3.0-alpha9",
|
||||||
"jshint": "~2.8.0",
|
"jshint": "~2.8.0",
|
||||||
"wintersmith": "^2.0.0",
|
|
||||||
"node-ensure": "^0.0.0",
|
"node-ensure": "^0.0.0",
|
||||||
|
"requirejs": "^2.1.22",
|
||||||
"rimraf": "^2.4.1",
|
"rimraf": "^2.4.1",
|
||||||
"shelljs": "~0.4.0",
|
"shelljs": "~0.4.0",
|
||||||
"typogr": "~0.6.5",
|
"typogr": "~0.6.5",
|
||||||
|
"wintersmith": "^2.0.0",
|
||||||
"yargs": "^3.14.0"
|
"yargs": "^3.14.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -291,3 +291,17 @@ var NetworkManager = (function NetworkManagerClosure() {
|
|||||||
|
|
||||||
return NetworkManager;
|
return NetworkManager;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
//#if !(FIREFOX || MOZCENTRAL)
|
||||||
|
(function (root, factory) {
|
||||||
|
if (typeof define === 'function' && define.amd) {
|
||||||
|
define('pdfjs/core/network', ['exports'], factory);
|
||||||
|
} else if (typeof exports !== 'undefined') {
|
||||||
|
factory(exports);
|
||||||
|
} else {
|
||||||
|
factory((root.pdfjsCoreNetwork = {}));
|
||||||
|
}
|
||||||
|
}(this, function (exports) {
|
||||||
|
exports.NetworkManager = NetworkManager;
|
||||||
|
}));
|
||||||
|
//#endif
|
||||||
|
@ -84,7 +84,13 @@ var WorkerTask = (function WorkerTaskClosure() {
|
|||||||
|
|
||||||
var WorkerMessageHandler = PDFJS.WorkerMessageHandler = {
|
var WorkerMessageHandler = PDFJS.WorkerMessageHandler = {
|
||||||
setup: function wphSetup(handler, port) {
|
setup: function wphSetup(handler, port) {
|
||||||
|
var testMessageProcessed = false;
|
||||||
handler.on('test', function wphSetupTest(data) {
|
handler.on('test', function wphSetupTest(data) {
|
||||||
|
if (testMessageProcessed) {
|
||||||
|
return; // we already processed 'test' message once
|
||||||
|
}
|
||||||
|
testMessageProcessed = true;
|
||||||
|
|
||||||
// check if Uint8Array can be sent to worker
|
// check if Uint8Array can be sent to worker
|
||||||
if (!(data instanceof Uint8Array)) {
|
if (!(data instanceof Uint8Array)) {
|
||||||
handler.send('test', 'main', false);
|
handler.send('test', 'main', false);
|
||||||
@ -611,51 +617,57 @@ var WorkerMessageHandler = PDFJS.WorkerMessageHandler = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var consoleTimer = {};
|
function initializeWorker() {
|
||||||
|
//#if !MOZCENTRAL
|
||||||
var workerConsole = {
|
|
||||||
log: function log() {
|
|
||||||
var args = Array.prototype.slice.call(arguments);
|
|
||||||
globalScope.postMessage({
|
|
||||||
targetName: 'main',
|
|
||||||
action: 'console_log',
|
|
||||||
data: args
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
error: function error() {
|
|
||||||
var args = Array.prototype.slice.call(arguments);
|
|
||||||
globalScope.postMessage({
|
|
||||||
targetName: 'main',
|
|
||||||
action: 'console_error',
|
|
||||||
data: args
|
|
||||||
});
|
|
||||||
throw 'pdf.js execution error';
|
|
||||||
},
|
|
||||||
|
|
||||||
time: function time(name) {
|
|
||||||
consoleTimer[name] = Date.now();
|
|
||||||
},
|
|
||||||
|
|
||||||
timeEnd: function timeEnd(name) {
|
|
||||||
var time = consoleTimer[name];
|
|
||||||
if (!time) {
|
|
||||||
error('Unknown timer name ' + name);
|
|
||||||
}
|
|
||||||
this.log('Timer:', name, Date.now() - time);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// Worker thread?
|
|
||||||
if (typeof window === 'undefined' &&
|
|
||||||
!(typeof module !== 'undefined' && module.require)) {
|
|
||||||
if (!('console' in globalScope)) {
|
if (!('console' in globalScope)) {
|
||||||
|
var consoleTimer = {};
|
||||||
|
|
||||||
|
var workerConsole = {
|
||||||
|
log: function log() {
|
||||||
|
var args = Array.prototype.slice.call(arguments);
|
||||||
|
globalScope.postMessage({
|
||||||
|
targetName: 'main',
|
||||||
|
action: 'console_log',
|
||||||
|
data: args
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
error: function error() {
|
||||||
|
var args = Array.prototype.slice.call(arguments);
|
||||||
|
globalScope.postMessage({
|
||||||
|
targetName: 'main',
|
||||||
|
action: 'console_error',
|
||||||
|
data: args
|
||||||
|
});
|
||||||
|
throw 'pdf.js execution error';
|
||||||
|
},
|
||||||
|
|
||||||
|
time: function time(name) {
|
||||||
|
consoleTimer[name] = Date.now();
|
||||||
|
},
|
||||||
|
|
||||||
|
timeEnd: function timeEnd(name) {
|
||||||
|
var time = consoleTimer[name];
|
||||||
|
if (!time) {
|
||||||
|
error('Unknown timer name ' + name);
|
||||||
|
}
|
||||||
|
this.log('Timer:', name, Date.now() - time);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
globalScope.console = workerConsole;
|
globalScope.console = workerConsole;
|
||||||
}
|
}
|
||||||
|
//#endif
|
||||||
|
|
||||||
var handler = new MessageHandler('worker', 'main', self);
|
var handler = new MessageHandler('worker', 'main', self);
|
||||||
WorkerMessageHandler.setup(handler, self);
|
WorkerMessageHandler.setup(handler, self);
|
||||||
|
handler.send('ready', null);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Worker thread (and not node.js)?
|
||||||
|
if (typeof window === 'undefined' &&
|
||||||
|
!(typeof module !== 'undefined' && module.require)) {
|
||||||
|
initializeWorker();
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.WorkerTask = WorkerTask;
|
exports.WorkerTask = WorkerTask;
|
||||||
|
@ -414,7 +414,7 @@ PDFJS.getDocument = function getDocument(src,
|
|||||||
var transport = new WorkerTransport(messageHandler, task, rangeTransport);
|
var transport = new WorkerTransport(messageHandler, task, rangeTransport);
|
||||||
task._transport = transport;
|
task._transport = transport;
|
||||||
});
|
});
|
||||||
}, task._capability.reject);
|
}).catch(task._capability.reject);
|
||||||
|
|
||||||
return task;
|
return task;
|
||||||
};
|
};
|
||||||
@ -1186,14 +1186,14 @@ var PDFWorker = (function PDFWorkerClosure() {
|
|||||||
// pdf.worker.js file is needed.
|
// pdf.worker.js file is needed.
|
||||||
//#if !PRODUCTION
|
//#if !PRODUCTION
|
||||||
if (typeof amdRequire === 'function') {
|
if (typeof amdRequire === 'function') {
|
||||||
amdRequire(['pdfjs/core/worker'], function () {
|
amdRequire(['pdfjs/core/network', 'pdfjs/core/worker'], function () {
|
||||||
PDFJS.fakeWorkerFilesLoadedCapability.resolve();
|
PDFJS.fakeWorkerFilesLoadedCapability.resolve();
|
||||||
});
|
});
|
||||||
} else if (typeof require === 'function') {
|
} else if (typeof require === 'function') {
|
||||||
require('../core/worker.js');
|
require('../core/worker.js');
|
||||||
PDFJS.fakeWorkerFilesLoadedCapability.resolve();
|
PDFJS.fakeWorkerFilesLoadedCapability.resolve();
|
||||||
} else {
|
} else {
|
||||||
Util.loadScript(PDFJS.workerSrc);
|
throw new Error('AMD or CommonJS must be used to load fake worker.');
|
||||||
}
|
}
|
||||||
//#endif
|
//#endif
|
||||||
//#if PRODUCTION && SINGLE_FILE
|
//#if PRODUCTION && SINGLE_FILE
|
||||||
@ -1253,8 +1253,16 @@ var PDFWorker = (function PDFWorkerClosure() {
|
|||||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=683280
|
// https://bugzilla.mozilla.org/show_bug.cgi?id=683280
|
||||||
var worker = new Worker(workerSrc);
|
var worker = new Worker(workerSrc);
|
||||||
var messageHandler = new MessageHandler('main', 'worker', worker);
|
var messageHandler = new MessageHandler('main', 'worker', worker);
|
||||||
|
//#if !PRODUCTION
|
||||||
|
// Don't allow worker to be destroyed by Chrome, see:
|
||||||
|
// https://code.google.com/p/chromium/issues/detail?id=572225
|
||||||
|
var jsWorkerId = '_workerKungfuGrip_' + Math.random();
|
||||||
|
window[jsWorkerId] = worker;
|
||||||
|
//#endif
|
||||||
messageHandler.on('test', function PDFWorker_test(data) {
|
messageHandler.on('test', function PDFWorker_test(data) {
|
||||||
|
//#if !PRODUCTION
|
||||||
|
delete window[jsWorkerId];
|
||||||
|
//#endif
|
||||||
if (this.destroyed) {
|
if (this.destroyed) {
|
||||||
this._readyCapability.reject(new Error('Worker was destroyed'));
|
this._readyCapability.reject(new Error('Worker was destroyed'));
|
||||||
messageHandler.destroy();
|
messageHandler.destroy();
|
||||||
@ -1284,16 +1292,40 @@ var PDFWorker = (function PDFWorkerClosure() {
|
|||||||
console.error.apply(console, data);
|
console.error.apply(console, data);
|
||||||
});
|
});
|
||||||
|
|
||||||
var testObj = new Uint8Array([PDFJS.postMessageTransfers ? 255 : 0]);
|
messageHandler.on('ready', function (data) {
|
||||||
// Some versions of Opera throw a DATA_CLONE_ERR on serializing the
|
if (this.destroyed) {
|
||||||
// typed array. Also, checking if we can use transfers.
|
this._readyCapability.reject(new Error('Worker was destroyed'));
|
||||||
try {
|
messageHandler.destroy();
|
||||||
messageHandler.send('test', testObj, [testObj.buffer]);
|
worker.terminate();
|
||||||
} catch (ex) {
|
return; // worker was destroyed
|
||||||
info('Cannot use postMessage transfers');
|
}
|
||||||
testObj[0] = 0;
|
try {
|
||||||
messageHandler.send('test', testObj);
|
sendTest();
|
||||||
}
|
} catch (e) {
|
||||||
|
// We need fallback to a faked worker.
|
||||||
|
this._setupFakeWorker();
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
|
|
||||||
|
var sendTest = function () {
|
||||||
|
var testObj = new Uint8Array(
|
||||||
|
[PDFJS.postMessageTransfers ? 255 : 0]);
|
||||||
|
// Some versions of Opera throw a DATA_CLONE_ERR on serializing the
|
||||||
|
// typed array. Also, checking if we can use transfers.
|
||||||
|
try {
|
||||||
|
messageHandler.send('test', testObj, [testObj.buffer]);
|
||||||
|
} catch (ex) {
|
||||||
|
info('Cannot use postMessage transfers');
|
||||||
|
testObj[0] = 0;
|
||||||
|
messageHandler.send('test', testObj);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// It might take time for worker to initialize (especially when AMD
|
||||||
|
// loader is used). We will try to send test immediately, and then
|
||||||
|
// when 'ready' message will arrive. The worker shall process only
|
||||||
|
// first received 'test'.
|
||||||
|
sendTest();
|
||||||
return;
|
return;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
info('The worker has been disabled.');
|
info('The worker has been disabled.');
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
//#if (GENERIC || SINGLE_FILE)
|
||||||
(function (root, factory) {
|
(function (root, factory) {
|
||||||
if (typeof define === 'function' && define.amd) {
|
if (typeof define === 'function' && define.amd) {
|
||||||
define('pdfjs/display/svg', ['exports', 'pdfjs/shared/util'], factory);
|
define('pdfjs/display/svg', ['exports', 'pdfjs/shared/util'], factory);
|
||||||
@ -25,7 +26,6 @@
|
|||||||
factory((root.pdfjsDisplaySVG = {}), root.pdfjsSharedUtil);
|
factory((root.pdfjsDisplaySVG = {}), root.pdfjsSharedUtil);
|
||||||
}
|
}
|
||||||
}(this, function (exports, sharedUtil) {
|
}(this, function (exports, sharedUtil) {
|
||||||
//#if (GENERIC || SINGLE_FILE)
|
|
||||||
|
|
||||||
var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
|
var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
|
||||||
var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
|
var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
|
||||||
@ -1209,5 +1209,5 @@ var SVGGraphics = (function SVGGraphicsClosure() {
|
|||||||
PDFJS.SVGGraphics = SVGGraphics;
|
PDFJS.SVGGraphics = SVGGraphics;
|
||||||
|
|
||||||
exports.SVGGraphics = SVGGraphics;
|
exports.SVGGraphics = SVGGraphics;
|
||||||
//#endif
|
|
||||||
}));
|
}));
|
||||||
|
//#endif
|
||||||
|
@ -12,22 +12,26 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
/* globals PDFJS */
|
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
(function (root, factory) {
|
(function (root, factory) {
|
||||||
if (typeof define === 'function' && define.amd) {
|
if (typeof define === 'function' && define.amd) {
|
||||||
define('pdfjs/display/text_layer', ['exports', 'pdfjs/shared/util'],
|
define('pdfjs/display/text_layer', ['exports', 'pdfjs/shared/util',
|
||||||
factory);
|
'pdfjs/display/dom_utils', 'pdfjs/shared/global'], factory);
|
||||||
} else if (typeof exports !== 'undefined') {
|
} else if (typeof exports !== 'undefined') {
|
||||||
factory(exports, require('../shared/util.js'));
|
factory(exports, require('../shared/util.js'), require('./dom_utils.js'),
|
||||||
|
require('../shared/global.js'));
|
||||||
} else {
|
} else {
|
||||||
factory((root.pdfjsDisplayTextLayer = {}), root.pdfjsSharedUtil);
|
factory((root.pdfjsDisplayTextLayer = {}), root.pdfjsSharedUtil,
|
||||||
|
root.pdfjsDisplayDOMUtils, root.pdfjsSharedGlobal);
|
||||||
}
|
}
|
||||||
}(this, function (exports, sharedUtil) {
|
}(this, function (exports, sharedUtil, displayDOMUtils, sharedGlobal) {
|
||||||
|
|
||||||
|
var Util = sharedUtil.Util;
|
||||||
var createPromiseCapability = sharedUtil.createPromiseCapability;
|
var createPromiseCapability = sharedUtil.createPromiseCapability;
|
||||||
|
var CustomStyle = displayDOMUtils.CustomStyle;
|
||||||
|
var PDFJS = sharedGlobal.PDFJS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Text layer render parameters.
|
* Text layer render parameters.
|
||||||
@ -61,7 +65,7 @@ var renderTextLayer = (function renderTextLayerClosure() {
|
|||||||
textDiv.dataset.isWhitespace = true;
|
textDiv.dataset.isWhitespace = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var tx = PDFJS.Util.transform(viewport.transform, geom.transform);
|
var tx = Util.transform(viewport.transform, geom.transform);
|
||||||
var angle = Math.atan2(tx[1], tx[0]);
|
var angle = Math.atan2(tx[1], tx[0]);
|
||||||
if (style.vertical) {
|
if (style.vertical) {
|
||||||
angle += Math.PI / 2;
|
angle += Math.PI / 2;
|
||||||
@ -167,7 +171,7 @@ var renderTextLayer = (function renderTextLayerClosure() {
|
|||||||
transform = 'rotate(' + rotation + 'deg) ' + transform;
|
transform = 'rotate(' + rotation + 'deg) ' + transform;
|
||||||
}
|
}
|
||||||
if (transform) {
|
if (transform) {
|
||||||
PDFJS.CustomStyle.setProp('transform' , textDiv, transform);
|
CustomStyle.setProp('transform' , textDiv, transform);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,35 +0,0 @@
|
|||||||
/* Copyright 2015 Mozilla Foundation
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
NOTE: This file is created as a helper to expose all loaded internal exported
|
|
||||||
members to global scope.
|
|
||||||
*/
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
(function (root) {
|
|
||||||
for (var i in root) {
|
|
||||||
if (/^pdfjs(Shared|Core|Display)/.test(i)) {
|
|
||||||
var obj = root[i];
|
|
||||||
for (var j in obj) {
|
|
||||||
if (Object.getOwnPropertyDescriptor(root, j)) {
|
|
||||||
continue; // ignoring if already set
|
|
||||||
}
|
|
||||||
root[j] = obj[j];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})(window);
|
|
@ -12,70 +12,13 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
/* globals PDFJS, Util */
|
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
// List of shared files to include;
|
importScripts('../node_modules/requirejs/require.js');
|
||||||
var sharedFiles = [
|
|
||||||
'shared/global.js',
|
|
||||||
'shared/util.js'
|
|
||||||
];
|
|
||||||
|
|
||||||
// List of other files to include;
|
require.config({paths: {'pdfjs': '.'}});
|
||||||
var otherFiles = [
|
require(['pdfjs/core/network', 'pdfjs/core/worker'],
|
||||||
'core/network.js',
|
function (network, worker) {
|
||||||
'core/arithmetic_decoder.js',
|
// Worker is loaded at this point.
|
||||||
'core/charsets.js',
|
});
|
||||||
'core/glyphlist.js',
|
|
||||||
'core/jpg.js',
|
|
||||||
'core/metrics.js',
|
|
||||||
'core/bidi.js',
|
|
||||||
'core/chunked_stream.js',
|
|
||||||
'core/jbig2.js',
|
|
||||||
'core/jpx.js',
|
|
||||||
'core/murmurhash3.js',
|
|
||||||
'core/primitives.js',
|
|
||||||
'core/stream.js',
|
|
||||||
'core/crypto.js',
|
|
||||||
'core/font_renderer.js',
|
|
||||||
'core/parser.js',
|
|
||||||
'core/cmap.js',
|
|
||||||
'core/obj.js',
|
|
||||||
'core/ps_parser.js',
|
|
||||||
'core/fonts.js',
|
|
||||||
'core/function.js',
|
|
||||||
'core/colorspace.js',
|
|
||||||
'core/image.js',
|
|
||||||
'core/pattern.js',
|
|
||||||
'core/evaluator.js',
|
|
||||||
'core/annotation.js',
|
|
||||||
'core/document.js',
|
|
||||||
'core/pdf_manager.js',
|
|
||||||
'core/worker.js'
|
|
||||||
];
|
|
||||||
|
|
||||||
function loadInOrder(index, path, files) {
|
|
||||||
if (index >= files.length) {
|
|
||||||
PDFJS.fakeWorkerFilesLoadedCapability.resolve();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
PDFJS.Util.loadScript(path + files[index],
|
|
||||||
loadInOrder.bind(null, ++index, path, files));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load all the files.
|
|
||||||
if (typeof PDFJS === 'undefined' || !PDFJS.fakeWorkerFilesLoadedCapability) {
|
|
||||||
var files = sharedFiles.concat(otherFiles);
|
|
||||||
for (var i = 0; i < files.length; i++) {
|
|
||||||
importScripts(files[i]);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
var src = PDFJS.workerSrc;
|
|
||||||
var path = src.substr(0, src.indexOf('worker_loader.js'));
|
|
||||||
// If Util is available, we assume that shared files are already loaded. Can
|
|
||||||
// happen that they are not if PDF.js is bundled inside a special namespace.
|
|
||||||
var skipShared = typeof Util !== 'undefined';
|
|
||||||
var files = skipShared ? otherFiles : sharedFiles.concat(otherFiles);
|
|
||||||
loadInOrder(0, path, files);
|
|
||||||
}
|
|
||||||
|
@ -6,55 +6,12 @@
|
|||||||
<link rel="shortcut icon" type="image/png" href="../../external/jasmine/jasmine_favicon.png">
|
<link rel="shortcut icon" type="image/png" href="../../external/jasmine/jasmine_favicon.png">
|
||||||
<link rel="stylesheet" type="text/css" href="../../external/jasmine/jasmine.css">
|
<link rel="stylesheet" type="text/css" href="../../external/jasmine/jasmine.css">
|
||||||
|
|
||||||
|
<script src="../../node_modules/requirejs/require.js"></script>
|
||||||
<script src="../../external/jasmine/jasmine.js"></script>
|
<script src="../../external/jasmine/jasmine.js"></script>
|
||||||
<script src="../../external/jasmine/jasmine-html.js"></script>
|
<script src="../../external/jasmine/jasmine-html.js"></script>
|
||||||
<script src="../unit/testreporter.js"></script>
|
<script src="../unit/testreporter.js"></script>
|
||||||
<script src="fontutils.js"></script>
|
<script src="fontutils.js"></script>
|
||||||
|
|
||||||
<!-- include source files here... -->
|
|
||||||
<script src="../../src/core/network.js"></script>
|
|
||||||
<script src="../../src/core/arithmetic_decoder.js"></script>
|
|
||||||
<script src="../../src/core/charsets.js"></script>
|
|
||||||
<script src="../../src/core/glyphlist.js"></script>
|
|
||||||
<script src="../../src/core/jpg.js"></script>
|
|
||||||
<script src="../../src/core/metrics.js"></script>
|
|
||||||
<script src="../../src/shared/global.js"></script>
|
|
||||||
<script src="../../src/core/bidi.js"></script>
|
|
||||||
<script src="../../src/display/dom_utils.js"></script>
|
|
||||||
<script src="../../src/shared/util.js"></script>
|
|
||||||
<script src="../../src/core/chunked_stream.js"></script>
|
|
||||||
<script src="../../src/core/jbig2.js"></script>
|
|
||||||
<script src="../../src/core/jpx.js"></script>
|
|
||||||
<script src="../../src/core/murmurhash3.js"></script>
|
|
||||||
<script src="../../src/core/primitives.js"></script>
|
|
||||||
<script src="../../src/display/annotation_layer.js"></script>
|
|
||||||
<script src="../../src/display/font_loader.js"></script>
|
|
||||||
<script src="../../src/display/metadata.js"></script>
|
|
||||||
<script src="../../src/display/text_layer.js"></script>
|
|
||||||
<script src="../../src/display/webgl.js"></script>
|
|
||||||
<script src="../../src/core/stream.js"></script>
|
|
||||||
<script src="../../src/display/pattern_helper.js"></script>
|
|
||||||
<script src="../../src/core/crypto.js"></script>
|
|
||||||
<script src="../../src/core/font_renderer.js"></script>
|
|
||||||
<script src="../../src/core/parser.js"></script>
|
|
||||||
<script src="../../src/display/canvas.js"></script>
|
|
||||||
<script src="../../src/core/cmap.js"></script>
|
|
||||||
<script src="../../src/core/obj.js"></script>
|
|
||||||
<script src="../../src/core/ps_parser.js"></script>
|
|
||||||
<script src="../../src/display/api.js"></script>
|
|
||||||
<script src="../../src/core/fonts.js"></script>
|
|
||||||
<script src="../../src/core/function.js"></script>
|
|
||||||
<script src="../../src/core/colorspace.js"></script>
|
|
||||||
<script src="../../src/core/image.js"></script>
|
|
||||||
<script src="../../src/core/pattern.js"></script>
|
|
||||||
<script src="../../src/core/evaluator.js"></script>
|
|
||||||
<script src="../../src/core/annotation.js"></script>
|
|
||||||
<script src="../../src/core/document.js"></script>
|
|
||||||
<script src="../../src/core/pdf_manager.js"></script>
|
|
||||||
<script src="../../src/core/worker.js"></script>
|
|
||||||
<script src="../../src/expose_to_global.js"></script>
|
|
||||||
<script>PDFJS.workerSrc = '../../src/worker_loader.js';</script>
|
|
||||||
|
|
||||||
<!-- include spec files here... -->
|
<!-- include spec files here... -->
|
||||||
<script src="font_core_spec.js"></script>
|
<script src="font_core_spec.js"></script>
|
||||||
<script src="font_os2_spec.js"></script>
|
<script src="font_os2_spec.js"></script>
|
||||||
@ -64,6 +21,20 @@
|
|||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
function initializePDFJS(callback) {
|
||||||
|
require.config({paths: {'pdfjs': '../../src'}});
|
||||||
|
require(['pdfjs/core/fonts', 'pdfjs/core/stream', 'pdfjs/core/primitives',
|
||||||
|
'pdfjs/core/cmap'], function (fonts, stream, primitives, cmap) {
|
||||||
|
// Expose some of the PDFJS members to global scope for tests.
|
||||||
|
window.Font = fonts.Font;
|
||||||
|
window.Stream = stream.Stream;
|
||||||
|
window.Name = primitives.Name;
|
||||||
|
window.CMapFactory = cmap.CMapFactory;
|
||||||
|
|
||||||
|
callback();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
(function pdfJsUnitTest() {
|
(function pdfJsUnitTest() {
|
||||||
function queryParams() {
|
function queryParams() {
|
||||||
var qs = window.location.search.substring(1);
|
var qs = window.location.search.substring(1);
|
||||||
@ -99,7 +70,7 @@
|
|||||||
if (currentWindowOnload) {
|
if (currentWindowOnload) {
|
||||||
currentWindowOnload();
|
currentWindowOnload();
|
||||||
}
|
}
|
||||||
execJasmine();
|
initializePDFJS(execJasmine);
|
||||||
};
|
};
|
||||||
|
|
||||||
function execJasmine() {
|
function execJasmine() {
|
||||||
|
@ -18,17 +18,7 @@ limitations under the License.
|
|||||||
<head>
|
<head>
|
||||||
<title>PDF.js test slave</title>
|
<title>PDF.js test slave</title>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<script src="../src/shared/global.js"></script>
|
<script src="../node_modules/requirejs/require.js"></script>
|
||||||
<script src="../src/display/dom_utils.js"></script>
|
|
||||||
<script src="../src/shared/util.js"></script>
|
|
||||||
<script src="../src/display/annotation_layer.js"></script>
|
|
||||||
<script src="../src/display/font_loader.js"></script>
|
|
||||||
<script src="../src/display/metadata.js"></script>
|
|
||||||
<script src="../src/display/text_layer.js"></script>
|
|
||||||
<script src="../src/display/webgl.js"></script>
|
|
||||||
<script src="../src/display/pattern_helper.js"></script>
|
|
||||||
<script src="../src/display/canvas.js"></script>
|
|
||||||
<script src="../src/display/api.js"></script>
|
|
||||||
<script src="driver.js"></script>
|
<script src="driver.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@ -41,12 +31,19 @@ limitations under the License.
|
|||||||
<div id="end"></div>
|
<div id="end"></div>
|
||||||
</body>
|
</body>
|
||||||
<script>
|
<script>
|
||||||
var driver = new Driver({
|
require.config({paths: {'pdfjs': '../src'}});
|
||||||
disableScrolling: document.getElementById('disableScrolling'),
|
require(['pdfjs/display/api', 'pdfjs/display/text_layer',
|
||||||
inflight: document.getElementById('inflight'),
|
'pdfjs/display/annotation_layer', 'pdfjs/shared/util'],
|
||||||
output: document.getElementById('output'),
|
function (api, textLayer, annotationLayer, pdfjsSharedUtil) {
|
||||||
end: document.getElementById('end')
|
window.pdfjsSharedUtil = pdfjsSharedUtil;
|
||||||
|
|
||||||
|
var driver = new Driver({
|
||||||
|
disableScrolling: document.getElementById('disableScrolling'),
|
||||||
|
inflight: document.getElementById('inflight'),
|
||||||
|
output: document.getElementById('output'),
|
||||||
|
end: document.getElementById('end')
|
||||||
|
});
|
||||||
|
driver.run();
|
||||||
});
|
});
|
||||||
driver.run();
|
|
||||||
</script>
|
</script>
|
||||||
</html>
|
</html>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/* globals expect, it, describe, CFFCompiler, CFFParser, CFFIndex, CFFStrings,
|
/* globals expect, it, describe, CFFCompiler, CFFParser, CFFIndex, CFFStrings,
|
||||||
SEAC_ANALYSIS_ENABLED:true, Type1Parser, StringStream */
|
SEAC_ANALYSIS_ENABLED, Type1Parser, StringStream,
|
||||||
|
_enableSeacAnalysis */
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@ -109,7 +110,7 @@ describe('font', function() {
|
|||||||
it('parses a CharString endchar with 4 args w/seac enabled', function() {
|
it('parses a CharString endchar with 4 args w/seac enabled', function() {
|
||||||
var seacAnalysisState = SEAC_ANALYSIS_ENABLED;
|
var seacAnalysisState = SEAC_ANALYSIS_ENABLED;
|
||||||
try {
|
try {
|
||||||
window.pdfjsCoreFonts._enableSeacAnalysis(true);
|
_enableSeacAnalysis(true);
|
||||||
var bytes = new Uint8Array([0, 1, // count
|
var bytes = new Uint8Array([0, 1, // count
|
||||||
1, // offsetSize
|
1, // offsetSize
|
||||||
0, // offset[0]
|
0, // offset[0]
|
||||||
@ -125,14 +126,14 @@ describe('font', function() {
|
|||||||
expect(result.seacs[0][2]).toEqual(65);
|
expect(result.seacs[0][2]).toEqual(65);
|
||||||
expect(result.seacs[0][3]).toEqual(194);
|
expect(result.seacs[0][3]).toEqual(194);
|
||||||
} finally {
|
} finally {
|
||||||
window.pdfjsCoreFonts._enableSeacAnalysis(seacAnalysisState);
|
_enableSeacAnalysis(seacAnalysisState);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('parses a CharString endchar with 4 args w/seac disabled', function() {
|
it('parses a CharString endchar with 4 args w/seac disabled', function() {
|
||||||
var seacAnalysisState = SEAC_ANALYSIS_ENABLED;
|
var seacAnalysisState = SEAC_ANALYSIS_ENABLED;
|
||||||
try {
|
try {
|
||||||
window.pdfjsCoreFonts._enableSeacAnalysis(false);
|
_enableSeacAnalysis(false);
|
||||||
var bytes = new Uint8Array([0, 1, // count
|
var bytes = new Uint8Array([0, 1, // count
|
||||||
1, // offsetSize
|
1, // offsetSize
|
||||||
0, // offset[0]
|
0, // offset[0]
|
||||||
@ -143,7 +144,7 @@ describe('font', function() {
|
|||||||
expect(result.charStrings.get(0).length).toEqual(9);
|
expect(result.charStrings.get(0).length).toEqual(9);
|
||||||
expect(result.seacs.length).toEqual(0);
|
expect(result.seacs.length).toEqual(0);
|
||||||
} finally {
|
} finally {
|
||||||
window.pdfjsCoreFonts._enableSeacAnalysis(seacAnalysisState);
|
_enableSeacAnalysis(seacAnalysisState);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -6,54 +6,21 @@
|
|||||||
<link rel="shortcut icon" type="image/png" href="../../external/jasmine/jasmine_favicon.png">
|
<link rel="shortcut icon" type="image/png" href="../../external/jasmine/jasmine_favicon.png">
|
||||||
<link rel="stylesheet" type="text/css" href="../../external/jasmine/jasmine.css">
|
<link rel="stylesheet" type="text/css" href="../../external/jasmine/jasmine.css">
|
||||||
|
|
||||||
|
<script src="../../node_modules/requirejs/require.js"></script>
|
||||||
<script src="../../external/jasmine/jasmine.js"></script>
|
<script src="../../external/jasmine/jasmine.js"></script>
|
||||||
<script src="../../external/jasmine/jasmine-html.js"></script>
|
<script src="../../external/jasmine/jasmine-html.js"></script>
|
||||||
<script src="testreporter.js"></script>
|
<script src="testreporter.js"></script>
|
||||||
|
|
||||||
<!-- include source files here... -->
|
|
||||||
<script src="../../src/core/network.js"></script>
|
|
||||||
<script src="../../src/core/arithmetic_decoder.js"></script>
|
|
||||||
<script src="../../src/core/charsets.js"></script>
|
|
||||||
<script src="../../src/core/glyphlist.js"></script>
|
|
||||||
<script src="../../src/core/jpg.js"></script>
|
|
||||||
<script src="../../src/core/metrics.js"></script>
|
|
||||||
<script src="../../src/shared/global.js"></script>
|
|
||||||
<script src="../../src/core/bidi.js"></script>
|
|
||||||
<script src="../../src/display/dom_utils.js"></script>
|
|
||||||
<script src="../../src/shared/util.js"></script>
|
|
||||||
<script src="../../src/core/chunked_stream.js"></script>
|
|
||||||
<script src="../../src/core/jbig2.js"></script>
|
|
||||||
<script src="../../src/core/jpx.js"></script>
|
|
||||||
<script src="../../src/core/murmurhash3.js"></script>
|
|
||||||
<script src="../../src/core/primitives.js"></script>
|
|
||||||
<script src="../../src/display/annotation_layer.js"></script>
|
|
||||||
<script src="../../src/display/font_loader.js"></script>
|
|
||||||
<script src="../../src/display/metadata.js"></script>
|
|
||||||
<script src="../../src/display/text_layer.js"></script>
|
|
||||||
<script src="../../src/display/webgl.js"></script>
|
|
||||||
<script src="../../src/core/stream.js"></script>
|
|
||||||
<script src="../../src/display/pattern_helper.js"></script>
|
|
||||||
<script src="../../src/core/crypto.js"></script>
|
|
||||||
<script src="../../src/core/font_renderer.js"></script>
|
|
||||||
<script src="../../src/core/parser.js"></script>
|
|
||||||
<script src="../../src/display/canvas.js"></script>
|
|
||||||
<script src="../../src/core/cmap.js"></script>
|
|
||||||
<script src="../../src/core/obj.js"></script>
|
|
||||||
<script src="../../src/core/ps_parser.js"></script>
|
|
||||||
<script src="../../src/display/api.js"></script>
|
|
||||||
<script src="../../src/core/fonts.js"></script>
|
|
||||||
<script src="../../src/core/function.js"></script>
|
|
||||||
<script src="../../src/core/colorspace.js"></script>
|
|
||||||
<script src="../../src/core/image.js"></script>
|
|
||||||
<script src="../../src/core/pattern.js"></script>
|
|
||||||
<script src="../../src/core/evaluator.js"></script>
|
|
||||||
<script src="../../src/core/annotation.js"></script>
|
|
||||||
<script src="../../src/core/document.js"></script>
|
|
||||||
<script src="../../src/core/pdf_manager.js"></script>
|
|
||||||
<script src="../../src/core/worker.js"></script>
|
|
||||||
<script src="../../src/expose_to_global.js"></script>
|
|
||||||
<script src="../../web/ui_utils.js"></script>
|
<script src="../../web/ui_utils.js"></script>
|
||||||
<script>PDFJS.workerSrc = '../../src/worker_loader.js';</script>
|
|
||||||
|
<script>
|
||||||
|
// Hacking describe() to wait for PDFJS to be loaded, since Jasmine executes
|
||||||
|
// it without waiting for libs to be loaded and fails to use PDFJS members.
|
||||||
|
var oldDescribe = window.describe, describeQueue = [];
|
||||||
|
window.describe = function () {
|
||||||
|
describeQueue.push(Array.prototype.slice.call(arguments, 0));
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
<!-- include spec files here... -->
|
<!-- include spec files here... -->
|
||||||
<script src="primitives_spec.js"></script>
|
<script src="primitives_spec.js"></script>
|
||||||
@ -69,9 +36,66 @@
|
|||||||
<script src="util_spec.js"></script>
|
<script src="util_spec.js"></script>
|
||||||
<script src="cmap_spec.js"></script>
|
<script src="cmap_spec.js"></script>
|
||||||
<script src="annotation_layer_spec.js"></script>
|
<script src="annotation_layer_spec.js"></script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
var pdfjsLibs;
|
||||||
|
|
||||||
|
function initializePDFJS(callback) {
|
||||||
|
require.config({paths: {'pdfjs': '../../src'}});
|
||||||
|
require(['pdfjs/shared/util', 'pdfjs/shared/global', 'pdfjs/core/primitives',
|
||||||
|
'pdfjs/core/annotation', 'pdfjs/core/crypto', 'pdfjs/core/stream',
|
||||||
|
'pdfjs/core/fonts', 'pdfjs/core/ps_parser', 'pdfjs/core/function',
|
||||||
|
'pdfjs/core/parser', 'pdfjs/core/evaluator', 'pdfjs/core/cmap',
|
||||||
|
'pdfjs/core/worker', 'pdfjs/display/api', 'pdfjs/display/metadata'],
|
||||||
|
function (sharedUtil, sharedGlobal, corePrimitives, coreAnnotation,
|
||||||
|
coreCrypto, coreStream, coreFonts, corePsParser, coreFunction,
|
||||||
|
coreParser, coreEvaluator, coreCMap, coreWorker, displayAPI,
|
||||||
|
displayMetadata) {
|
||||||
|
|
||||||
|
pdfjsLibs = {
|
||||||
|
sharedUtil: sharedUtil,
|
||||||
|
sharedGlobal: sharedGlobal,
|
||||||
|
corePrimitives: corePrimitives,
|
||||||
|
coreAnnotation: coreAnnotation,
|
||||||
|
coreCrypto: coreCrypto,
|
||||||
|
coreStream: coreStream,
|
||||||
|
coreFonts: coreFonts,
|
||||||
|
corePsParser: corePsParser,
|
||||||
|
coreFunction: coreFunction,
|
||||||
|
coreParser: coreParser,
|
||||||
|
coreEvaluator: coreEvaluator,
|
||||||
|
coreCMap: coreCMap,
|
||||||
|
coreWorker: coreWorker,
|
||||||
|
displayAPI: displayAPI,
|
||||||
|
displayMetadata: displayMetadata
|
||||||
|
};
|
||||||
|
|
||||||
|
// Expose all loaded internal exported members to global scope.
|
||||||
|
Object.keys(pdfjsLibs).forEach(function (libName) {
|
||||||
|
var lib = pdfjsLibs[libName];
|
||||||
|
Object.keys(lib).forEach(function (name) {
|
||||||
|
if (Object.getOwnPropertyDescriptor(window, name)) {
|
||||||
|
return; // ignoring if already set
|
||||||
|
}
|
||||||
|
window[name] = lib[name];
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Configure the worker.
|
||||||
|
PDFJS.workerSrc = '../../src/worker_loader.js';
|
||||||
|
|
||||||
|
// Release describe() calls.
|
||||||
|
window.describe = oldDescribe;
|
||||||
|
describeQueue.forEach(function (args) {
|
||||||
|
oldDescribe.apply(window, args);
|
||||||
|
});
|
||||||
|
|
||||||
|
callback();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
(function pdfJsUnitTest() {
|
(function pdfJsUnitTest() {
|
||||||
function queryParams() {
|
function queryParams() {
|
||||||
var qs = window.location.search.substring(1);
|
var qs = window.location.search.substring(1);
|
||||||
@ -107,7 +131,7 @@
|
|||||||
if (currentWindowOnload) {
|
if (currentWindowOnload) {
|
||||||
currentWindowOnload();
|
currentWindowOnload();
|
||||||
}
|
}
|
||||||
execJasmine();
|
initializePDFJS(execJasmine);
|
||||||
};
|
};
|
||||||
|
|
||||||
function execJasmine() {
|
function execJasmine() {
|
||||||
|
@ -36,8 +36,6 @@ var TEXT_LAYER_RENDER_DELAY = 200; // ms
|
|||||||
* @implements {IRenderableView}
|
* @implements {IRenderableView}
|
||||||
*/
|
*/
|
||||||
var PDFPageView = (function PDFPageViewClosure() {
|
var PDFPageView = (function PDFPageViewClosure() {
|
||||||
var CustomStyle = PDFJS.CustomStyle;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructs PDFPageView
|
* @constructs PDFPageView
|
||||||
* @param {PDFPageViewOptions} options
|
* @param {PDFPageViewOptions} options
|
||||||
@ -211,6 +209,8 @@ var PDFPageView = (function PDFPageViewClosure() {
|
|||||||
},
|
},
|
||||||
|
|
||||||
cssTransform: function PDFPageView_transform(canvas, redrawAnnotations) {
|
cssTransform: function PDFPageView_transform(canvas, redrawAnnotations) {
|
||||||
|
var CustomStyle = PDFJS.CustomStyle;
|
||||||
|
|
||||||
// Scale canvas, canvas wrapper, and page container.
|
// Scale canvas, canvas wrapper, and page container.
|
||||||
var width = this.viewport.width;
|
var width = this.viewport.width;
|
||||||
var height = this.viewport.height;
|
var height = this.viewport.height;
|
||||||
@ -518,6 +518,7 @@ var PDFPageView = (function PDFPageViewClosure() {
|
|||||||
},
|
},
|
||||||
|
|
||||||
beforePrint: function PDFPageView_beforePrint() {
|
beforePrint: function PDFPageView_beforePrint() {
|
||||||
|
var CustomStyle = PDFJS.CustomStyle;
|
||||||
var pdfPage = this.pdfPage;
|
var pdfPage = this.pdfPage;
|
||||||
|
|
||||||
var viewport = pdfPage.getViewport(1);
|
var viewport = pdfPage.getViewport(1);
|
||||||
|
@ -53,18 +53,7 @@ See https://github.com/adobe-type-tools/cmap-resources
|
|||||||
<!--#endif-->
|
<!--#endif-->
|
||||||
|
|
||||||
<!--#if !PRODUCTION-->
|
<!--#if !PRODUCTION-->
|
||||||
<script src="../src/shared/global.js"></script>
|
<script src="../node_modules/requirejs/require.js"></script>
|
||||||
<script src="../src/display/dom_utils.js"></script>
|
|
||||||
<script src="../src/shared/util.js"></script>
|
|
||||||
<script src="../src/display/annotation_layer.js"></script>
|
|
||||||
<script src="../src/display/font_loader.js"></script>
|
|
||||||
<script src="../src/display/metadata.js"></script>
|
|
||||||
<script src="../src/display/text_layer.js"></script>
|
|
||||||
<script src="../src/display/webgl.js"></script>
|
|
||||||
<script src="../src/display/pattern_helper.js"></script>
|
|
||||||
<script src="../src/display/canvas.js"></script>
|
|
||||||
<script src="../src/display/api.js"></script>
|
|
||||||
<script>PDFJS.workerSrc = '../src/worker_loader.js';</script>
|
|
||||||
<!--#endif-->
|
<!--#endif-->
|
||||||
|
|
||||||
<!--#if (GENERIC && !MINIFIED) -->
|
<!--#if (GENERIC && !MINIFIED) -->
|
||||||
|
@ -34,17 +34,20 @@ var SCALE_SELECT_PADDING = 22;
|
|||||||
var PAGE_NUMBER_LOADING_INDICATOR = 'visiblePageIsLoading';
|
var PAGE_NUMBER_LOADING_INDICATOR = 'visiblePageIsLoading';
|
||||||
var DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000;
|
var DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000;
|
||||||
|
|
||||||
PDFJS.imageResourcesPath = './images/';
|
function configure(PDFJS) {
|
||||||
|
PDFJS.imageResourcesPath = './images/';
|
||||||
//#if (FIREFOX || MOZCENTRAL || GENERIC || CHROME)
|
//#if (FIREFOX || MOZCENTRAL || GENERIC || CHROME)
|
||||||
//PDFJS.workerSrc = '../build/pdf.worker.js';
|
//PDFJS.workerSrc = '../build/pdf.worker.js';
|
||||||
//#endif
|
//#endif
|
||||||
//#if !PRODUCTION
|
//#if !PRODUCTION
|
||||||
PDFJS.cMapUrl = '../external/bcmaps/';
|
PDFJS.cMapUrl = '../external/bcmaps/';
|
||||||
PDFJS.cMapPacked = true;
|
PDFJS.cMapPacked = true;
|
||||||
|
PDFJS.workerSrc = '../src/worker_loader.js';
|
||||||
//#else
|
//#else
|
||||||
//PDFJS.cMapUrl = '../web/cmaps/';
|
//PDFJS.cMapUrl = '../web/cmaps/';
|
||||||
//PDFJS.cMapPacked = true;
|
//PDFJS.cMapPacked = true;
|
||||||
//#endif
|
//#endif
|
||||||
|
}
|
||||||
|
|
||||||
var mozL10n = document.mozL10n || document.webL10n;
|
var mozL10n = document.mozL10n || document.webL10n;
|
||||||
|
|
||||||
@ -1330,7 +1333,20 @@ window.PDFView = PDFViewerApplication; // obsolete name, using it as an alias
|
|||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
function webViewerLoad(evt) {
|
function webViewerLoad(evt) {
|
||||||
PDFViewerApplication.initialize().then(webViewerInitialized);
|
//#if !PRODUCTION
|
||||||
|
require.config({paths: {'pdfjs': '../src'}});
|
||||||
|
require(['pdfjs/display/api',
|
||||||
|
'pdfjs/display/annotation_layer',
|
||||||
|
'pdfjs/display/text_layer',
|
||||||
|
'pdfjs/display/metadata'],
|
||||||
|
function (api, annotationLayer, textLayer, metadata) {
|
||||||
|
configure(PDFJS);
|
||||||
|
PDFViewerApplication.initialize().then(webViewerInitialized);
|
||||||
|
});
|
||||||
|
//#else
|
||||||
|
// configure(PDFJS);
|
||||||
|
// PDFViewerApplication.initialize().then(webViewerInitialized);
|
||||||
|
//#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
function webViewerInitialized() {
|
function webViewerInitialized() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user