Use RequireJS in the viewer, examples and tests.
This commit is contained in:
parent
05b9d3730a
commit
85e95d34ed
@ -5,6 +5,9 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
// Specify the PDF with AcroForm here
|
||||
var pdfWithFormsPath = '../../test/pdfs/f1040.pdf';
|
||||
|
||||
var formFields = {};
|
||||
|
||||
function setupForm(div, content, viewport) {
|
||||
@ -135,8 +138,14 @@ function renderPage(div, pdf, pageNumber, callback) {
|
||||
});
|
||||
}
|
||||
|
||||
// Fetch the PDF document from the URL using promices
|
||||
PDFJS.getDocument(pdfWithFormsPath).then(function getPdfForm(pdf) {
|
||||
// In production, the bundled pdf.js shall be used instead of RequireJS.
|
||||
require.config({paths: {'pdfjs': '../../src'}});
|
||||
require(['pdfjs/display/api'], function (api) {
|
||||
// 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(pdfWithFormsPath).then(function getPdfForm(pdf) {
|
||||
// Rendering all pages starting from first
|
||||
var viewer = document.getElementById('viewer');
|
||||
var pageNumber = 1;
|
||||
@ -148,3 +157,4 @@ PDFJS.getDocument(pdfWithFormsPath).then(function getPdfForm(pdf) {
|
||||
renderPage(viewer, pdf, pageNumber++, pageRenderingComplete);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -2,27 +2,7 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<!-- In production, only one script (pdf.js) is necessary -->
|
||||
<!-- 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>
|
||||
<script src="../../node_modules/requirejs/require.js"></script>
|
||||
|
||||
<style>
|
||||
.pdfpage { position:relative; top: 0; left: 0; border: solid 1px black; margin: 10px; }
|
||||
|
@ -1,30 +1,25 @@
|
||||
|
||||
//
|
||||
// See README for overview
|
||||
//
|
||||
|
||||
'use strict';
|
||||
|
||||
//
|
||||
// Fetch the PDF document from the URL using promises
|
||||
//
|
||||
PDFJS.getDocument('helloworld.pdf').then(function(pdf) {
|
||||
// Using promise to fetch the page
|
||||
// In production, the bundled pdf.js shall be used instead of RequireJS.
|
||||
require.config({paths: {'pdfjs': '../../src'}});
|
||||
require(['pdfjs/display/api'], function (api) {
|
||||
// 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('helloworld.pdf').then(function (pdf) {
|
||||
// Fetch the page.
|
||||
pdf.getPage(1).then(function (page) {
|
||||
var scale = 1.5;
|
||||
var viewport = page.getViewport(scale);
|
||||
|
||||
//
|
||||
// Prepare canvas using PDF page dimensions
|
||||
//
|
||||
// Prepare canvas using PDF page dimensions.
|
||||
var canvas = document.getElementById('the-canvas');
|
||||
var context = canvas.getContext('2d');
|
||||
canvas.height = viewport.height;
|
||||
canvas.width = viewport.width;
|
||||
|
||||
//
|
||||
// Render PDF page into canvas context
|
||||
//
|
||||
// Render PDF page into canvas context.
|
||||
var renderContext = {
|
||||
canvasContext: context,
|
||||
viewport: viewport
|
||||
@ -32,3 +27,4 @@ PDFJS.getDocument('helloworld.pdf').then(function(pdf) {
|
||||
page.render(renderContext);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -2,26 +2,7 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<!-- In production, only one script (pdf.js) is necessary -->
|
||||
<!-- 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="../../node_modules/requirejs/require.js"></script>
|
||||
<script src="hello.js"></script>
|
||||
</head>
|
||||
|
||||
|
@ -2,24 +2,7 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<!-- In production, only one script (pdf.js) is necessary -->
|
||||
<!-- 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="../../node_modules/requirejs/require.js"></script>
|
||||
<script src="viewer.js"></script>
|
||||
<style>
|
||||
body {
|
||||
|
@ -1,8 +1,3 @@
|
||||
|
||||
//
|
||||
// See README for overview
|
||||
//
|
||||
|
||||
'use strict';
|
||||
|
||||
// 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 scale = +queryParams.scale || 1.5;
|
||||
|
||||
//
|
||||
// Fetch the PDF document from the URL using promises
|
||||
//
|
||||
PDFJS.getDocument(url).then(function(pdf) {
|
||||
function renderDocument(pdf) {
|
||||
var numPages = pdf.numPages;
|
||||
// Using promise to fetch the page
|
||||
|
||||
@ -53,4 +45,14 @@ PDFJS.getDocument(url).then(function(pdf) {
|
||||
});
|
||||
}.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);
|
||||
});
|
||||
|
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>');
|
||||
});
|
@ -4,11 +4,12 @@
|
||||
"devDependencies": {
|
||||
"jsdoc": "^3.3.0-alpha9",
|
||||
"jshint": "~2.8.0",
|
||||
"wintersmith": "^2.0.0",
|
||||
"node-ensure": "^0.0.0",
|
||||
"requirejs": "^2.1.22",
|
||||
"rimraf": "^2.4.1",
|
||||
"shelljs": "~0.4.0",
|
||||
"typogr": "~0.6.5",
|
||||
"wintersmith": "^2.0.0",
|
||||
"yargs": "^3.14.0"
|
||||
},
|
||||
"scripts": {
|
||||
|
@ -12,22 +12,26 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/* globals PDFJS */
|
||||
|
||||
'use strict';
|
||||
|
||||
(function (root, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define('pdfjs/display/text_layer', ['exports', 'pdfjs/shared/util'],
|
||||
factory);
|
||||
define('pdfjs/display/text_layer', ['exports', 'pdfjs/shared/util',
|
||||
'pdfjs/display/dom_utils', 'pdfjs/shared/global'], factory);
|
||||
} 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 {
|
||||
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 CustomStyle = displayDOMUtils.CustomStyle;
|
||||
var PDFJS = sharedGlobal.PDFJS;
|
||||
|
||||
/**
|
||||
* Text layer render parameters.
|
||||
@ -61,7 +65,7 @@ var renderTextLayer = (function renderTextLayerClosure() {
|
||||
textDiv.dataset.isWhitespace = true;
|
||||
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]);
|
||||
if (style.vertical) {
|
||||
angle += Math.PI / 2;
|
||||
@ -167,7 +171,7 @@ var renderTextLayer = (function renderTextLayerClosure() {
|
||||
transform = 'rotate(' + rotation + 'deg) ' + 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);
|
@ -6,55 +6,12 @@
|
||||
<link rel="shortcut icon" type="image/png" href="../../external/jasmine/jasmine_favicon.png">
|
||||
<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-html.js"></script>
|
||||
<script src="../unit/testreporter.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... -->
|
||||
<script src="font_core_spec.js"></script>
|
||||
<script src="font_os2_spec.js"></script>
|
||||
@ -64,6 +21,20 @@
|
||||
<script>
|
||||
'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 queryParams() {
|
||||
var qs = window.location.search.substring(1);
|
||||
@ -99,7 +70,7 @@
|
||||
if (currentWindowOnload) {
|
||||
currentWindowOnload();
|
||||
}
|
||||
execJasmine();
|
||||
initializePDFJS(execJasmine);
|
||||
};
|
||||
|
||||
function execJasmine() {
|
||||
|
@ -18,17 +18,7 @@ limitations under the License.
|
||||
<head>
|
||||
<title>PDF.js test slave</title>
|
||||
<meta charset="utf-8">
|
||||
<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 src="../node_modules/requirejs/require.js"></script>
|
||||
<script src="driver.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
@ -41,6 +31,12 @@ limitations under the License.
|
||||
<div id="end"></div>
|
||||
</body>
|
||||
<script>
|
||||
require.config({paths: {'pdfjs': '../src'}});
|
||||
require(['pdfjs/display/api', 'pdfjs/display/text_layer',
|
||||
'pdfjs/display/annotation_layer', 'pdfjs/shared/util'],
|
||||
function (api, textLayer, annotationLayer, pdfjsSharedUtil) {
|
||||
window.pdfjsSharedUtil = pdfjsSharedUtil;
|
||||
|
||||
var driver = new Driver({
|
||||
disableScrolling: document.getElementById('disableScrolling'),
|
||||
inflight: document.getElementById('inflight'),
|
||||
@ -48,5 +44,6 @@ limitations under the License.
|
||||
end: document.getElementById('end')
|
||||
});
|
||||
driver.run();
|
||||
});
|
||||
</script>
|
||||
</html>
|
||||
|
@ -1,5 +1,6 @@
|
||||
/* globals expect, it, describe, CFFCompiler, CFFParser, CFFIndex, CFFStrings,
|
||||
SEAC_ANALYSIS_ENABLED:true, Type1Parser, StringStream */
|
||||
SEAC_ANALYSIS_ENABLED, Type1Parser, StringStream,
|
||||
_enableSeacAnalysis */
|
||||
|
||||
'use strict';
|
||||
|
||||
@ -109,7 +110,7 @@ describe('font', function() {
|
||||
it('parses a CharString endchar with 4 args w/seac enabled', function() {
|
||||
var seacAnalysisState = SEAC_ANALYSIS_ENABLED;
|
||||
try {
|
||||
window.pdfjsCoreFonts._enableSeacAnalysis(true);
|
||||
_enableSeacAnalysis(true);
|
||||
var bytes = new Uint8Array([0, 1, // count
|
||||
1, // offsetSize
|
||||
0, // offset[0]
|
||||
@ -125,14 +126,14 @@ describe('font', function() {
|
||||
expect(result.seacs[0][2]).toEqual(65);
|
||||
expect(result.seacs[0][3]).toEqual(194);
|
||||
} finally {
|
||||
window.pdfjsCoreFonts._enableSeacAnalysis(seacAnalysisState);
|
||||
_enableSeacAnalysis(seacAnalysisState);
|
||||
}
|
||||
});
|
||||
|
||||
it('parses a CharString endchar with 4 args w/seac disabled', function() {
|
||||
var seacAnalysisState = SEAC_ANALYSIS_ENABLED;
|
||||
try {
|
||||
window.pdfjsCoreFonts._enableSeacAnalysis(false);
|
||||
_enableSeacAnalysis(false);
|
||||
var bytes = new Uint8Array([0, 1, // count
|
||||
1, // offsetSize
|
||||
0, // offset[0]
|
||||
@ -143,7 +144,7 @@ describe('font', function() {
|
||||
expect(result.charStrings.get(0).length).toEqual(9);
|
||||
expect(result.seacs.length).toEqual(0);
|
||||
} 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="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-html.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>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... -->
|
||||
<script src="primitives_spec.js"></script>
|
||||
@ -69,9 +36,66 @@
|
||||
<script src="util_spec.js"></script>
|
||||
<script src="cmap_spec.js"></script>
|
||||
<script src="annotation_layer_spec.js"></script>
|
||||
|
||||
<script>
|
||||
'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 queryParams() {
|
||||
var qs = window.location.search.substring(1);
|
||||
@ -107,7 +131,7 @@
|
||||
if (currentWindowOnload) {
|
||||
currentWindowOnload();
|
||||
}
|
||||
execJasmine();
|
||||
initializePDFJS(execJasmine);
|
||||
};
|
||||
|
||||
function execJasmine() {
|
||||
|
@ -36,8 +36,6 @@ var TEXT_LAYER_RENDER_DELAY = 200; // ms
|
||||
* @implements {IRenderableView}
|
||||
*/
|
||||
var PDFPageView = (function PDFPageViewClosure() {
|
||||
var CustomStyle = PDFJS.CustomStyle;
|
||||
|
||||
/**
|
||||
* @constructs PDFPageView
|
||||
* @param {PDFPageViewOptions} options
|
||||
@ -211,6 +209,8 @@ var PDFPageView = (function PDFPageViewClosure() {
|
||||
},
|
||||
|
||||
cssTransform: function PDFPageView_transform(canvas, redrawAnnotations) {
|
||||
var CustomStyle = PDFJS.CustomStyle;
|
||||
|
||||
// Scale canvas, canvas wrapper, and page container.
|
||||
var width = this.viewport.width;
|
||||
var height = this.viewport.height;
|
||||
@ -518,6 +518,7 @@ var PDFPageView = (function PDFPageViewClosure() {
|
||||
},
|
||||
|
||||
beforePrint: function PDFPageView_beforePrint() {
|
||||
var CustomStyle = PDFJS.CustomStyle;
|
||||
var pdfPage = this.pdfPage;
|
||||
|
||||
var viewport = pdfPage.getViewport(1);
|
||||
|
@ -53,18 +53,7 @@ See https://github.com/adobe-type-tools/cmap-resources
|
||||
<!--#endif-->
|
||||
|
||||
<!--#if !PRODUCTION-->
|
||||
<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>PDFJS.workerSrc = '../src/worker_loader.js';</script>
|
||||
<script src="../node_modules/requirejs/require.js"></script>
|
||||
<!--#endif-->
|
||||
|
||||
<!--#if (GENERIC && !MINIFIED) -->
|
||||
|
@ -34,6 +34,7 @@ var SCALE_SELECT_PADDING = 22;
|
||||
var PAGE_NUMBER_LOADING_INDICATOR = 'visiblePageIsLoading';
|
||||
var DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000;
|
||||
|
||||
function configure(PDFJS) {
|
||||
PDFJS.imageResourcesPath = './images/';
|
||||
//#if (FIREFOX || MOZCENTRAL || GENERIC || CHROME)
|
||||
//PDFJS.workerSrc = '../build/pdf.worker.js';
|
||||
@ -41,10 +42,12 @@ PDFJS.imageResourcesPath = './images/';
|
||||
//#if !PRODUCTION
|
||||
PDFJS.cMapUrl = '../external/bcmaps/';
|
||||
PDFJS.cMapPacked = true;
|
||||
PDFJS.workerSrc = '../src/worker_loader.js';
|
||||
//#else
|
||||
//PDFJS.cMapUrl = '../web/cmaps/';
|
||||
//PDFJS.cMapPacked = true;
|
||||
//#endif
|
||||
}
|
||||
|
||||
var mozL10n = document.mozL10n || document.webL10n;
|
||||
|
||||
@ -1330,7 +1333,20 @@ window.PDFView = PDFViewerApplication; // obsolete name, using it as an alias
|
||||
//#endif
|
||||
|
||||
function webViewerLoad(evt) {
|
||||
//#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() {
|
||||
|
Loading…
Reference in New Issue
Block a user