Browse Source

PDF.js version 2.0.437 - See mozilla/pdf.js@0d391daccc2f4e4b9c91268e719bd10fe63a49ae

master v2.0.437
pdfjsbot 7 years ago
parent
commit
1cc7753357
  1. 2
      bower.json
  2. 39
      build/pdf.js
  3. 2
      build/pdf.js.map
  4. 2
      build/pdf.min.js
  5. 6
      build/pdf.worker.js
  6. 2
      build/pdf.worker.js.map
  7. 2
      build/pdf.worker.min.js
  8. 2
      lib/core/worker.js
  9. 35
      lib/display/api.js
  10. 4
      lib/pdf.js
  11. 4
      lib/pdf.worker.js
  12. 8
      lib/test/unit/api_spec.js
  13. 2
      lib/web/app.js
  14. 85
      lib/web/pdf_document_properties.js
  15. 4
      lib/web/pdf_viewer.component.js
  16. 2
      package.json
  17. 4
      web/pdf_viewer.js
  18. 2
      web/pdf_viewer.js.map

2
bower.json

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

39
build/pdf.js

@ -3135,8 +3135,8 @@ exports.GlobalWorkerOptions = GlobalWorkerOptions; @@ -3135,8 +3135,8 @@ exports.GlobalWorkerOptions = GlobalWorkerOptions;
"use strict";
var pdfjsVersion = '2.0.432';
var pdfjsBuild = '4136d41a';
var pdfjsVersion = '2.0.437';
var pdfjsBuild = '0d391dac';
var pdfjsSharedUtil = __w_pdfjs_require__(0);
var pdfjsDisplayAPI = __w_pdfjs_require__(117);
var pdfjsDisplayTextLayer = __w_pdfjs_require__(124);
@ -8567,7 +8567,7 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) { @@ -8567,7 +8567,7 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
}
return worker.messageHandler.sendWithPromise('GetDocRequest', {
docId: docId,
apiVersion: '2.0.432',
apiVersion: '2.0.437',
source: {
data: source.data,
url: source.url,
@ -8728,22 +8728,6 @@ var PDFDocumentProxy = function PDFDocumentProxyClosure() { @@ -8728,22 +8728,6 @@ var PDFDocumentProxy = function PDFDocumentProxyClosure() {
getMetadata: function PDFDocumentProxy_getMetadata() {
return this.transport.getMetadata();
},
getPageSizeInches: function getPageSizeInches(pageNumber) {
pageNumber = pageNumber || 1;
return this.getPage(pageNumber).then(function (page) {
var _page$view = _slicedToArray(page.view, 4),
x1 = _page$view[0],
y1 = _page$view[1],
x2 = _page$view[2],
y2 = _page$view[3];
return {
width: (x2 - x1) / 72 * page.userUnit,
height: (y2 - y1) / 72 * page.userUnit
};
});
},
getData: function PDFDocumentProxy_getData() {
return this.transport.getData();
},
@ -8797,6 +8781,19 @@ var PDFPageProxy = function PDFPageProxyClosure() { @@ -8797,6 +8781,19 @@ var PDFPageProxy = function PDFPageProxyClosure() {
get view() {
return this.pageInfo.view;
},
get pageSizeInches() {
var _view = _slicedToArray(this.view, 4),
x1 = _view[0],
y1 = _view[1],
x2 = _view[2],
y2 = _view[3],
userUnit = this.userUnit;
return {
width: (x2 - x1) / 72 * userUnit,
height: (y2 - y1) / 72 * userUnit
};
},
getViewport: function getViewport(scale) {
var rotate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.rotate;
var dontFlip = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
@ -10001,8 +9998,8 @@ var InternalRenderTask = function InternalRenderTaskClosure() { @@ -10001,8 +9998,8 @@ var InternalRenderTask = function InternalRenderTaskClosure() {
}();
var version, build;
{
exports.version = version = '2.0.432';
exports.build = build = '4136d41a';
exports.version = version = '2.0.437';
exports.build = build = '0d391dac';
}
exports.getDocument = getDocument;
exports.LoopbackPort = LoopbackPort;

2
build/pdf.js.map

File diff suppressed because one or more lines are too long

2
build/pdf.min.js vendored

File diff suppressed because one or more lines are too long

6
build/pdf.worker.js vendored

@ -22350,8 +22350,8 @@ exports.PostScriptCompiler = PostScriptCompiler; @@ -22350,8 +22350,8 @@ exports.PostScriptCompiler = PostScriptCompiler;
"use strict";
var pdfjsVersion = '2.0.432';
var pdfjsBuild = '4136d41a';
var pdfjsVersion = '2.0.437';
var pdfjsBuild = '0d391dac';
var pdfjsCoreWorker = __w_pdfjs_require__(74);
exports.WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler;
@ -22564,7 +22564,7 @@ var WorkerMessageHandler = { @@ -22564,7 +22564,7 @@ var WorkerMessageHandler = {
var cancelXHRs = null;
var WorkerTasks = [];
var apiVersion = docParams.apiVersion;
var workerVersion = '2.0.432';
var workerVersion = '2.0.437';
if (apiVersion !== null && apiVersion !== workerVersion) {
throw new Error('The API version "' + apiVersion + '" does not match ' + ('the Worker version "' + workerVersion + '".'));
}

2
build/pdf.worker.js.map vendored

File diff suppressed because one or more lines are too long

2
build/pdf.worker.min.js vendored

File diff suppressed because one or more lines are too long

2
lib/core/worker.js

@ -223,7 +223,7 @@ var WorkerMessageHandler = { @@ -223,7 +223,7 @@ var WorkerMessageHandler = {
var cancelXHRs = null;
var WorkerTasks = [];
var apiVersion = docParams.apiVersion;
var workerVersion = '2.0.432';
var workerVersion = '2.0.437';
if (apiVersion !== null && apiVersion !== workerVersion) {
throw new Error('The API version "' + apiVersion + '" does not match ' + ('the Worker version "' + workerVersion + '".'));
}

35
lib/display/api.js

@ -234,7 +234,7 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) { @@ -234,7 +234,7 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
}
return worker.messageHandler.sendWithPromise('GetDocRequest', {
docId: docId,
apiVersion: '2.0.432',
apiVersion: '2.0.437',
source: {
data: source.data,
url: source.url,
@ -395,22 +395,6 @@ var PDFDocumentProxy = function PDFDocumentProxyClosure() { @@ -395,22 +395,6 @@ var PDFDocumentProxy = function PDFDocumentProxyClosure() {
getMetadata: function PDFDocumentProxy_getMetadata() {
return this.transport.getMetadata();
},
getPageSizeInches: function getPageSizeInches(pageNumber) {
pageNumber = pageNumber || 1;
return this.getPage(pageNumber).then(function (page) {
var _page$view = _slicedToArray(page.view, 4),
x1 = _page$view[0],
y1 = _page$view[1],
x2 = _page$view[2],
y2 = _page$view[3];
return {
width: (x2 - x1) / 72 * page.userUnit,
height: (y2 - y1) / 72 * page.userUnit
};
});
},
getData: function PDFDocumentProxy_getData() {
return this.transport.getData();
},
@ -464,6 +448,19 @@ var PDFPageProxy = function PDFPageProxyClosure() { @@ -464,6 +448,19 @@ var PDFPageProxy = function PDFPageProxyClosure() {
get view() {
return this.pageInfo.view;
},
get pageSizeInches() {
var _view = _slicedToArray(this.view, 4),
x1 = _view[0],
y1 = _view[1],
x2 = _view[2],
y2 = _view[3],
userUnit = this.userUnit;
return {
width: (x2 - x1) / 72 * userUnit,
height: (y2 - y1) / 72 * userUnit
};
},
getViewport: function getViewport(scale) {
var rotate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.rotate;
var dontFlip = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
@ -1668,8 +1665,8 @@ var InternalRenderTask = function InternalRenderTaskClosure() { @@ -1668,8 +1665,8 @@ var InternalRenderTask = function InternalRenderTaskClosure() {
}();
var version, build;
{
exports.version = version = '2.0.432';
exports.build = build = '4136d41a';
exports.version = version = '2.0.437';
exports.build = build = '0d391dac';
}
exports.getDocument = getDocument;
exports.LoopbackPort = LoopbackPort;

4
lib/pdf.js

@ -21,8 +21,8 @@ @@ -21,8 +21,8 @@
*/
'use strict';
var pdfjsVersion = '2.0.432';
var pdfjsBuild = '4136d41a';
var pdfjsVersion = '2.0.437';
var pdfjsBuild = '0d391dac';
var pdfjsSharedUtil = require('./shared/util.js');
var pdfjsDisplayAPI = require('./display/api.js');
var pdfjsDisplayTextLayer = require('./display/text_layer.js');

4
lib/pdf.worker.js vendored

@ -21,7 +21,7 @@ @@ -21,7 +21,7 @@
*/
'use strict';
var pdfjsVersion = '2.0.432';
var pdfjsBuild = '4136d41a';
var pdfjsVersion = '2.0.437';
var pdfjsBuild = '0d391dac';
var pdfjsCoreWorker = require('./core/worker.js');
exports.WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler;

8
lib/test/unit/api_spec.js

@ -833,6 +833,14 @@ describe('api', function () { @@ -833,6 +833,14 @@ describe('api', function () {
it('gets view', function () {
expect(page.view).toEqual([0, 0, 595.28, 841.89]);
});
it('gets page size (in inches)', function () {
var _page$pageSizeInches = page.pageSizeInches,
width = _page$pageSizeInches.width,
height = _page$pageSizeInches.height;
expect(+width.toPrecision(3)).toEqual(8.27);
expect(+height.toPrecision(4)).toEqual(11.69);
});
it('gets viewport', function () {
var viewport = page.getViewport(1.5, 90);
expect(viewport.viewBox).toEqual(page.view);

2
lib/web/app.js

@ -353,7 +353,7 @@ var PDFViewerApplication = { @@ -353,7 +353,7 @@ var PDFViewerApplication = {
findBarConfig.findController = _this2.findController;
findBarConfig.eventBus = eventBus;
_this2.findBar = new _pdf_find_bar.PDFFindBar(findBarConfig, _this2.l10n);
_this2.pdfDocumentProperties = new _pdf_document_properties.PDFDocumentProperties(appConfig.documentProperties, _this2.overlayManager, _this2.l10n);
_this2.pdfDocumentProperties = new _pdf_document_properties.PDFDocumentProperties(appConfig.documentProperties, _this2.overlayManager, eventBus, _this2.l10n);
_this2.pdfCursorTools = new _pdf_cursor_tools.PDFCursorTools({
container: container,
eventBus: eventBus,

85
lib/web/pdf_document_properties.js

@ -39,12 +39,15 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons @@ -39,12 +39,15 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
var DEFAULT_FIELD_CONTENT = '-';
var PDFDocumentProperties = function () {
function PDFDocumentProperties(_ref, overlayManager) {
function PDFDocumentProperties(_ref, overlayManager, eventBus) {
var overlayName = _ref.overlayName,
fields = _ref.fields,
container = _ref.container,
closeButton = _ref.closeButton;
var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
var _this = this;
var l10n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _ui_utils.NullL10n;
_classCallCheck(this, PDFDocumentProperties);
@ -58,15 +61,20 @@ var PDFDocumentProperties = function () { @@ -58,15 +61,20 @@ var PDFDocumentProperties = function () {
closeButton.addEventListener('click', this.close.bind(this));
}
this.overlayManager.register(this.overlayName, this.container, this.close.bind(this));
if (eventBus) {
eventBus.on('pagechanging', function (evt) {
_this._currentPageNumber = evt.pageNumber;
});
}
}
_createClass(PDFDocumentProperties, [{
key: 'open',
value: function open() {
var _this = this;
var _this2 = this;
var freezeFieldData = function freezeFieldData(data) {
Object.defineProperty(_this, 'fieldData', {
Object.defineProperty(_this2, 'fieldData', {
value: Object.freeze(data),
writable: false,
enumerable: true,
@ -74,17 +82,18 @@ var PDFDocumentProperties = function () { @@ -74,17 +82,18 @@ var PDFDocumentProperties = function () {
});
};
Promise.all([this.overlayManager.open(this.overlayName), this._dataAvailableCapability.promise]).then(function () {
if (_this.fieldData) {
_this._updateUI();
var currentPageNumber = _this2._currentPageNumber;
if (_this2.fieldData && currentPageNumber === _this2.fieldData['_currentPageNumber']) {
_this2._updateUI();
return;
}
_this.pdfDocument.getMetadata().then(function (_ref2) {
_this2.pdfDocument.getMetadata().then(function (_ref2) {
var info = _ref2.info,
metadata = _ref2.metadata,
contentDispositionFilename = _ref2.contentDispositionFilename;
return Promise.all([info, metadata, contentDispositionFilename || (0, _ui_utils.getPDFFileNameFromURL)(_this.url), _this._parseFileSize(_this.maybeFileSize), _this._parseDate(info.CreationDate), _this._parseDate(info.ModDate), _this.pdfDocument.getPageSizeInches().then(function (pageSizeInches) {
return _this._parsePageSize(pageSizeInches);
return Promise.all([info, metadata, contentDispositionFilename || (0, _ui_utils.getPDFFileNameFromURL)(_this2.url), _this2._parseFileSize(_this2.maybeFileSize), _this2._parseDate(info.CreationDate), _this2._parseDate(info.ModDate), _this2.pdfDocument.getPage(currentPageNumber).then(function (pdfPage) {
return _this2._parsePageSize(pdfPage.pageSizeInches);
})]);
}).then(function (_ref3) {
var _ref4 = _slicedToArray(_ref3, 7),
@ -94,7 +103,7 @@ var PDFDocumentProperties = function () { @@ -94,7 +103,7 @@ var PDFDocumentProperties = function () {
fileSize = _ref4[3],
creationDate = _ref4[4],
modDate = _ref4[5],
pageSize = _ref4[6];
pageSizes = _ref4[6];
freezeFieldData({
'fileName': fileName,
@ -108,21 +117,26 @@ var PDFDocumentProperties = function () { @@ -108,21 +117,26 @@ var PDFDocumentProperties = function () {
'creator': info.Creator,
'producer': info.Producer,
'version': info.PDFFormatVersion,
'pageCount': _this.pdfDocument.numPages,
'pageSizeInch': pageSize.inch,
'pageSizeMM': pageSize.mm
'pageCount': _this2.pdfDocument.numPages,
'pageSizeInch': pageSizes.inch,
'pageSizeMM': pageSizes.mm,
'_currentPageNumber': currentPageNumber
});
_this._updateUI();
return _this.pdfDocument.getDownloadInfo();
_this2._updateUI();
return _this2.pdfDocument.getDownloadInfo();
}).then(function (_ref5) {
var length = _ref5.length;
return _this._parseFileSize(length);
_this2.maybeFileSize = length;
return _this2._parseFileSize(length);
}).then(function (fileSize) {
var data = (0, _ui_utils.cloneObj)(_this.fieldData);
if (fileSize === _this2.fieldData['fileSize']) {
return;
}
var data = (0, _ui_utils.cloneObj)(_this2.fieldData);
data['fileSize'] = fileSize;
freezeFieldData(data);
_this._updateUI();
_this2._updateUI();
});
});
}
@ -148,7 +162,7 @@ var PDFDocumentProperties = function () { @@ -148,7 +162,7 @@ var PDFDocumentProperties = function () {
}, {
key: 'setFileSize',
value: function setFileSize(fileSize) {
if (typeof fileSize === 'number' && fileSize > 0) {
if (Number.isInteger(fileSize) && fileSize > 0) {
this.maybeFileSize = fileSize;
}
}
@ -160,6 +174,7 @@ var PDFDocumentProperties = function () { @@ -160,6 +174,7 @@ var PDFDocumentProperties = function () {
this.maybeFileSize = 0;
delete this.fieldData;
this._dataAvailableCapability = (0, _pdf.createPromiseCapability)();
this._currentPageNumber = 1;
}
}, {
key: '_updateUI',
@ -203,23 +218,25 @@ var PDFDocumentProperties = function () { @@ -203,23 +218,25 @@ var PDFDocumentProperties = function () {
key: '_parsePageSize',
value: function _parsePageSize(pageSizeInches) {
if (!pageSizeInches) {
return Promise.resolve([undefined, undefined]);
}
var sizes_two_units = {
'width_in': Math.round(pageSizeInches.width * 100) / 100,
'height_in': Math.round(pageSizeInches.height * 100) / 100,
'width_mm': Math.round(pageSizeInches.width * 25.4 * 10) / 10,
'height_mm': Math.round(pageSizeInches.height * 25.4 * 10) / 10
};
return Promise.all([this.l10n.get('document_properties_page_size_in', sizes_two_units, '{{width_in}} in × {{height_in}} in'), this.l10n.get('document_properties_page_size_mm', sizes_two_units, '{{width_mm}} mm × {{height_mm}} mm')]).then(function (_ref6) {
var _ref7 = _slicedToArray(_ref6, 2),
parsedPageSizeInches = _ref7[0],
parsedPageSizeMM = _ref7[1];
return Promise.resolve({
inch: parsedPageSizeInches,
mm: parsedPageSizeMM
inch: undefined,
mm: undefined
});
}
var width = pageSizeInches.width,
height = pageSizeInches.height;
return Promise.all([this.l10n.get('document_properties_page_size_in_2', {
width: (Math.round(width * 100) / 100).toLocaleString(),
height: (Math.round(height * 100) / 100).toLocaleString()
}, '{{width}} × {{height}} in'), this.l10n.get('document_properties_page_size_mm_2', {
width: (Math.round(width * 25.4 * 10) / 10).toLocaleString(),
height: (Math.round(height * 25.4 * 10) / 10).toLocaleString()
}, '{{width}} × {{height}} mm')]).then(function (sizes) {
return {
inch: sizes[0],
mm: sizes[1]
};
});
}
}, {

4
lib/web/pdf_viewer.component.js

@ -48,8 +48,8 @@ var _pdf_single_page_viewer = require('./pdf_single_page_viewer'); @@ -48,8 +48,8 @@ var _pdf_single_page_viewer = require('./pdf_single_page_viewer');
var _pdf_viewer = require('./pdf_viewer.js');
var pdfjsVersion = '2.0.432';
var pdfjsBuild = '4136d41a';
var pdfjsVersion = '2.0.437';
var pdfjsBuild = '0d391dac';
exports.PDFViewer = _pdf_viewer.PDFViewer;
exports.PDFSinglePageViewer = _pdf_single_page_viewer.PDFSinglePageViewer;
exports.PDFPageView = _pdf_page_view.PDFPageView;

2
package.json

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

4
web/pdf_viewer.js

@ -3183,8 +3183,8 @@ var _pdf_single_page_viewer = __w_pdfjs_require__(16); @@ -3183,8 +3183,8 @@ var _pdf_single_page_viewer = __w_pdfjs_require__(16);
var _pdf_viewer = __w_pdfjs_require__(17);
var pdfjsVersion = '2.0.432';
var pdfjsBuild = '4136d41a';
var pdfjsVersion = '2.0.437';
var pdfjsBuild = '0d391dac';
exports.PDFViewer = _pdf_viewer.PDFViewer;
exports.PDFSinglePageViewer = _pdf_single_page_viewer.PDFSinglePageViewer;
exports.PDFPageView = _pdf_page_view.PDFPageView;

2
web/pdf_viewer.js.map

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save