Browse Source

PDF.js version 1.9.541 - See mozilla/pdf.js@e6d05be41a3556fbb47118d579f7dcaa630b3600

master v1.9.541
pdfjsbot 7 years ago
parent
commit
8996bb74f1
  1. 2
      bower.json
  2. 12
      build/pdf.combined.js
  3. 2
      build/pdf.combined.js.map
  4. 12
      build/pdf.js
  5. 2
      build/pdf.js.map
  6. 2
      build/pdf.min.js
  7. 4
      build/pdf.worker.js
  8. 2
      build/pdf.worker.js.map
  9. 4
      lib/display/api.js
  10. 4
      lib/display/global.js
  11. 4
      lib/pdf.js
  12. 4
      lib/pdf.worker.js
  13. 20
      lib/test/unit/ui_utils_spec.js
  14. 47
      lib/web/app.js
  15. 4
      lib/web/interfaces.js
  16. 29
      lib/web/pdf_history.js
  17. 14
      lib/web/pdf_link_service.js
  18. 5
      lib/web/pdf_thumbnail_viewer.js
  19. 16
      lib/web/pdf_viewer.js
  20. 6
      lib/web/ui_utils.js
  21. 2
      package.json
  22. 65
      web/pdf_viewer.js
  23. 2
      web/pdf_viewer.js.map

2
bower.json

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

12
build/pdf.combined.js

