Skip to content
This repository has been archived by the owner on Jul 14, 2024. It is now read-only.

Commit

Permalink
PDF.js version 2.0.466 - See mozilla/pdf.js@a8e9f6c
Browse files Browse the repository at this point in the history
  • Loading branch information
pdfjsbot committed Mar 25, 2018
1 parent 1f0cfc0 commit de65be6
Show file tree
Hide file tree
Showing 22 changed files with 177 additions and 67 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pdfjs-dist",
"version": "2.0.457",
"version": "2.0.466",
"main": [
"build/pdf.js",
"build/pdf.worker.js"
Expand Down
10 changes: 5 additions & 5 deletions build/pdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -3004,8 +3004,8 @@ exports.GlobalWorkerOptions = GlobalWorkerOptions;
"use strict";


var pdfjsVersion = '2.0.457';
var pdfjsBuild = '5c1a16ba';
var pdfjsVersion = '2.0.466';
var pdfjsBuild = 'a8e9f6cc';
var pdfjsSharedUtil = __w_pdfjs_require__(0);
var pdfjsDisplayAPI = __w_pdfjs_require__(117);
var pdfjsDisplayTextLayer = __w_pdfjs_require__(125);
Expand Down Expand Up @@ -8434,7 +8434,7 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
}
return worker.messageHandler.sendWithPromise('GetDocRequest', {
docId: docId,
apiVersion: '2.0.457',
apiVersion: '2.0.466',
source: {
data: source.data,
url: source.url,
Expand Down Expand Up @@ -9852,8 +9852,8 @@ var InternalRenderTask = function InternalRenderTaskClosure() {
}();
var version, build;
{
exports.version = version = '2.0.457';
exports.build = build = '5c1a16ba';
exports.version = version = '2.0.466';
exports.build = build = 'a8e9f6cc';
}
exports.getDocument = getDocument;
exports.LoopbackPort = LoopbackPort;
Expand Down
2 changes: 1 addition & 1 deletion build/pdf.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/pdf.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions build/pdf.worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -22361,8 +22361,8 @@ exports.PostScriptCompiler = PostScriptCompiler;
"use strict";


var pdfjsVersion = '2.0.457';
var pdfjsBuild = '5c1a16ba';
var pdfjsVersion = '2.0.466';
var pdfjsBuild = 'a8e9f6cc';
var pdfjsCoreWorker = __w_pdfjs_require__(74);
exports.WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler;

Expand Down Expand Up @@ -22575,7 +22575,7 @@ var WorkerMessageHandler = {
var cancelXHRs = null;
var WorkerTasks = [];
var apiVersion = docParams.apiVersion;
var workerVersion = '2.0.457';
var workerVersion = '2.0.466';
if (apiVersion !== null && apiVersion !== workerVersion) {
throw new Error('The API version "' + apiVersion + '" does not match ' + ('the Worker version "' + workerVersion + '".'));
}
Expand Down
2 changes: 1 addition & 1 deletion build/pdf.worker.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/pdf.worker.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/core/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ var WorkerMessageHandler = {
var cancelXHRs = null;
var WorkerTasks = [];
var apiVersion = docParams.apiVersion;
var workerVersion = '2.0.457';
var workerVersion = '2.0.466';
if (apiVersion !== null && apiVersion !== workerVersion) {
throw new Error('The API version "' + apiVersion + '" does not match ' + ('the Worker version "' + workerVersion + '".'));
}
Expand Down
6 changes: 3 additions & 3 deletions lib/display/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
}
return worker.messageHandler.sendWithPromise('GetDocRequest', {
docId: docId,
apiVersion: '2.0.457',
apiVersion: '2.0.466',
source: {
data: source.data,
url: source.url,
Expand Down Expand Up @@ -1650,8 +1650,8 @@ var InternalRenderTask = function InternalRenderTaskClosure() {
}();
var version, build;
{
exports.version = version = '2.0.457';
exports.build = build = '5c1a16ba';
exports.version = version = '2.0.466';
exports.build = build = 'a8e9f6cc';
}
exports.getDocument = getDocument;
exports.LoopbackPort = LoopbackPort;
Expand Down
4 changes: 2 additions & 2 deletions lib/pdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
*/
'use strict';

var pdfjsVersion = '2.0.457';
var pdfjsBuild = '5c1a16ba';
var pdfjsVersion = '2.0.466';
var pdfjsBuild = 'a8e9f6cc';
var pdfjsSharedUtil = require('./shared/util.js');
var pdfjsDisplayAPI = require('./display/api.js');
var pdfjsDisplayTextLayer = require('./display/text_layer.js');
Expand Down
4 changes: 2 additions & 2 deletions lib/pdf.worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
'use strict';

var pdfjsVersion = '2.0.457';
var pdfjsBuild = '5c1a16ba';
var pdfjsVersion = '2.0.466';
var pdfjsBuild = 'a8e9f6cc';
var pdfjsCoreWorker = require('./core/worker.js');
exports.WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler;
18 changes: 18 additions & 0 deletions lib/test/unit/ui_utils_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,24 @@ describe('ui_utils', function () {
expect((0, _ui_utils.isValidRotation)(540)).toEqual(true);
});
});
describe('isPortraitOrientation', function () {
it('should be portrait orientation', function () {
expect((0, _ui_utils.isPortraitOrientation)({
width: 200,
height: 400
})).toEqual(true);
expect((0, _ui_utils.isPortraitOrientation)({
width: 500,
height: 500
})).toEqual(true);
});
it('should be landscape orientation', function () {
expect((0, _ui_utils.isPortraitOrientation)({
width: 600,
height: 300
})).toEqual(false);
});
});
describe('waitOnEventOrTimeout', function () {
var eventBus = void 0;
beforeAll(function (done) {
Expand Down
10 changes: 3 additions & 7 deletions lib/web/base_viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,6 @@ function isSameScale(oldScale, newScale) {
}
return false;
}
function isPortraitOrientation(size) {
return size.width <= size.height;
}

var BaseViewer = function () {
function BaseViewer(options) {
Expand Down Expand Up @@ -391,8 +388,7 @@ var BaseViewer = function () {
scale = Math.min(pageWidthScale, pageHeightScale);
break;
case 'auto':
var isLandscape = currentPage.width > currentPage.height;
var horizontalScale = isLandscape ? Math.min(pageHeightScale, pageWidthScale) : pageWidthScale;
var horizontalScale = (0, _ui_utils.isPortraitOrientation)(currentPage) ? pageWidthScale : Math.min(pageHeightScale, pageWidthScale);
scale = Math.min(_ui_utils.MAX_AUTO_SCALE, horizontalScale);
break;
default:
Expand Down Expand Up @@ -675,9 +671,9 @@ var BaseViewer = function () {
if (!this.enablePrintAutoRotate) {
return pagesOverview;
}
var isFirstPagePortrait = isPortraitOrientation(pagesOverview[0]);
var isFirstPagePortrait = (0, _ui_utils.isPortraitOrientation)(pagesOverview[0]);
return pagesOverview.map(function (size) {
if (isFirstPagePortrait === isPortraitOrientation(size)) {
if (isFirstPagePortrait === (0, _ui_utils.isPortraitOrientation)(size)) {
return size;
}
return {
Expand Down
5 changes: 5 additions & 0 deletions lib/web/firefoxcom.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,11 @@ var MozL10n = function () {
}

_createClass(MozL10n, [{
key: 'getLanguage',
value: function getLanguage() {
return Promise.resolve(this.mozL10n.getLanguage());
}
}, {
key: 'getDirection',
value: function getDirection() {
return Promise.resolve(this.mozL10n.getDirection());
Expand Down
7 changes: 7 additions & 0 deletions lib/web/genericl10n.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ var GenericL10n = function () {
}

_createClass(GenericL10n, [{
key: 'getLanguage',
value: function getLanguage() {
return this._ready.then(function (l10n) {
return l10n.getLanguage();
});
}
}, {
key: 'getDirection',
value: function getDirection() {
return this._ready.then(function (l10n) {
Expand Down
3 changes: 3 additions & 0 deletions lib/web/interfaces.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ var IL10n = function () {
}

_createClass(IL10n, [{
key: 'getLanguage',
value: function getLanguage() {}
}, {
key: 'getDirection',
value: function getDirection() {}
}, {
Expand Down
112 changes: 88 additions & 24 deletions lib/web/pdf_document_properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,20 @@ var _pdf = require('../pdf');
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

var DEFAULT_FIELD_CONTENT = '-';
var NON_METRIC_LOCALES = ['en-us', 'en-lr', 'my'];
var US_PAGE_NAMES = {
'8.5x11': 'Letter',
'8.5x14': 'Legal'
};
var METRIC_PAGE_NAMES = {
'297x420': 'A3',
'210x297': 'A4'
};
function getPageName(size, isPortrait, pageNames) {
var width = isPortrait ? size.width : size.height;
var height = isPortrait ? size.height : size.width;
return pageNames[width + 'x' + height];
}

var PDFDocumentProperties = function () {
function PDFDocumentProperties(_ref, overlayManager, eventBus) {
Expand Down Expand Up @@ -65,7 +79,14 @@ var PDFDocumentProperties = function () {
eventBus.on('pagechanging', function (evt) {
_this._currentPageNumber = evt.pageNumber;
});
eventBus.on('rotationchanging', function (evt) {
_this._pagesRotation = evt.pagesRotation;
});
}
this._isNonMetricLocale = true;
l10n.getLanguage().then(function (locale) {
_this._isNonMetricLocale = NON_METRIC_LOCALES.includes(locale);
});
}

_createClass(PDFDocumentProperties, [{
Expand All @@ -83,7 +104,8 @@ var PDFDocumentProperties = function () {
};
Promise.all([this.overlayManager.open(this.overlayName), this._dataAvailableCapability.promise]).then(function () {
var currentPageNumber = _this2._currentPageNumber;
if (_this2.fieldData && currentPageNumber === _this2.fieldData['_currentPageNumber']) {
var pagesRotation = _this2._pagesRotation;
if (_this2.fieldData && currentPageNumber === _this2.fieldData['_currentPageNumber'] && pagesRotation === _this2.fieldData['_pagesRotation']) {
_this2._updateUI();
return;
}
Expand All @@ -93,7 +115,7 @@ var PDFDocumentProperties = function () {
contentDispositionFilename = _ref2.contentDispositionFilename;

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((0, _ui_utils.getPageSizeInches)(pdfPage));
return _this2._parsePageSize((0, _ui_utils.getPageSizeInches)(pdfPage), pagesRotation);
})]);
}).then(function (_ref3) {
var _ref4 = _slicedToArray(_ref3, 7),
Expand All @@ -103,7 +125,7 @@ var PDFDocumentProperties = function () {
fileSize = _ref4[3],
creationDate = _ref4[4],
modDate = _ref4[5],
pageSizes = _ref4[6];
pageSize = _ref4[6];

freezeFieldData({
'fileName': fileName,
Expand All @@ -118,9 +140,9 @@ var PDFDocumentProperties = function () {
'producer': info.Producer,
'version': info.PDFFormatVersion,
'pageCount': _this2.pdfDocument.numPages,
'pageSizeInch': pageSizes.inch,
'pageSizeMM': pageSizes.mm,
'_currentPageNumber': currentPageNumber
'pageSize': pageSize,
'_currentPageNumber': currentPageNumber,
'_pagesRotation': pagesRotation
});
_this2._updateUI();
return _this2.pdfDocument.getDownloadInfo();
Expand Down Expand Up @@ -175,6 +197,7 @@ var PDFDocumentProperties = function () {
delete this.fieldData;
this._dataAvailableCapability = (0, _pdf.createPromiseCapability)();
this._currentPageNumber = 1;
this._pagesRotation = 0;
}
}, {
key: '_updateUI',
Expand Down Expand Up @@ -216,27 +239,68 @@ var PDFDocumentProperties = function () {
}
}, {
key: '_parsePageSize',
value: function _parsePageSize(pageSizeInches) {
value: function _parsePageSize(pageSizeInches, pagesRotation) {
var _this3 = this;

if (!pageSizeInches) {
return Promise.resolve({
inch: undefined,
mm: undefined
});
return Promise.resolve(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]
if (pagesRotation % 180 !== 0) {
pageSizeInches = {
width: pageSizeInches.height,
height: pageSizeInches.width
};
}
var isPortrait = (0, _ui_utils.isPortraitOrientation)(pageSizeInches);
var sizeInches = {
width: Math.round(pageSizeInches.width * 100) / 100,
height: Math.round(pageSizeInches.height * 100) / 100
};
var sizeMillimeters = {
width: Math.round(pageSizeInches.width * 25.4 * 10) / 10,
height: Math.round(pageSizeInches.height * 25.4 * 10) / 10
};
var pageName = null;
var name = getPageName(sizeInches, isPortrait, US_PAGE_NAMES) || getPageName(sizeMillimeters, isPortrait, METRIC_PAGE_NAMES);
if (!name && !(Number.isInteger(sizeMillimeters.width) && Number.isInteger(sizeMillimeters.height))) {
var exactMillimeters = {
width: pageSizeInches.width * 25.4,
height: pageSizeInches.height * 25.4
};
var intMillimeters = {
width: Math.round(sizeMillimeters.width),
height: Math.round(sizeMillimeters.height)
};
if (Math.abs(exactMillimeters.width - intMillimeters.width) < 0.1 && Math.abs(exactMillimeters.height - intMillimeters.height) < 0.1) {
name = getPageName(intMillimeters, isPortrait, METRIC_PAGE_NAMES);
if (name) {
sizeInches = {
width: Math.round(intMillimeters.width / 25.4 * 100) / 100,
height: Math.round(intMillimeters.height / 25.4 * 100) / 100
};
sizeMillimeters = intMillimeters;
}
}
}
if (name) {
pageName = this.l10n.get('document_properties_page_size_name_' + name.toLowerCase(), null, name);
}
return Promise.all([this._isNonMetricLocale ? sizeInches : sizeMillimeters, this.l10n.get('document_properties_page_size_unit_' + (this._isNonMetricLocale ? 'inches' : 'millimeters'), null, this._isNonMetricLocale ? 'in' : 'mm'), pageName, this.l10n.get('document_properties_page_size_orientation_' + (isPortrait ? 'portrait' : 'landscape'), null, isPortrait ? 'portrait' : 'landscape')]).then(function (_ref6) {
var _ref7 = _slicedToArray(_ref6, 4),
_ref7$ = _ref7[0],
width = _ref7$.width,
height = _ref7$.height,
unit = _ref7[1],
name = _ref7[2],
orientation = _ref7[3];

return _this3.l10n.get('document_properties_page_size_dimension_' + (name ? 'name_' : '') + 'string', {
width: width.toLocaleString(),
height: height.toLocaleString(),
unit: unit,
name: name,
orientation: orientation
}, '{{width}} × {{height}} {{unit}} (' + (name ? '{{name}}, ' : '') + '{{orientation}})');
});
}
}, {
Expand Down
4 changes: 2 additions & 2 deletions lib/web/pdf_viewer.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.457';
var pdfjsBuild = '5c1a16ba';
var pdfjsVersion = '2.0.466';
var pdfjsBuild = 'a8e9f6cc';
exports.PDFViewer = _pdf_viewer.PDFViewer;
exports.PDFSinglePageViewer = _pdf_single_page_viewer.PDFSinglePageViewer;
exports.PDFPageView = _pdf_page_view.PDFPageView;
Expand Down
Loading

0 comments on commit de65be6

Please sign in to comment.