Browse Source

PDF.js version 1.8.241 - See mozilla/pdf.js@c44fd3d6e21c708b3cd942fe99d822ca37a452a8

master v1.8.241
pdfjsbot 8 years ago
parent
commit
e5d78111b7
  1. 2
      bower.json
  2. 20
      build/pdf.combined.js
  3. 20
      build/pdf.js
  4. 6
      build/pdf.min.js
  5. 12
      build/pdf.worker.js
  6. 2
      build/pdf.worker.min.js
  7. 4
      lib/display/api.js
  8. 4
      lib/display/global.js
  9. 4
      lib/pdf.js
  10. 4
      lib/pdf.worker.js
  11. 8
      lib/shared/util.js
  12. 63
      lib/test/unit/ui_utils_spec.js
  13. 10
      lib/web/pdf_attachment_viewer.js
  14. 17
      lib/web/ui_utils.js
  15. 2
      package.json
  16. 17
      web/pdf_viewer.js

2
bower.json

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
{
"name": "pdfjs-dist",
"version": "1.8.237",
"version": "1.8.241",
"main": [
"build/pdf.js",
"build/pdf.worker.js"

20
build/pdf.combined.js

@ -963,12 +963,14 @@ var createBlob = function createBlob(data, contentType) { @@ -963,12 +963,14 @@ var createBlob = function createBlob(data, contentType) {
if (typeof Blob !== 'undefined') {
return new Blob([data], { type: contentType });
}
warn('The "Blob" constructor is not supported.');
throw new Error('The "Blob" constructor is not supported.');
};
var createObjectURL = function createObjectURLClosure() {
var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
return function createObjectURL(data, contentType, forceDataSchema) {
if (!forceDataSchema && typeof URL !== 'undefined' && URL.createObjectURL) {
return function createObjectURL(data, contentType) {
var forceDataSchema = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
if (!forceDataSchema) {
var blob = createBlob(data, contentType);
return URL.createObjectURL(blob);
}
@ -12720,8 +12722,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() { @@ -12720,8 +12722,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() {
}();
var version, build;
{
exports.version = version = '1.8.237';
exports.build = build = '29285781';
exports.version = version = '1.8.241';
exports.build = build = 'c44fd3d6';
}
exports.getDocument = getDocument;
exports.PDFDataRangeTransport = PDFDataRangeTransport;
@ -28014,8 +28016,8 @@ if (!_util.globalScope.PDFJS) { @@ -28014,8 +28016,8 @@ if (!_util.globalScope.PDFJS) {
}
var PDFJS = _util.globalScope.PDFJS;
{
PDFJS.version = '1.8.237';
PDFJS.build = '29285781';
PDFJS.version = '1.8.241';
PDFJS.build = 'c44fd3d6';
}
PDFJS.pdfBug = false;
if (PDFJS.verbosity !== undefined) {
@ -43532,8 +43534,8 @@ exports.TilingPattern = TilingPattern; @@ -43532,8 +43534,8 @@ exports.TilingPattern = TilingPattern;
"use strict";
var pdfjsVersion = '1.8.237';
var pdfjsBuild = '29285781';
var pdfjsVersion = '1.8.241';
var pdfjsBuild = 'c44fd3d6';
var pdfjsSharedUtil = __w_pdfjs_require__(0);
var pdfjsDisplayGlobal = __w_pdfjs_require__(26);
var pdfjsDisplayAPI = __w_pdfjs_require__(10);

20
build/pdf.js

@ -963,12 +963,14 @@ var createBlob = function createBlob(data, contentType) { @@ -963,12 +963,14 @@ var createBlob = function createBlob(data, contentType) {
if (typeof Blob !== 'undefined') {
return new Blob([data], { type: contentType });
}
warn('The "Blob" constructor is not supported.');
throw new Error('The "Blob" constructor is not supported.');
};
var createObjectURL = function createObjectURLClosure() {
var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
return function createObjectURL(data, contentType, forceDataSchema) {
if (!forceDataSchema && typeof URL !== 'undefined' && URL.createObjectURL) {
return function createObjectURL(data, contentType) {
var forceDataSchema = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
if (!forceDataSchema) {
var blob = createBlob(data, contentType);
return URL.createObjectURL(blob);
}
@ -3429,8 +3431,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() { @@ -3429,8 +3431,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() {
}();
var version, build;
{
exports.version = version = '1.8.237';
exports.build = build = '29285781';
exports.version = version = '1.8.241';
exports.build = build = 'c44fd3d6';
}
exports.getDocument = getDocument;
exports.PDFDataRangeTransport = PDFDataRangeTransport;
@ -5397,8 +5399,8 @@ if (!_util.globalScope.PDFJS) { @@ -5397,8 +5399,8 @@ if (!_util.globalScope.PDFJS) {
}
var PDFJS = _util.globalScope.PDFJS;
{
PDFJS.version = '1.8.237';
PDFJS.build = '29285781';
PDFJS.version = '1.8.241';
PDFJS.build = 'c44fd3d6';
}
PDFJS.pdfBug = false;
if (PDFJS.verbosity !== undefined) {
@ -7887,8 +7889,8 @@ exports.TilingPattern = TilingPattern; @@ -7887,8 +7889,8 @@ exports.TilingPattern = TilingPattern;
"use strict";
var pdfjsVersion = '1.8.237';
var pdfjsBuild = '29285781';
var pdfjsVersion = '1.8.241';
var pdfjsBuild = 'c44fd3d6';
var pdfjsSharedUtil = __w_pdfjs_require__(0);
var pdfjsDisplayGlobal = __w_pdfjs_require__(9);
var pdfjsDisplayAPI = __w_pdfjs_require__(3);

6
build/pdf.min.js vendored

File diff suppressed because one or more lines are too long

12
build/pdf.worker.js vendored

@ -963,12 +963,14 @@ var createBlob = function createBlob(data, contentType) { @@ -963,12 +963,14 @@ var createBlob = function createBlob(data, contentType) {
if (typeof Blob !== 'undefined') {
return new Blob([data], { type: contentType });
}
warn('The "Blob" constructor is not supported.');
throw new Error('The "Blob" constructor is not supported.');
};
var createObjectURL = function createObjectURLClosure() {
var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
return function createObjectURL(data, contentType, forceDataSchema) {
if (!forceDataSchema && typeof URL !== 'undefined' && URL.createObjectURL) {
return function createObjectURL(data, contentType) {
var forceDataSchema = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
if (!forceDataSchema) {
var blob = createBlob(data, contentType);
return URL.createObjectURL(blob);
}
@ -36954,8 +36956,8 @@ exports.Type1Parser = Type1Parser; @@ -36954,8 +36956,8 @@ exports.Type1Parser = Type1Parser;
"use strict";
var pdfjsVersion = '1.8.237';
var pdfjsBuild = '29285781';
var pdfjsVersion = '1.8.241';
var pdfjsBuild = 'c44fd3d6';
var pdfjsCoreWorker = __w_pdfjs_require__(8);
{
__w_pdfjs_require__(19);

2
build/pdf.worker.min.js vendored

File diff suppressed because one or more lines are too long

4
lib/display/api.js

@ -1362,8 +1362,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() { @@ -1362,8 +1362,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() {
}();
var version, build;
{
exports.version = version = '1.8.237';
exports.build = build = '29285781';
exports.version = version = '1.8.241';
exports.build = build = 'c44fd3d6';
}
exports.getDocument = getDocument;
exports.PDFDataRangeTransport = PDFDataRangeTransport;

4
lib/display/global.js

@ -39,8 +39,8 @@ if (!_util.globalScope.PDFJS) { @@ -39,8 +39,8 @@ if (!_util.globalScope.PDFJS) {
}
var PDFJS = _util.globalScope.PDFJS;
{
PDFJS.version = '1.8.237';
PDFJS.build = '29285781';
PDFJS.version = '1.8.241';
PDFJS.build = 'c44fd3d6';
}
PDFJS.pdfBug = false;
if (PDFJS.verbosity !== undefined) {

4
lib/pdf.js

@ -14,8 +14,8 @@ @@ -14,8 +14,8 @@
*/
'use strict';
var pdfjsVersion = '1.8.237';
var pdfjsBuild = '29285781';
var pdfjsVersion = '1.8.241';
var pdfjsBuild = 'c44fd3d6';
var pdfjsSharedUtil = require('./shared/util.js');
var pdfjsDisplayGlobal = require('./display/global.js');
var pdfjsDisplayAPI = require('./display/api.js');

4
lib/pdf.worker.js vendored

@ -14,8 +14,8 @@ @@ -14,8 +14,8 @@
*/
'use strict';
var pdfjsVersion = '1.8.237';
var pdfjsBuild = '29285781';
var pdfjsVersion = '1.8.241';
var pdfjsBuild = 'c44fd3d6';
var pdfjsCoreWorker = require('./core/worker.js');
{
require('./core/network.js');

8
lib/shared/util.js

@ -879,12 +879,14 @@ var createBlob = function createBlob(data, contentType) { @@ -879,12 +879,14 @@ var createBlob = function createBlob(data, contentType) {
if (typeof Blob !== 'undefined') {
return new Blob([data], { type: contentType });
}
warn('The "Blob" constructor is not supported.');
throw new Error('The "Blob" constructor is not supported.');
};
var createObjectURL = function createObjectURLClosure() {
var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
return function createObjectURL(data, contentType, forceDataSchema) {
if (!forceDataSchema && typeof URL !== 'undefined' && URL.createObjectURL) {
return function createObjectURL(data, contentType) {
var forceDataSchema = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
if (!forceDataSchema) {
var blob = createBlob(data, contentType);
return URL.createObjectURL(blob);
}

63
lib/test/unit/ui_utils_spec.js

@ -15,8 +15,11 @@ @@ -15,8 +15,11 @@
'use strict';
var webUiUtils = require('../../web/ui_utils.js');
var sharedUtil = require('../../shared/util.js');
var binarySearchFirstItem = webUiUtils.binarySearchFirstItem;
var getPDFFileNameFromURL = webUiUtils.getPDFFileNameFromURL;
var EventBus = webUiUtils.EventBus;
var createObjectURL = sharedUtil.createObjectURL;
describe('ui_utils', function () {
describe('binary search', function () {
function isTrue(boolean) {
@ -44,6 +47,66 @@ describe('ui_utils', function () { @@ -44,6 +47,66 @@ describe('ui_utils', function () {
expect(binarySearchFirstItem([4, 5, 6], isGreater3)).toEqual(0);
});
});
describe('getPDFFileNameFromURL', function () {
it('gets PDF filename', function () {
expect(getPDFFileNameFromURL('/pdfs/file1.pdf')).toEqual('file1.pdf');
expect(getPDFFileNameFromURL('http://www.example.com/pdfs/file2.pdf')).toEqual('file2.pdf');
});
it('gets fallback filename', function () {
expect(getPDFFileNameFromURL('/pdfs/file1.txt')).toEqual('document.pdf');
expect(getPDFFileNameFromURL('http://www.example.com/pdfs/file2.txt')).toEqual('document.pdf');
});
it('gets custom fallback filename', function () {
expect(getPDFFileNameFromURL('/pdfs/file1.txt', 'qwerty1.pdf')).toEqual('qwerty1.pdf');
expect(getPDFFileNameFromURL('http://www.example.com/pdfs/file2.txt', 'qwerty2.pdf')).toEqual('qwerty2.pdf');
expect(getPDFFileNameFromURL('/pdfs/file3.txt', '')).toEqual('');
});
it('gets PDF filename from URL containing leading/trailing whitespace', function () {
expect(getPDFFileNameFromURL(' /pdfs/file1.pdf ')).toEqual('file1.pdf');
expect(getPDFFileNameFromURL(' http://www.example.com/pdfs/file2.pdf ')).toEqual('file2.pdf');
});
it('gets PDF filename from query string', function () {
expect(getPDFFileNameFromURL('/pdfs/pdfs.html?name=file1.pdf')).toEqual('file1.pdf');
expect(getPDFFileNameFromURL('http://www.example.com/pdfs/pdf.html?file2.pdf')).toEqual('file2.pdf');
});
it('gets PDF filename from hash string', function () {
expect(getPDFFileNameFromURL('/pdfs/pdfs.html#name=file1.pdf')).toEqual('file1.pdf');
expect(getPDFFileNameFromURL('http://www.example.com/pdfs/pdf.html#file2.pdf')).toEqual('file2.pdf');
});
it('gets correct PDF filename when multiple ones are present', function () {
expect(getPDFFileNameFromURL('/pdfs/file1.pdf?name=file.pdf')).toEqual('file1.pdf');
expect(getPDFFileNameFromURL('http://www.example.com/pdfs/file2.pdf#file.pdf')).toEqual('file2.pdf');
});
it('gets PDF filename from URI-encoded data', function () {
var encodedUrl = encodeURIComponent('http://www.example.com/pdfs/file1.pdf');
expect(getPDFFileNameFromURL(encodedUrl)).toEqual('file1.pdf');
var encodedUrlWithQuery = encodeURIComponent('http://www.example.com/pdfs/file.txt?file2.pdf');
expect(getPDFFileNameFromURL(encodedUrlWithQuery)).toEqual('file2.pdf');
});
it('gets PDF filename from data mistaken for URI-encoded', function () {
expect(getPDFFileNameFromURL('/pdfs/%AA.pdf')).toEqual('%AA.pdf');
expect(getPDFFileNameFromURL('/pdfs/%2F.pdf')).toEqual('%2F.pdf');
});
it('gets PDF filename from (some) standard protocols', function () {
expect(getPDFFileNameFromURL('http://www.example.com/file1.pdf')).toEqual('file1.pdf');
expect(getPDFFileNameFromURL('https://www.example.com/file2.pdf')).toEqual('file2.pdf');
expect(getPDFFileNameFromURL('file:///path/to/files/file3.pdf')).toEqual('file3.pdf');
expect(getPDFFileNameFromURL('ftp://www.example.com/file4.pdf')).toEqual('file4.pdf');
});
it('gets PDF filename from query string appended to "blob:" URL', function () {
var typedArray = new Uint8Array([1, 2, 3, 4, 5]);
var blobUrl = createObjectURL(typedArray, 'application/pdf');
expect(blobUrl.indexOf('blob:') === 0).toEqual(true);
expect(getPDFFileNameFromURL(blobUrl + '?file.pdf')).toEqual('file.pdf');
});
it('gets fallback filename from query string appended to "data:" URL', function () {
var typedArray = new Uint8Array([1, 2, 3, 4, 5]);
var dataUrl = createObjectURL(typedArray, 'application/pdf', true);
expect(dataUrl.indexOf('data:') === 0).toEqual(true);
expect(getPDFFileNameFromURL(dataUrl + '?file1.pdf')).toEqual('document.pdf');
expect(getPDFFileNameFromURL(' ' + dataUrl + '?file2.pdf')).toEqual('document.pdf');
});
});
describe('EventBus', function () {
it('dispatch event', function () {
var eventBus = new EventBus();

10
lib/web/pdf_attachment_viewer.js

@ -45,11 +45,14 @@ var PDFAttachmentViewer = function PDFAttachmentViewerClosure() { @@ -45,11 +45,14 @@ var PDFAttachmentViewer = function PDFAttachmentViewerClosure() {
});
this._renderedCapability.resolve();
},
_bindPdfLink: function PDFAttachmentViewer_bindPdfLink(button, content, filename) {
_bindPdfLink: function _bindPdfLink(button, content, filename) {
if (_pdfjs.PDFJS.disableCreateObjectURL) {
throw new Error('bindPdfLink: ' + 'Unsupported "PDFJS.disableCreateObjectURL" value.');
}
var blobUrl;
button.onclick = function () {
if (!blobUrl) {
blobUrl = (0, _pdfjs.createObjectURL)(content, 'application/pdf', _pdfjs.PDFJS.disableCreateObjectURL);
blobUrl = (0, _pdfjs.createObjectURL)(content, 'application/pdf');
}
var viewerUrl;
viewerUrl = '?file=' + encodeURIComponent(blobUrl + '#' + filename);
@ -57,6 +60,7 @@ var PDFAttachmentViewer = function PDFAttachmentViewerClosure() { @@ -57,6 +60,7 @@ var PDFAttachmentViewer = function PDFAttachmentViewerClosure() {
return false;
};
},
_bindLink: function PDFAttachmentViewer_bindLink(button, content, filename) {
button.onclick = function downloadFile(e) {
this.downloadManager.downloadData(content, filename, '');
@ -87,7 +91,7 @@ var PDFAttachmentViewer = function PDFAttachmentViewerClosure() { @@ -87,7 +91,7 @@ var PDFAttachmentViewer = function PDFAttachmentViewerClosure() {
div.className = 'attachmentsItem';
var button = document.createElement('button');
button.textContent = filename;
if (/\.pdf$/i.test(filename)) {
if (/\.pdf$/i.test(filename) && !_pdfjs.PDFJS.disableCreateObjectURL) {
this._bindPdfLink(button, item.content, filename);
} else {
this._bindLink(button, item.content, filename);

17
lib/web/ui_utils.js

@ -243,9 +243,20 @@ function getVisibleElements(scrollEl, views, sortByVisibility) { @@ -243,9 +243,20 @@ function getVisibleElements(scrollEl, views, sortByVisibility) {
function noContextMenuHandler(e) {
e.preventDefault();
}
function getPDFFileNameFromURL(url, defaultFilename) {
if (typeof defaultFilename === 'undefined') {
defaultFilename = 'document.pdf';
function isDataSchema(url) {
var i = 0,
ii = url.length;
while (i < ii && url[i].trim() === '') {
i++;
}
return url.substr(i, 5).toLowerCase() === 'data:';
}
function getPDFFileNameFromURL(url) {
var defaultFilename = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'document.pdf';
if (isDataSchema(url)) {
console.warn('getPDFFileNameFromURL: ' + 'ignoring "data:" URL for performance reasons.');
return defaultFilename;
}
var reURI = /^(?:(?:[^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
var reFilename = /[^\/?#=]+\.pdf\b(?!.*\.pdf\b)/i;

2
package.json

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
{
"name": "pdfjs-dist",
"version": "1.8.237",
"version": "1.8.241",
"main": "build/pdf.js",
"description": "Generic build of Mozilla's PDF.js library.",
"keywords": [

17
web/pdf_viewer.js

@ -348,9 +348,20 @@ function getVisibleElements(scrollEl, views, sortByVisibility) { @@ -348,9 +348,20 @@ function getVisibleElements(scrollEl, views, sortByVisibility) {
function noContextMenuHandler(e) {
e.preventDefault();
}
function getPDFFileNameFromURL(url, defaultFilename) {
if (typeof defaultFilename === 'undefined') {
defaultFilename = 'document.pdf';
function isDataSchema(url) {
var i = 0,
ii = url.length;
while (i < ii && url[i].trim() === '') {
i++;
}
return url.substr(i, 5).toLowerCase() === 'data:';
}
function getPDFFileNameFromURL(url) {
var defaultFilename = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'document.pdf';
if (isDataSchema(url)) {
console.warn('getPDFFileNameFromURL: ' + 'ignoring "data:" URL for performance reasons.');
return defaultFilename;
}
var reURI = /^(?:(?:[^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
var reFilename = /[^\/?#=]+\.pdf\b(?!.*\.pdf\b)/i;

Loading…
Cancel
Save