pdfjs-dist
Advanced tools
Comparing version 2.0.457 to 2.0.466
{ | ||
"name": "pdfjs-dist", | ||
"version": "2.0.457", | ||
"version": "2.0.466", | ||
"main": [ | ||
@@ -5,0 +5,0 @@ "build/pdf.js", |
@@ -226,3 +226,3 @@ /** | ||
var apiVersion = docParams.apiVersion; | ||
var workerVersion = '2.0.457'; | ||
var workerVersion = '2.0.466'; | ||
if (apiVersion !== null && apiVersion !== workerVersion) { | ||
@@ -229,0 +229,0 @@ throw new Error('The API version "' + apiVersion + '" does not match ' + ('the Worker version "' + workerVersion + '".')); |
@@ -235,3 +235,3 @@ /** | ||
docId: docId, | ||
apiVersion: '2.0.457', | ||
apiVersion: '2.0.466', | ||
source: { | ||
@@ -1654,4 +1654,4 @@ data: source.data, | ||
{ | ||
exports.version = version = '2.0.457'; | ||
exports.build = build = '5c1a16ba'; | ||
exports.version = version = '2.0.466'; | ||
exports.build = build = 'a8e9f6cc'; | ||
} | ||
@@ -1658,0 +1658,0 @@ exports.getDocument = getDocument; |
@@ -24,4 +24,4 @@ /** | ||
var pdfjsVersion = '2.0.457'; | ||
var pdfjsBuild = '5c1a16ba'; | ||
var pdfjsVersion = '2.0.466'; | ||
var pdfjsBuild = 'a8e9f6cc'; | ||
var pdfjsSharedUtil = require('./shared/util.js'); | ||
@@ -28,0 +28,0 @@ var pdfjsDisplayAPI = require('./display/api.js'); |
@@ -24,5 +24,5 @@ /** | ||
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; |
@@ -229,2 +229,20 @@ /** | ||
}); | ||
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 () { | ||
@@ -231,0 +249,0 @@ var eventBus = void 0; |
@@ -78,5 +78,2 @@ /** | ||
} | ||
function isPortraitOrientation(size) { | ||
return size.width <= size.height; | ||
} | ||
@@ -395,4 +392,3 @@ var BaseViewer = function () { | ||
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); | ||
@@ -680,5 +676,5 @@ break; | ||
} | ||
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; | ||
@@ -685,0 +681,0 @@ } |
@@ -178,2 +178,7 @@ /** | ||
_createClass(MozL10n, [{ | ||
key: 'getLanguage', | ||
value: function getLanguage() { | ||
return Promise.resolve(this.mozL10n.getLanguage()); | ||
} | ||
}, { | ||
key: 'getDirection', | ||
@@ -180,0 +185,0 @@ value: function getDirection() { |
@@ -50,2 +50,9 @@ /** | ||
_createClass(GenericL10n, [{ | ||
key: 'getLanguage', | ||
value: function getLanguage() { | ||
return this._ready.then(function (l10n) { | ||
return l10n.getLanguage(); | ||
}); | ||
} | ||
}, { | ||
key: 'getDirection', | ||
@@ -52,0 +59,0 @@ value: function getDirection() { |
@@ -162,2 +162,5 @@ /** | ||
_createClass(IL10n, [{ | ||
key: 'getLanguage', | ||
value: function getLanguage() {} | ||
}, { | ||
key: 'getDirection', | ||
@@ -164,0 +167,0 @@ value: function getDirection() {} |
@@ -40,2 +40,16 @@ /** | ||
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]; | ||
} | ||
@@ -69,3 +83,10 @@ var PDFDocumentProperties = function () { | ||
}); | ||
eventBus.on('rotationchanging', function (evt) { | ||
_this._pagesRotation = evt.pagesRotation; | ||
}); | ||
} | ||
this._isNonMetricLocale = true; | ||
l10n.getLanguage().then(function (locale) { | ||
_this._isNonMetricLocale = NON_METRIC_LOCALES.includes(locale); | ||
}); | ||
} | ||
@@ -88,3 +109,4 @@ | ||
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(); | ||
@@ -99,3 +121,3 @@ return; | ||
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); | ||
})]); | ||
@@ -110,3 +132,3 @@ }).then(function (_ref3) { | ||
modDate = _ref4[5], | ||
pageSizes = _ref4[6]; | ||
pageSize = _ref4[6]; | ||
@@ -126,5 +148,5 @@ freezeFieldData({ | ||
'pageCount': _this2.pdfDocument.numPages, | ||
'pageSizeInch': pageSizes.inch, | ||
'pageSizeMM': pageSizes.mm, | ||
'_currentPageNumber': currentPageNumber | ||
'pageSize': pageSize, | ||
'_currentPageNumber': currentPageNumber, | ||
'_pagesRotation': pagesRotation | ||
}); | ||
@@ -184,2 +206,3 @@ _this2._updateUI(); | ||
this._currentPageNumber = 1; | ||
this._pagesRotation = 0; | ||
} | ||
@@ -226,23 +249,64 @@ }, { | ||
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; | ||
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 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] | ||
}; | ||
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}})'); | ||
}); | ||
@@ -249,0 +313,0 @@ } |
@@ -51,4 +51,4 @@ /** | ||
var pdfjsVersion = '2.0.457'; | ||
var pdfjsBuild = '5c1a16ba'; | ||
var pdfjsVersion = '2.0.466'; | ||
var pdfjsBuild = 'a8e9f6cc'; | ||
exports.PDFViewer = _pdf_viewer.PDFViewer; | ||
@@ -55,0 +55,0 @@ exports.PDFSinglePageViewer = _pdf_single_page_viewer.PDFSinglePageViewer; |
@@ -27,3 +27,3 @@ /** | ||
}); | ||
exports.waitOnEventOrTimeout = exports.WaitOnType = exports.animationStarted = exports.normalizeWheelEventDelta = exports.binarySearchFirstItem = exports.watchScroll = exports.scrollIntoView = exports.getOutputScale = exports.approximateFraction = exports.getPageSizeInches = exports.roundToDivide = exports.getVisibleElements = exports.parseQueryString = exports.noContextMenuHandler = exports.getPDFFileNameFromURL = exports.ProgressBar = exports.EventBus = exports.NullL10n = exports.TextLayerMode = exports.RendererType = exports.PresentationModeState = exports.cloneObj = exports.isFileSchema = 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; | ||
exports.waitOnEventOrTimeout = exports.WaitOnType = exports.animationStarted = exports.normalizeWheelEventDelta = exports.binarySearchFirstItem = exports.watchScroll = exports.scrollIntoView = exports.getOutputScale = exports.approximateFraction = exports.getPageSizeInches = exports.roundToDivide = exports.getVisibleElements = exports.parseQueryString = exports.noContextMenuHandler = exports.getPDFFileNameFromURL = exports.ProgressBar = exports.EventBus = exports.NullL10n = exports.TextLayerMode = exports.RendererType = exports.PresentationModeState = exports.cloneObj = exports.isFileSchema = exports.isPortraitOrientation = 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; | ||
@@ -73,2 +73,5 @@ 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; }; }(); | ||
var NullL10n = { | ||
getLanguage: function getLanguage() { | ||
return Promise.resolve('en-us'); | ||
}, | ||
getDirection: function getDirection() { | ||
@@ -366,2 +369,5 @@ return Promise.resolve('ltr'); | ||
} | ||
function isPortraitOrientation(size) { | ||
return size.width <= size.height; | ||
} | ||
function cloneObj(obj) { | ||
@@ -551,2 +557,3 @@ var result = Object.create(null); | ||
exports.isValidRotation = isValidRotation; | ||
exports.isPortraitOrientation = isPortraitOrientation; | ||
exports.isFileSchema = isFileSchema; | ||
@@ -553,0 +560,0 @@ exports.cloneObj = cloneObj; |
{ | ||
"name": "pdfjs-dist", | ||
"version": "2.0.457", | ||
"version": "2.0.466", | ||
"main": "build/pdf.js", | ||
@@ -5,0 +5,0 @@ "description": "Generic build of Mozilla's PDF.js library.", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11063973
138794