@ -13443,8 +13443,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() { @@ -13443,8 +13443,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() {
}();
var version, build;
{
exports.version = version = '1.9.537';
exports.build = build = 'bd3f16bf';
exports.version = version = '1.9.541';
exports.build = build = 'e6d05be4';
}
exports.getDocument = getDocument;
exports.LoopbackPort = LoopbackPort;
@ -29207,8 +29207,8 @@ exports.SVGGraphics = SVGGraphics; @@ -29207,8 +29207,8 @@ exports.SVGGraphics = SVGGraphics;
"use strict";
var pdfjsVersion = '1.9.537';
var pdfjsBuild = 'bd3f16bf';
var pdfjsVersion = '1.9.541';
var pdfjsBuild = 'e6d05be4';
var pdfjsSharedUtil = __w_pdfjs_require__(0);
var pdfjsDisplayGlobal = __w_pdfjs_require__(98);
var pdfjsDisplayAPI = __w_pdfjs_require__(55);
@ -35070,8 +35070,8 @@ if (!_global_scope2.default.PDFJS) { @@ -35070,8 +35070,8 @@ if (!_global_scope2.default.PDFJS) {
}
var PDFJS = _global_scope2.default.PDFJS;
{
PDFJS.version = '1.9.537';
PDFJS.build = 'bd3f16bf';
PDFJS.version = '1.9.541';
PDFJS.build = 'e6d05be4';
}
PDFJS.pdfBug = false;
if (PDFJS.verbosity !== undefined) {

2
build/pdf.combined.js.map

File diff suppressed because one or more lines are too long

12
build/pdf.js

@ -4173,8 +4173,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() { @@ -4173,8 +4173,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() {
}();
var version, build;
{
exports.version = version = '1.9.537';
exports.build = build = 'bd3f16bf';
exports.version = version = '1.9.541';
exports.build = build = 'e6d05be4';
}
exports.getDocument = getDocument;
exports.LoopbackPort = LoopbackPort;
@ -7052,8 +7052,8 @@ exports.SVGGraphics = SVGGraphics; @@ -7052,8 +7052,8 @@ exports.SVGGraphics = SVGGraphics;
"use strict";
var pdfjsVersion = '1.9.537';
var pdfjsBuild = 'bd3f16bf';
var pdfjsVersion = '1.9.541';
var pdfjsBuild = 'e6d05be4';
var pdfjsSharedUtil = __w_pdfjs_require__(0);
var pdfjsDisplayGlobal = __w_pdfjs_require__(82);
var pdfjsDisplayAPI = __w_pdfjs_require__(48);
@ -12915,8 +12915,8 @@ if (!_global_scope2.default.PDFJS) { @@ -12915,8 +12915,8 @@ if (!_global_scope2.default.PDFJS) {
}
var PDFJS = _global_scope2.default.PDFJS;
{
PDFJS.version = '1.9.537';
PDFJS.build = 'bd3f16bf';
PDFJS.version = '1.9.541';
PDFJS.build = 'e6d05be4';
}
PDFJS.pdfBug = false;
if (PDFJS.verbosity !== undefined) {

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

4
build/pdf.worker.js vendored

@ -24512,8 +24512,8 @@ exports.getUnicodeForGlyph = getUnicodeForGlyph; @@ -24512,8 +24512,8 @@ exports.getUnicodeForGlyph = getUnicodeForGlyph;
"use strict";
var pdfjsVersion = '1.9.537';
var pdfjsBuild = 'bd3f16bf';
var pdfjsVersion = '1.9.541';
var pdfjsBuild = 'e6d05be4';
var pdfjsCoreWorker = __w_pdfjs_require__(62);
exports.WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler;

2
build/pdf.worker.js.map vendored

File diff suppressed because one or more lines are too long

4
lib/display/api.js

@ -1581,8 +1581,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() { @@ -1581,8 +1581,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() {
}();
var version, build;
{
exports.version = version = '1.9.537';
exports.build = build = 'bd3f16bf';
exports.version = version = '1.9.541';
exports.build = build = 'e6d05be4';
}
exports.getDocument = getDocument;
exports.LoopbackPort = LoopbackPort;

4
lib/display/global.js

@ -45,8 +45,8 @@ if (!_global_scope2.default.PDFJS) { @@ -45,8 +45,8 @@ if (!_global_scope2.default.PDFJS) {
}
var PDFJS = _global_scope2.default.PDFJS;
{
PDFJS.version = '1.9.537';
PDFJS.build = 'bd3f16bf';
PDFJS.version = '1.9.541';
PDFJS.build = 'e6d05be4';
}
PDFJS.pdfBug = false;
if (PDFJS.verbosity !== undefined) {

4
lib/pdf.js

@ -14,8 +14,8 @@ @@ -14,8 +14,8 @@
*/
'use strict';
var pdfjsVersion = '1.9.537';
var pdfjsBuild = 'bd3f16bf';
var pdfjsVersion = '1.9.541';
var pdfjsBuild = 'e6d05be4';
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,7 +14,7 @@ @@ -14,7 +14,7 @@
*/
'use strict';
var pdfjsVersion = '1.9.537';
var pdfjsBuild = 'bd3f16bf';
var pdfjsVersion = '1.9.541';
var pdfjsBuild = 'e6d05be4';
var pdfjsCoreWorker = require('./core/worker.js');
exports.WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler;

20
lib/test/unit/ui_utils_spec.js

@ -193,6 +193,26 @@ describe('ui_utils', function () { @@ -193,6 +193,26 @@ describe('ui_utils', function () {
expect(count).toEqual(2);
});
});
describe('isValidRotation', function () {
it('should reject non-integer angles', function () {
expect((0, _ui_utils.isValidRotation)()).toEqual(false);
expect((0, _ui_utils.isValidRotation)(null)).toEqual(false);
expect((0, _ui_utils.isValidRotation)(NaN)).toEqual(false);
expect((0, _ui_utils.isValidRotation)([90])).toEqual(false);
expect((0, _ui_utils.isValidRotation)('90')).toEqual(false);
expect((0, _ui_utils.isValidRotation)(90.5)).toEqual(false);
});
it('should reject non-multiple of 90 degree angles', function () {
expect((0, _ui_utils.isValidRotation)(45)).toEqual(false);
expect((0, _ui_utils.isValidRotation)(-123)).toEqual(false);
});
it('should accept valid angles', function () {
expect((0, _ui_utils.isValidRotation)(0)).toEqual(true);
expect((0, _ui_utils.isValidRotation)(90)).toEqual(true);
expect((0, _ui_utils.isValidRotation)(-270)).toEqual(true);
expect((0, _ui_utils.isValidRotation)(540)).toEqual(true);
});
});
describe('waitOnEventOrTimeout', function () {
var eventBus = void 0;
beforeAll(function (done) {

47
lib/web/app.js

@ -652,6 +652,7 @@ var PDFViewerApplication = { @@ -652,6 +652,7 @@ var PDFViewerApplication = {
_this6.pdfHistory.initialize(id, resetHistory);
if (_this6.pdfHistory.initialBookmark) {
_this6.initialBookmark = _this6.pdfHistory.initialBookmark;
_this6.initialRotation = _this6.pdfHistory.initialRotation;
}
}
var initialParams = {
@ -664,6 +665,7 @@ var PDFViewerApplication = { @@ -664,6 +665,7 @@ var PDFViewerApplication = {
zoom: _ui_utils.DEFAULT_SCALE_VALUE,
scrollLeft: '0',
scrollTop: '0',
rotation: null,
sidebarView: _pdf_sidebar.SidebarView.NONE
}).catch(function () {});
Promise.all([storePromise, pageModePromise]).then(function (_ref2) {
@ -673,9 +675,11 @@ var PDFViewerApplication = { @@ -673,9 +675,11 @@ var PDFViewerApplication = {
pageMode = _ref3[1];
var hash = _this6.viewerPrefs['defaultZoomValue'] ? 'zoom=' + _this6.viewerPrefs['defaultZoomValue'] : null;
var rotation = null;
var sidebarView = _this6.viewerPrefs['sidebarViewOnLoad'];
if (values.exists && _this6.viewerPrefs['showPreviousViewOnLoad']) {
hash = 'page=' + values.page + '&zoom=' + (_this6.viewerPrefs['defaultZoomValue'] || values.zoom) + ',' + values.scrollLeft + ',' + values.scrollTop;
rotation = parseInt(values.rotation, 10);
sidebarView = sidebarView || values.sidebarView | 0;
}
if (pageMode && !_this6.viewerPrefs['disablePageMode']) {
@ -683,15 +687,20 @@ var PDFViewerApplication = { @@ -683,15 +687,20 @@ var PDFViewerApplication = {
}
return {
hash: hash,
rotation: rotation,
sidebarView: sidebarView
};
}).then(function (_ref4) {
var hash = _ref4.hash,
rotation = _ref4.rotation,
sidebarView = _ref4.sidebarView;
initialParams.bookmark = _this6.initialBookmark;
initialParams.hash = hash;
_this6.setInitialView(hash, { sidebarView: sidebarView });
_this6.setInitialView(hash, {
rotation: rotation,
sidebarView: sidebarView
});
if (!_this6.isViewerEmbedded) {
pdfViewer.focus();
}
@ -787,15 +796,26 @@ var PDFViewerApplication = { @@ -787,15 +796,26 @@ var PDFViewerApplication = {
});
},
setInitialView: function setInitialView(storedHash) {
var _this7 = this;
var _ref6 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
rotation = _ref6.rotation,
sidebarView = _ref6.sidebarView;
var setRotation = function setRotation(angle) {
if ((0, _ui_utils.isValidRotation)(angle)) {
_this7.pdfViewer.pagesRotation = angle;
}
};
this.isInitialViewSet = true;
this.pdfSidebar.setInitialView(sidebarView);
if (this.initialBookmark) {
setRotation(this.initialRotation);
delete this.initialRotation;
this.pdfLinkService.setHash(this.initialBookmark);
this.initialBookmark = null;
} else if (storedHash) {
setRotation(rotation);
this.pdfLinkService.setHash(storedHash);
}
this.toolbar.setPageNumber(this.pdfViewer.currentPageNumber, this.pdfViewer.currentPageLabel);
@ -820,14 +840,14 @@ var PDFViewerApplication = { @@ -820,14 +840,14 @@ var PDFViewerApplication = {
this.pdfRenderingQueue.renderHighestPriority();
},
beforePrint: function beforePrint() {
var _this7 = this;
var _this8 = this;
if (this.printService) {
return;
}
if (!this.supportsPrinting) {
this.l10n.get('printing_not_supported', null, 'Warning: Printing is not fully supported by ' + 'this browser.').then(function (printMessage) {
_this7.error(printMessage);
_this8.error(printMessage);
});
return;
}
@ -856,15 +876,8 @@ var PDFViewerApplication = { @@ -856,15 +876,8 @@ var PDFViewerApplication = {
if (!this.pdfDocument) {
return;
}
var pdfViewer = this.pdfViewer,
pdfThumbnailViewer = this.pdfThumbnailViewer;
var pageNumber = pdfViewer.currentPageNumber;
var newRotation = (pdfViewer.pagesRotation + 360 + delta) % 360;
pdfViewer.pagesRotation = newRotation;
pdfThumbnailViewer.pagesRotation = newRotation;
this.forceRendering();
pdfViewer.currentPageNumber = pageNumber;
var newRotation = (this.pdfViewer.pagesRotation + 360 + delta) % 360;
this.pdfViewer.pagesRotation = newRotation;
},
requestPresentationMode: function requestPresentationMode() {
if (!this.pdfPresentationMode) {
@ -887,6 +900,7 @@ var PDFViewerApplication = { @@ -887,6 +900,7 @@ var PDFViewerApplication = {
eventBus.on('updateviewarea', webViewerUpdateViewarea);
eventBus.on('pagechanging', webViewerPageChanging);
eventBus.on('scalechanging', webViewerScaleChanging);
eventBus.on('rotationchanging', webViewerRotationChanging);
eventBus.on('sidebarviewchanged', webViewerSidebarViewChanged);
eventBus.on('pagemode', webViewerPageMode);
eventBus.on('namedaction', webViewerNamedAction);
@ -955,6 +969,7 @@ var PDFViewerApplication = { @@ -955,6 +969,7 @@ var PDFViewerApplication = {
eventBus.off('updateviewarea', webViewerUpdateViewarea);
eventBus.off('pagechanging', webViewerPageChanging);
eventBus.off('scalechanging', webViewerScaleChanging);
eventBus.off('rotationchanging', webViewerRotationChanging);
eventBus.off('sidebarviewchanged', webViewerSidebarViewChanged);
eventBus.off('pagemode', webViewerPageMode);
eventBus.off('namedaction', webViewerNamedAction);
@ -1249,7 +1264,8 @@ function webViewerUpdateViewarea(evt) { @@ -1249,7 +1264,8 @@ function webViewerUpdateViewarea(evt) {
'page': location.pageNumber,
'zoom': location.scale,
'scrollLeft': location.left,
'scrollTop': location.top
'scrollTop': location.top,
'rotation': location.rotation
}).catch(function () {});
}
var href = PDFViewerApplication.pdfLinkService.getAnchorUrl(location.pdfOpenParams);
@ -1381,6 +1397,11 @@ function webViewerScaleChanging(evt) { @@ -1381,6 +1397,11 @@ function webViewerScaleChanging(evt) {
PDFViewerApplication.toolbar.setPageScale(evt.presetValue, evt.scale);
PDFViewerApplication.pdfViewer.update();
}
function webViewerRotationChanging(evt) {
PDFViewerApplication.pdfThumbnailViewer.pagesRotation = evt.pagesRotation;
PDFViewerApplication.forceRendering();
PDFViewerApplication.pdfViewer.currentPageNumber = evt.pageNumber;
}
function webViewerPageChanging(evt) {
var page = evt.pageNumber;
PDFViewerApplication.toolbar.setPageNumber(page, evt.pageLabel || null);

4
lib/web/interfaces.js

@ -52,6 +52,10 @@ var IPDFLinkService = function () { @@ -52,6 +52,10 @@ var IPDFLinkService = function () {
key: 'page',
get: function get() {},
set: function set(value) {}
}, {
key: 'rotation',
get: function get() {},
set: function set(value) {}
}]);
return IPDFLinkService;

29
lib/web/pdf_history.js

@ -44,7 +44,8 @@ function parseCurrentHash(linkService) { @@ -44,7 +44,8 @@ function parseCurrentHash(linkService) {
}
return {
hash: hash,
page: page
page: page,
rotation: linkService.rotation
};
}
@ -61,6 +62,7 @@ var PDFHistory = function () { @@ -61,6 +62,7 @@ var PDFHistory = function () {
this.eventBus = eventBus || (0, _dom_events.getGlobalEventBus)();
this.initialized = false;
this.initialBookmark = null;
this.initialRotation = null;
this._boundEvents = Object.create(null);
this._isViewerInPresentationMode = false;
this._isPagesLoaded = false;
@ -89,6 +91,7 @@ var PDFHistory = function () { @@ -89,6 +91,7 @@ var PDFHistory = function () {
var state = window.history.state;
this.initialized = true;
this.initialBookmark = null;
this.initialRotation = null;
this._popStateInProgress = false;
this._blockHashChange = 0;
this._currentHash = getCurrentHash();
@ -99,7 +102,8 @@ var PDFHistory = function () { @@ -99,7 +102,8 @@ var PDFHistory = function () {
if (!this._isValidState(state) || resetHistory) {
var _parseCurrentHash = parseCurrentHash(this.linkService),
hash = _parseCurrentHash.hash,
page = _parseCurrentHash.page;
page = _parseCurrentHash.page,
rotation = _parseCurrentHash.rotation;
if (!hash || reInitialized || resetHistory) {
this._pushOrReplaceState(null, true);
@ -107,12 +111,16 @@ var PDFHistory = function () { @@ -107,12 +111,16 @@ var PDFHistory = function () {
}
this._pushOrReplaceState({
hash: hash,
page: page
page: page,
rotation: rotation
}, true);
return;
}
var destination = state.destination;
this._updateInternalState(destination, state.uid, true);
if (destination.rotation !== undefined) {
this.initialRotation = destination.rotation;
}
if (destination.dest) {
this.initialBookmark = JSON.stringify(destination.dest);
this._destination.page = null;
@ -155,7 +163,8 @@ var PDFHistory = function () { @@ -155,7 +163,8 @@ var PDFHistory = function () {
this._pushOrReplaceState({
dest: explicitDest,
hash: hash,
page: pageNumber
page: pageNumber,
rotation: this.linkService.rotation
}, forceReplace);
if (!this._popStateInProgress) {
this._popStateInProgress = true;
@ -296,7 +305,8 @@ var PDFHistory = function () { @@ -296,7 +305,8 @@ var PDFHistory = function () {
this._position = {
hash: this._isViewerInPresentationMode ? 'page=' + location.pageNumber : location.pdfOpenParams.substring(1),
page: this.linkService.page,
first: location.pageNumber
first: location.pageNumber,
rotation: location.rotation
};
if (this._popStateInProgress) {
return;
@ -328,11 +338,13 @@ var PDFHistory = function () { @@ -328,11 +338,13 @@ var PDFHistory = function () {
var _parseCurrentHash2 = parseCurrentHash(this.linkService),
hash = _parseCurrentHash2.hash,
page = _parseCurrentHash2.page;
page = _parseCurrentHash2.page,
rotation = _parseCurrentHash2.rotation;
this._pushOrReplaceState({
hash: hash,
page: page
page: page,
rotation: rotation
}, true);
return;
}
@ -352,6 +364,9 @@ var PDFHistory = function () { @@ -352,6 +364,9 @@ var PDFHistory = function () {
}
var destination = state.destination;
this._updateInternalState(destination, state.uid, true);
if ((0, _ui_utils.isValidRotation)(destination.rotation)) {
this.linkService.rotation = destination.rotation;
}
if (destination.dest) {
this.linkService.navigateTo(destination.dest);
} else if (destination.hash) {

14
lib/web/pdf_link_service.js

@ -302,6 +302,14 @@ var PDFLinkService = function () { @@ -302,6 +302,14 @@ var PDFLinkService = function () {
set: function set(value) {
this.pdfViewer.currentPageNumber = value;
}
}, {
key: 'rotation',
get: function get() {
return this.pdfViewer.pagesRotation;
},
set: function set(value) {
this.pdfViewer.pagesRotation = value;
}
}]);
return PDFLinkService;
@ -399,6 +407,12 @@ var SimpleLinkService = function () { @@ -399,6 +407,12 @@ var SimpleLinkService = function () {
return 0;
},
set: function set(value) {}
}, {
key: 'rotation',
get: function get() {
return 0;
},
set: function set(value) {}
}]);
return SimpleLinkService;

5
lib/web/pdf_thumbnail_viewer.js

@ -201,12 +201,15 @@ var PDFThumbnailViewer = function () { @@ -201,12 +201,15 @@ var PDFThumbnailViewer = function () {
return this._pagesRotation;
},
set: function set(rotation) {
if (!(typeof rotation === 'number' && rotation % 90 === 0)) {
if (!(0, _ui_utils.isValidRotation)(rotation)) {
throw new Error('Invalid thumbnails rotation angle.');
}
if (!this.pdfDocument) {
return;
}
if (this._pagesRotation === rotation) {
return;
}
this._pagesRotation = rotation;
for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
this._thumbnails[i].update(rotation);

16
lib/web/pdf_viewer.js

@ -502,6 +502,7 @@ var PDFViewer = function () { @@ -502,6 +502,7 @@ var PDFViewer = function () {
scale: normalizedScaleValue,
top: intTop,
left: intLeft,
rotation: this._pagesRotation,
pdfOpenParams: pdfOpenParams
};
}
@ -764,18 +765,29 @@ var PDFViewer = function () { @@ -764,18 +765,29 @@ var PDFViewer = function () {
return this._pagesRotation;
},
set: function set(rotation) {
if (!(typeof rotation === 'number' && rotation % 90 === 0)) {
if (!(0, _ui_utils.isValidRotation)(rotation)) {
throw new Error('Invalid pages rotation angle.');
}
if (!this.pdfDocument) {
return;
}
if (this._pagesRotation === rotation) {
return;
}
this._pagesRotation = rotation;
var pageNumber = this._currentPageNumber;
for (var i = 0, ii = this._pages.length; i < ii; i++) {
var pageView = this._pages[i];
pageView.update(pageView.scale, rotation);
}
this._setScale(this._currentScaleValue, true);
if (this._currentScaleValue) {
this._setScale(this._currentScaleValue, true);
}
this.eventBus.dispatch('rotationchanging', {
source: this,
pagesRotation: rotation,
pageNumber: pageNumber
});
if (this.defaultRenderingQueue) {
this.update();
}

6
lib/web/ui_utils.js

@ -17,7 +17,7 @@ @@ -17,7 +17,7 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.waitOnEventOrTimeout = exports.WaitOnType = exports.localized = exports.animationStarted = exports.normalizeWheelEventDelta = exports.binarySearchFirstItem = exports.watchScroll = exports.scrollIntoView = exports.getOutputScale = exports.approximateFraction = exports.roundToDivide = exports.getVisibleElements = exports.parseQueryString = exports.noContextMenuHandler = exports.getPDFFileNameFromURL = exports.ProgressBar = exports.EventBus = exports.NullL10n = exports.mozL10n = exports.RendererType = exports.cloneObj = exports.VERTICAL_PADDING = exports.SCROLLBAR_PADDING = exports.MAX_AUTO_SCALE = exports.UNKNOWN_SCALE = exports.MAX_SCALE = exports.MIN_SCALE = exports.DEFAULT_SCALE = exports.DEFAULT_SCALE_VALUE = exports.CSS_UNITS = undefined;
exports.waitOnEventOrTimeout = exports.WaitOnType = exports.localized = exports.animationStarted = exports.normalizeWheelEventDelta = exports.binarySearchFirstItem = exports.watchScroll = exports.scrollIntoView = exports.getOutputScale = exports.approximateFraction = exports.roundToDivide = exports.getVisibleElements = exports.parseQueryString = exports.noContextMenuHandler = exports.getPDFFileNameFromURL = exports.ProgressBar = exports.EventBus = exports.NullL10n = exports.mozL10n = exports.RendererType = exports.cloneObj = exports.isValidRotation = exports.VERTICAL_PADDING = exports.SCROLLBAR_PADDING = exports.MAX_AUTO_SCALE = exports.UNKNOWN_SCALE = exports.MAX_SCALE = exports.MIN_SCALE = exports.DEFAULT_SCALE = exports.DEFAULT_SCALE_VALUE = exports.CSS_UNITS = undefined;
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
@ -317,6 +317,9 @@ function normalizeWheelEventDelta(evt) { @@ -317,6 +317,9 @@ function normalizeWheelEventDelta(evt) {
}
return delta;
}
function isValidRotation(angle) {
return Number.isInteger(angle) && angle % 90 === 0;
}
function cloneObj(obj) {
var result = Object.create(null);
for (var i in obj) {
@ -502,6 +505,7 @@ exports.UNKNOWN_SCALE = UNKNOWN_SCALE; @@ -502,6 +505,7 @@ exports.UNKNOWN_SCALE = UNKNOWN_SCALE;
exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE;
exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;
exports.VERTICAL_PADDING = VERTICAL_PADDING;
exports.isValidRotation = isValidRotation;
exports.cloneObj = cloneObj;
exports.RendererType = RendererType;
exports.mozL10n = mozL10n;

2
package.json

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

65
web/pdf_viewer.js

@ -113,7 +113,7 @@ module.exports = pdfjsLib; @@ -113,7 +113,7 @@ module.exports = pdfjsLib;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.waitOnEventOrTimeout = exports.WaitOnType = exports.localized = exports.animationStarted = exports.normalizeWheelEventDelta = exports.binarySearchFirstItem = exports.watchScroll = exports.scrollIntoView = exports.getOutputScale = exports.approximateFraction = exports.roundToDivide = exports.getVisibleElements = exports.parseQueryString = exports.noContextMenuHandler = exports.getPDFFileNameFromURL = exports.ProgressBar = exports.EventBus = exports.NullL10n = exports.mozL10n = exports.RendererType = exports.cloneObj = exports.VERTICAL_PADDING = exports.SCROLLBAR_PADDING = exports.MAX_AUTO_SCALE = exports.UNKNOWN_SCALE = exports.MAX_SCALE = exports.MIN_SCALE = exports.DEFAULT_SCALE = exports.DEFAULT_SCALE_VALUE = exports.CSS_UNITS = undefined;
exports.waitOnEventOrTimeout = exports.WaitOnType = exports.localized = exports.animationStarted = exports.normalizeWheelEventDelta = exports.binarySearchFirstItem = exports.watchScroll = exports.scrollIntoView = exports.getOutputScale = exports.approximateFraction = exports.roundToDivide = exports.getVisibleElements = exports.parseQueryString = exports.noContextMenuHandler = exports.getPDFFileNameFromURL = exports.ProgressBar = exports.EventBus = exports.NullL10n = exports.mozL10n = exports.RendererType = exports.cloneObj = exports.isValidRotation = exports.VERTICAL_PADDING = exports.SCROLLBAR_PADDING = exports.MAX_AUTO_SCALE = exports.UNKNOWN_SCALE = exports.MAX_SCALE = exports.MIN_SCALE = exports.DEFAULT_SCALE = exports.DEFAULT_SCALE_VALUE = exports.CSS_UNITS = undefined;
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
@ -413,6 +413,9 @@ function normalizeWheelEventDelta(evt) { @@ -413,6 +413,9 @@ function normalizeWheelEventDelta(evt) {
}
return delta;
}
function isValidRotation(angle) {
return Number.isInteger(angle) && angle % 90 === 0;
}
function cloneObj(obj) {
var result = Object.create(null);
for (var i in obj) {
@ -598,6 +601,7 @@ exports.UNKNOWN_SCALE = UNKNOWN_SCALE; @@ -598,6 +601,7 @@ exports.UNKNOWN_SCALE = UNKNOWN_SCALE;
exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE;
exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;
exports.VERTICAL_PADDING = VERTICAL_PADDING;
exports.isValidRotation = isValidRotation;
exports.cloneObj = cloneObj;
exports.RendererType = RendererType;
exports.mozL10n = mozL10n;
@ -1037,6 +1041,14 @@ var PDFLinkService = function () { @@ -1037,6 +1041,14 @@ var PDFLinkService = function () {
set: function set(value) {
this.pdfViewer.currentPageNumber = value;
}
}, {
key: 'rotation',
get: function get() {
return this.pdfViewer.pagesRotation;
},
set: function set(value) {
this.pdfViewer.pagesRotation = value;
}
}]);
return PDFLinkService;
@ -1134,6 +1146,12 @@ var SimpleLinkService = function () { @@ -1134,6 +1146,12 @@ var SimpleLinkService = function () {
return 0;
},
set: function set(value) {}
}, {
key: 'rotation',
get: function get() {
return 0;
},
set: function set(value) {}
}]);
return SimpleLinkService;
@ -2794,6 +2812,7 @@ var PDFViewer = function () { @@ -2794,6 +2812,7 @@ var PDFViewer = function () {
scale: normalizedScaleValue,
top: intTop,
left: intLeft,
rotation: this._pagesRotation,
pdfOpenParams: pdfOpenParams
};
}
@ -3056,18 +3075,29 @@ var PDFViewer = function () { @@ -3056,18 +3075,29 @@ var PDFViewer = function () {
return this._pagesRotation;
},
set: function set(rotation) {
if (!(typeof rotation === 'number' && rotation % 90 === 0)) {
if (!(0, _ui_utils.isValidRotation)(rotation)) {
throw new Error('Invalid pages rotation angle.');
}
if (!this.pdfDocument) {
return;
}
if (this._pagesRotation === rotation) {
return;
}
this._pagesRotation = rotation;
var pageNumber = this._currentPageNumber;
for (var i = 0, ii = this._pages.length; i < ii; i++) {
var pageView = this._pages[i];
pageView.update(pageView.scale, rotation);
}
this._setScale(this._currentScaleValue, true);
if (this._currentScaleValue) {
this._setScale(this._currentScaleValue, true);
}
this.eventBus.dispatch('rotationchanging', {
source: this,
pagesRotation: rotation,
pageNumber: pageNumber
});
if (this.defaultRenderingQueue) {
this.update();
}
@ -3144,7 +3174,8 @@ function parseCurrentHash(linkService) { @@ -3144,7 +3174,8 @@ function parseCurrentHash(linkService) {
}
return {
hash: hash,
page: page
page: page,
rotation: linkService.rotation
};
}
@ -3161,6 +3192,7 @@ var PDFHistory = function () { @@ -3161,6 +3192,7 @@ var PDFHistory = function () {
this.eventBus = eventBus || (0, _dom_events.getGlobalEventBus)();
this.initialized = false;
this.initialBookmark = null;
this.initialRotation = null;
this._boundEvents = Object.create(null);
this._isViewerInPresentationMode = false;
this._isPagesLoaded = false;
@ -3189,6 +3221,7 @@ var PDFHistory = function () { @@ -3189,6 +3221,7 @@ var PDFHistory = function () {
var state = window.history.state;
this.initialized = true;
this.initialBookmark = null;
this.initialRotation = null;
this._popStateInProgress = false;
this._blockHashChange = 0;
this._currentHash = getCurrentHash();
@ -3199,7 +3232,8 @@ var PDFHistory = function () { @@ -3199,7 +3232,8 @@ var PDFHistory = function () {
if (!this._isValidState(state) || resetHistory) {
var _parseCurrentHash = parseCurrentHash(this.linkService),
hash = _parseCurrentHash.hash,
page = _parseCurrentHash.page;
page = _parseCurrentHash.page,
rotation = _parseCurrentHash.rotation;
if (!hash || reInitialized || resetHistory) {
this._pushOrReplaceState(null, true);
@ -3207,12 +3241,16 @@ var PDFHistory = function () { @@ -3207,12 +3241,16 @@ var PDFHistory = function () {
}
this._pushOrReplaceState({
hash: hash,
page: page
page: page,
rotation: rotation
}, true);
return;
}
var destination = state.destination;
this._updateInternalState(destination, state.uid, true);
if (destination.rotation !== undefined) {
this.initialRotation = destination.rotation;
}
if (destination.dest) {
this.initialBookmark = JSON.stringify(destination.dest);
this._destination.page = null;
@ -3255,7 +3293,8 @@ var PDFHistory = function () { @@ -3255,7 +3293,8 @@ var PDFHistory = function () {
this._pushOrReplaceState({
dest: explicitDest,
hash: hash,
page: pageNumber
page: pageNumber,
rotation: this.linkService.rotation
}, forceReplace);
if (!this._popStateInProgress) {
this._popStateInProgress = true;
@ -3396,7 +3435,8 @@ var PDFHistory = function () { @@ -3396,7 +3435,8 @@ var PDFHistory = function () {
this._position = {
hash: this._isViewerInPresentationMode ? 'page=' + location.pageNumber : location.pdfOpenParams.substring(1),
page: this.linkService.page,
first: location.pageNumber
first: location.pageNumber,
rotation: location.rotation
};
if (this._popStateInProgress) {
return;
@ -3428,11 +3468,13 @@ var PDFHistory = function () { @@ -3428,11 +3468,13 @@ var PDFHistory = function () {
var _parseCurrentHash2 = parseCurrentHash(this.linkService),
hash = _parseCurrentHash2.hash,
page = _parseCurrentHash2.page;
page = _parseCurrentHash2.page,
rotation = _parseCurrentHash2.rotation;
this._pushOrReplaceState({
hash: hash,
page: page
page: page,
rotation: rotation
}, true);
return;
}
@ -3452,6 +3494,9 @@ var PDFHistory = function () { @@ -3452,6 +3494,9 @@ var PDFHistory = function () {
}
var destination = state.destination;
this._updateInternalState(destination, state.uid, true);
if ((0, _ui_utils.isValidRotation)(destination.rotation)) {
this.linkService.rotation = destination.rotation;
}
if (destination.dest) {
this.linkService.navigateTo(destination.dest);
} else if (destination.hash) {

2
web/pdf_viewer.js.map

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