mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 17:30:09 +02:00
Convert a number of import * as pdfjsLib from 'pdfjs-web/pdfjs';
cases to only specify the necessary imports
Rather than always importing everything from the `web/pdfjs.js`, similar to all other imports we can just choose what we actually need.
This commit is contained in:
parent
3b35c15d42
commit
b2c3f8f081
14 changed files with 89 additions and 86 deletions
|
@ -13,7 +13,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as pdfjsLib from 'pdfjs-web/pdfjs';
|
import { AnnotationLayer } from 'pdfjs-web/pdfjs';
|
||||||
import { mozL10n } from 'pdfjs-web/ui_utils';
|
import { mozL10n } from 'pdfjs-web/ui_utils';
|
||||||
import { SimpleLinkService } from 'pdfjs-web/pdf_link_service';
|
import { SimpleLinkService } from 'pdfjs-web/pdf_link_service';
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ var AnnotationLayerBuilder = (function AnnotationLayerBuilderClosure() {
|
||||||
if (self.div) {
|
if (self.div) {
|
||||||
// If an annotationLayer already exists, refresh its children's
|
// If an annotationLayer already exists, refresh its children's
|
||||||
// transformation matrices.
|
// transformation matrices.
|
||||||
pdfjsLib.AnnotationLayer.update(parameters);
|
AnnotationLayer.update(parameters);
|
||||||
} else {
|
} else {
|
||||||
// Create an annotation layer div and render the annotations
|
// Create an annotation layer div and render the annotations
|
||||||
// if there is at least one annotation.
|
// if there is at least one annotation.
|
||||||
|
@ -85,7 +85,7 @@ var AnnotationLayerBuilder = (function AnnotationLayerBuilderClosure() {
|
||||||
self.pageDiv.appendChild(self.div);
|
self.pageDiv.appendChild(self.div);
|
||||||
parameters.div = self.div;
|
parameters.div = self.div;
|
||||||
|
|
||||||
pdfjsLib.AnnotationLayer.render(parameters);
|
AnnotationLayer.render(parameters);
|
||||||
if (typeof mozL10n !== 'undefined') {
|
if (typeof mozL10n !== 'undefined') {
|
||||||
mozL10n.translate(self.div);
|
mozL10n.translate(self.div);
|
||||||
}
|
}
|
||||||
|
|
53
web/app.js
53
web/app.js
|
@ -14,12 +14,16 @@
|
||||||
*/
|
*/
|
||||||
/* globals PDFBug, Stats */
|
/* globals PDFBug, Stats */
|
||||||
|
|
||||||
import * as pdfjsLib from 'pdfjs-web/pdfjs';
|
|
||||||
import {
|
import {
|
||||||
animationStarted, DEFAULT_SCALE_VALUE, getPDFFileNameFromURL, localized,
|
animationStarted, DEFAULT_SCALE_VALUE, getPDFFileNameFromURL, localized,
|
||||||
MAX_SCALE, MIN_SCALE, mozL10n, noContextMenuHandler, normalizeWheelEventDelta,
|
MAX_SCALE, MIN_SCALE, mozL10n, noContextMenuHandler, normalizeWheelEventDelta,
|
||||||
parseQueryString, ProgressBar, RendererType, UNKNOWN_SCALE
|
parseQueryString, ProgressBar, RendererType, UNKNOWN_SCALE
|
||||||
} from 'pdfjs-web/ui_utils';
|
} from 'pdfjs-web/ui_utils';
|
||||||
|
import {
|
||||||
|
build, createBlob, getDocument, getFilenameFromUrl, InvalidPDFException,
|
||||||
|
MissingPDFException, OPS, PDFJS, shadow, UnexpectedResponseException,
|
||||||
|
UNSUPPORTED_FEATURES, version,
|
||||||
|
} from 'pdfjs-web/pdfjs';
|
||||||
import {
|
import {
|
||||||
PDFRenderingQueue, RenderingStates
|
PDFRenderingQueue, RenderingStates
|
||||||
} from 'pdfjs-web/pdf_rendering_queue';
|
} from 'pdfjs-web/pdf_rendering_queue';
|
||||||
|
@ -140,7 +144,6 @@ var PDFViewerApplication = {
|
||||||
// called once when the document is loaded
|
// called once when the document is loaded
|
||||||
initialize: function pdfViewInitialize(appConfig) {
|
initialize: function pdfViewInitialize(appConfig) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var PDFJS = pdfjsLib.PDFJS;
|
|
||||||
|
|
||||||
Preferences.initialize();
|
Preferences.initialize();
|
||||||
this.preferences = Preferences;
|
this.preferences = Preferences;
|
||||||
|
@ -179,7 +182,6 @@ var PDFViewerApplication = {
|
||||||
*/
|
*/
|
||||||
_readPreferences: function () {
|
_readPreferences: function () {
|
||||||
var self = this;
|
var self = this;
|
||||||
var PDFJS = pdfjsLib.PDFJS;
|
|
||||||
|
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
Preferences.get('enableWebGL').then(function resolved(value) {
|
Preferences.get('enableWebGL').then(function resolved(value) {
|
||||||
|
@ -445,11 +447,11 @@ var PDFViewerApplication = {
|
||||||
support = false;
|
support = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (support && pdfjsLib.PDFJS.disableFullscreen === true) {
|
if (support && PDFJS.disableFullscreen === true) {
|
||||||
support = false;
|
support = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return pdfjsLib.shadow(this, 'supportsFullscreen', support);
|
return shadow(this, 'supportsFullscreen', support);
|
||||||
},
|
},
|
||||||
|
|
||||||
get supportsIntegratedFind() {
|
get supportsIntegratedFind() {
|
||||||
|
@ -467,7 +469,7 @@ var PDFViewerApplication = {
|
||||||
get loadingBar() {
|
get loadingBar() {
|
||||||
var bar = new ProgressBar('#loadingBar', {});
|
var bar = new ProgressBar('#loadingBar', {});
|
||||||
|
|
||||||
return pdfjsLib.shadow(this, 'loadingBar', bar);
|
return shadow(this, 'loadingBar', bar);
|
||||||
},
|
},
|
||||||
|
|
||||||
get supportedMouseWheelZoomModifierKeys() {
|
get supportedMouseWheelZoomModifierKeys() {
|
||||||
|
@ -517,7 +519,7 @@ var PDFViewerApplication = {
|
||||||
var title = getPDFFileNameFromURL(url, '');
|
var title = getPDFFileNameFromURL(url, '');
|
||||||
if (!title) {
|
if (!title) {
|
||||||
try {
|
try {
|
||||||
title = decodeURIComponent(pdfjsLib.getFilenameFromUrl(url)) || url;
|
title = decodeURIComponent(getFilenameFromUrl(url)) || url;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// decodeURIComponent may throw URIError,
|
// decodeURIComponent may throw URIError,
|
||||||
// fall back to using the unprocessed url in that case
|
// fall back to using the unprocessed url in that case
|
||||||
|
@ -632,7 +634,7 @@ var PDFViewerApplication = {
|
||||||
var self = this;
|
var self = this;
|
||||||
self.downloadComplete = false;
|
self.downloadComplete = false;
|
||||||
|
|
||||||
var loadingTask = pdfjsLib.getDocument(parameters);
|
var loadingTask = getDocument(parameters);
|
||||||
this.pdfLoadingTask = loadingTask;
|
this.pdfLoadingTask = loadingTask;
|
||||||
|
|
||||||
loadingTask.onPassword = function passwordNeeded(updateCallback, reason) {
|
loadingTask.onPassword = function passwordNeeded(updateCallback, reason) {
|
||||||
|
@ -656,15 +658,15 @@ var PDFViewerApplication = {
|
||||||
var loadingErrorMessage = mozL10n.get('loading_error', null,
|
var loadingErrorMessage = mozL10n.get('loading_error', null,
|
||||||
'An error occurred while loading the PDF.');
|
'An error occurred while loading the PDF.');
|
||||||
|
|
||||||
if (exception instanceof pdfjsLib.InvalidPDFException) {
|
if (exception instanceof InvalidPDFException) {
|
||||||
// change error message also for other builds
|
// change error message also for other builds
|
||||||
loadingErrorMessage = mozL10n.get('invalid_file_error', null,
|
loadingErrorMessage = mozL10n.get('invalid_file_error', null,
|
||||||
'Invalid or corrupted PDF file.');
|
'Invalid or corrupted PDF file.');
|
||||||
} else if (exception instanceof pdfjsLib.MissingPDFException) {
|
} else if (exception instanceof MissingPDFException) {
|
||||||
// special message for missing PDF's
|
// special message for missing PDF's
|
||||||
loadingErrorMessage = mozL10n.get('missing_file_error', null,
|
loadingErrorMessage = mozL10n.get('missing_file_error', null,
|
||||||
'Missing PDF file.');
|
'Missing PDF file.');
|
||||||
} else if (exception instanceof pdfjsLib.UnexpectedResponseException) {
|
} else if (exception instanceof UnexpectedResponseException) {
|
||||||
loadingErrorMessage = mozL10n.get('unexpected_response_error', null,
|
loadingErrorMessage = mozL10n.get('unexpected_response_error', null,
|
||||||
'Unexpected server response.');
|
'Unexpected server response.');
|
||||||
}
|
}
|
||||||
|
@ -707,7 +709,7 @@ var PDFViewerApplication = {
|
||||||
|
|
||||||
this.pdfDocument.getData().then(
|
this.pdfDocument.getData().then(
|
||||||
function getDataSuccess(data) {
|
function getDataSuccess(data) {
|
||||||
var blob = pdfjsLib.createBlob(data, 'application/pdf');
|
var blob = createBlob(data, 'application/pdf');
|
||||||
downloadManager.download(blob, url, filename);
|
downloadManager.download(blob, url, filename);
|
||||||
},
|
},
|
||||||
downloadByUrl // Error occurred try downloading with just the url.
|
downloadByUrl // Error occurred try downloading with just the url.
|
||||||
|
@ -744,7 +746,7 @@ var PDFViewerApplication = {
|
||||||
*/
|
*/
|
||||||
error: function pdfViewError(message, moreInfo) {
|
error: function pdfViewError(message, moreInfo) {
|
||||||
var moreInfoText = mozL10n.get('error_version_info',
|
var moreInfoText = mozL10n.get('error_version_info',
|
||||||
{version: pdfjsLib.version || '?', build: pdfjsLib.build || '?'},
|
{version: version || '?', build: build || '?'},
|
||||||
'PDF.js v{{version}} (build: {{build}})') + '\n';
|
'PDF.js v{{version}} (build: {{build}})') + '\n';
|
||||||
if (moreInfo) {
|
if (moreInfo) {
|
||||||
moreInfoText +=
|
moreInfoText +=
|
||||||
|
@ -822,7 +824,7 @@ var PDFViewerApplication = {
|
||||||
// the loading bar will not be completely filled, nor will it be hidden.
|
// the loading bar will not be completely filled, nor will it be hidden.
|
||||||
// To prevent displaying a partially filled loading bar permanently, we
|
// To prevent displaying a partially filled loading bar permanently, we
|
||||||
// hide it when no data has been loaded during a certain amount of time.
|
// hide it when no data has been loaded during a certain amount of time.
|
||||||
if (pdfjsLib.PDFJS.disableAutoFetch && percent) {
|
if (PDFJS.disableAutoFetch && percent) {
|
||||||
if (this.disableAutoFetchLoadingBarTimeout) {
|
if (this.disableAutoFetchLoadingBarTimeout) {
|
||||||
clearTimeout(this.disableAutoFetchLoadingBarTimeout);
|
clearTimeout(this.disableAutoFetchLoadingBarTimeout);
|
||||||
this.disableAutoFetchLoadingBarTimeout = null;
|
this.disableAutoFetchLoadingBarTimeout = null;
|
||||||
|
@ -885,7 +887,7 @@ var PDFViewerApplication = {
|
||||||
|
|
||||||
self.loadingBar.setWidth(self.appConfig.viewerContainer);
|
self.loadingBar.setWidth(self.appConfig.viewerContainer);
|
||||||
|
|
||||||
if (!pdfjsLib.PDFJS.disableHistory && !self.isViewerEmbedded) {
|
if (!PDFJS.disableHistory && !self.isViewerEmbedded) {
|
||||||
// The browsing history is only enabled when the viewer is standalone,
|
// The browsing history is only enabled when the viewer is standalone,
|
||||||
// i.e. not when it is embedded in a web page.
|
// i.e. not when it is embedded in a web page.
|
||||||
if (!self.viewerPrefs['showPreviousViewOnLoad']) {
|
if (!self.viewerPrefs['showPreviousViewOnLoad']) {
|
||||||
|
@ -989,7 +991,7 @@ var PDFViewerApplication = {
|
||||||
pdfDocument.getJavaScript().then(function(javaScript) {
|
pdfDocument.getJavaScript().then(function(javaScript) {
|
||||||
if (javaScript.length) {
|
if (javaScript.length) {
|
||||||
console.warn('Warning: JavaScript is not supported');
|
console.warn('Warning: JavaScript is not supported');
|
||||||
self.fallback(pdfjsLib.UNSUPPORTED_FEATURES.javaScript);
|
self.fallback(UNSUPPORTED_FEATURES.javaScript);
|
||||||
}
|
}
|
||||||
// Hack to support auto printing.
|
// Hack to support auto printing.
|
||||||
var regex = /\bprint\s*\(/;
|
var regex = /\bprint\s*\(/;
|
||||||
|
@ -1024,8 +1026,8 @@ var PDFViewerApplication = {
|
||||||
console.log('PDF ' + pdfDocument.fingerprint + ' [' +
|
console.log('PDF ' + pdfDocument.fingerprint + ' [' +
|
||||||
info.PDFFormatVersion + ' ' + (info.Producer || '-').trim() +
|
info.PDFFormatVersion + ' ' + (info.Producer || '-').trim() +
|
||||||
' / ' + (info.Creator || '-').trim() + ']' +
|
' / ' + (info.Creator || '-').trim() + ']' +
|
||||||
' (PDF.js: ' + (pdfjsLib.version || '-') +
|
' (PDF.js: ' + (version || '-') +
|
||||||
(!pdfjsLib.PDFJS.disableWebGL ? ' [WebGL]' : '') + ')');
|
(!PDFJS.disableWebGL ? ' [WebGL]' : '') + ')');
|
||||||
|
|
||||||
var pdfTitle;
|
var pdfTitle;
|
||||||
if (metadata && metadata.has('dc:title')) {
|
if (metadata && metadata.has('dc:title')) {
|
||||||
|
@ -1046,7 +1048,7 @@ var PDFViewerApplication = {
|
||||||
|
|
||||||
if (info.IsAcroFormPresent) {
|
if (info.IsAcroFormPresent) {
|
||||||
console.warn('Warning: AcroForm/XFA is not supported');
|
console.warn('Warning: AcroForm/XFA is not supported');
|
||||||
self.fallback(pdfjsLib.UNSUPPORTED_FEATURES.forms);
|
self.fallback(UNSUPPORTED_FEATURES.forms);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof PDFJSDev !== 'undefined' &&
|
if (typeof PDFJSDev !== 'undefined' &&
|
||||||
|
@ -1329,7 +1331,10 @@ function loadAndEnablePDFBug(enabledTabs) {
|
||||||
script.src = appConfig.debuggerScriptPath;
|
script.src = appConfig.debuggerScriptPath;
|
||||||
script.onload = function () {
|
script.onload = function () {
|
||||||
PDFBug.enable(enabledTabs);
|
PDFBug.enable(enabledTabs);
|
||||||
PDFBug.init(pdfjsLib, appConfig.mainContainer);
|
PDFBug.init({
|
||||||
|
PDFJS,
|
||||||
|
OPS,
|
||||||
|
}, appConfig.mainContainer);
|
||||||
resolve();
|
resolve();
|
||||||
};
|
};
|
||||||
script.onerror = function () {
|
script.onerror = function () {
|
||||||
|
@ -1375,8 +1380,6 @@ function webViewerInitialized() {
|
||||||
appConfig.secondaryToolbar.openFileButton.setAttribute('hidden', 'true');
|
appConfig.secondaryToolbar.openFileButton.setAttribute('hidden', 'true');
|
||||||
}
|
}
|
||||||
|
|
||||||
var PDFJS = pdfjsLib.PDFJS;
|
|
||||||
|
|
||||||
if ((typeof PDFJSDev === 'undefined' || !PDFJSDev.test('PRODUCTION')) ||
|
if ((typeof PDFJSDev === 'undefined' || !PDFJSDev.test('PRODUCTION')) ||
|
||||||
PDFViewerApplication.viewerPrefs['pdfBugEnabled']) {
|
PDFViewerApplication.viewerPrefs['pdfBugEnabled']) {
|
||||||
// Special debugging flags in the hash section of the URL.
|
// Special debugging flags in the hash section of the URL.
|
||||||
|
@ -1555,7 +1558,7 @@ function webViewerPageRendered(e) {
|
||||||
thumbnailView.setImage(pageView);
|
thumbnailView.setImage(pageView);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pdfjsLib.PDFJS.pdfBug && Stats.enabled && pageView.stats) {
|
if (PDFJS.pdfBug && Stats.enabled && pageView.stats) {
|
||||||
Stats.add(pageNumber, pageView.stats);
|
Stats.add(pageNumber, pageView.stats);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1720,7 +1723,7 @@ if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) {
|
||||||
webViewerFileInputChange = function webViewerFileInputChange(e) {
|
webViewerFileInputChange = function webViewerFileInputChange(e) {
|
||||||
var file = e.fileInput.files[0];
|
var file = e.fileInput.files[0];
|
||||||
|
|
||||||
if (!pdfjsLib.PDFJS.disableCreateObjectURL &&
|
if (!PDFJS.disableCreateObjectURL &&
|
||||||
typeof URL !== 'undefined' && URL.createObjectURL) {
|
typeof URL !== 'undefined' && URL.createObjectURL) {
|
||||||
PDFViewerApplication.open(URL.createObjectURL(file));
|
PDFViewerApplication.open(URL.createObjectURL(file));
|
||||||
} else {
|
} else {
|
||||||
|
@ -1843,7 +1846,7 @@ function webViewerPageChanging(e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// we need to update stats
|
// we need to update stats
|
||||||
if (pdfjsLib.PDFJS.pdfBug && Stats.enabled) {
|
if (PDFJS.pdfBug && Stats.enabled) {
|
||||||
var pageView = PDFViewerApplication.pdfViewer.getPageView(page - 1);
|
var pageView = PDFViewerApplication.pdfViewer.getPageView(page - 1);
|
||||||
if (pageView.stats) {
|
if (pageView.stats) {
|
||||||
Stats.add(page, pageView.stats);
|
Stats.add(page, pageView.stats);
|
||||||
|
|
|
@ -14,9 +14,9 @@
|
||||||
*/
|
*/
|
||||||
/* globals chrome */
|
/* globals chrome */
|
||||||
|
|
||||||
import * as pdfjsLib from 'pdfjs-web/pdfjs';
|
|
||||||
import { DefaultExternalServices, PDFViewerApplication } from 'pdfjs-web/app';
|
import { DefaultExternalServices, PDFViewerApplication } from 'pdfjs-web/app';
|
||||||
import { OverlayManager } from 'pdfjs-web/overlay_manager';
|
import { OverlayManager } from 'pdfjs-web/overlay_manager';
|
||||||
|
import { PDFJS } from 'pdfjs-web/pdfjs';
|
||||||
import { Preferences } from 'pdfjs-web/preferences';
|
import { Preferences } from 'pdfjs-web/preferences';
|
||||||
|
|
||||||
if (typeof PDFJSDev === 'undefined' || !PDFJSDev.test('CHROME')) {
|
if (typeof PDFJSDev === 'undefined' || !PDFJSDev.test('CHROME')) {
|
||||||
|
@ -63,7 +63,7 @@ ChromeCom.resolvePDFFile = function ChromeCom_resolvePDFFile(file, callback) {
|
||||||
file = file.replace(/^drive:/i,
|
file = file.replace(/^drive:/i,
|
||||||
'filesystem:' + location.origin + '/external/');
|
'filesystem:' + location.origin + '/external/');
|
||||||
|
|
||||||
if (/^filesystem:/.test(file) && !pdfjsLib.PDFJS.disableWorker) {
|
if (/^filesystem:/.test(file) && !PDFJS.disableWorker) {
|
||||||
// The security origin of filesystem:-URLs are not preserved when the
|
// The security origin of filesystem:-URLs are not preserved when the
|
||||||
// URL is passed to a Web worker, (http://crbug.com/362061), so we have
|
// URL is passed to a Web worker, (http://crbug.com/362061), so we have
|
||||||
// to create an intermediate blob:-URL as a work-around.
|
// to create an intermediate blob:-URL as a work-around.
|
||||||
|
|
|
@ -13,7 +13,9 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as pdfjsLib from 'pdfjs-web/pdfjs';
|
import {
|
||||||
|
createObjectURL, createValidAbsoluteUrl, PDFJS
|
||||||
|
} from 'pdfjs-web/pdfjs';
|
||||||
import { DefaultExternalServices, PDFViewerApplication } from 'pdfjs-web/app';
|
import { DefaultExternalServices, PDFViewerApplication } from 'pdfjs-web/app';
|
||||||
|
|
||||||
if (typeof PDFJSDev !== 'undefined' && !PDFJSDev.test('CHROME || GENERIC')) {
|
if (typeof PDFJSDev !== 'undefined' && !PDFJSDev.test('CHROME || GENERIC')) {
|
||||||
|
@ -61,7 +63,7 @@ function DownloadManager() {}
|
||||||
|
|
||||||
DownloadManager.prototype = {
|
DownloadManager.prototype = {
|
||||||
downloadUrl: function DownloadManager_downloadUrl(url, filename) {
|
downloadUrl: function DownloadManager_downloadUrl(url, filename) {
|
||||||
if (!pdfjsLib.createValidAbsoluteUrl(url, 'http://example.com')) {
|
if (!createValidAbsoluteUrl(url, 'http://example.com')) {
|
||||||
return; // restricted/invalid URL
|
return; // restricted/invalid URL
|
||||||
}
|
}
|
||||||
download(url + '#pdfjs.action=download', filename);
|
download(url + '#pdfjs.action=download', filename);
|
||||||
|
@ -74,8 +76,8 @@ DownloadManager.prototype = {
|
||||||
filename);
|
filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
var blobUrl = pdfjsLib.createObjectURL(data, contentType,
|
var blobUrl = createObjectURL(data, contentType,
|
||||||
pdfjsLib.PDFJS.disableCreateObjectURL);
|
PDFJS.disableCreateObjectURL);
|
||||||
download(blobUrl, filename);
|
download(blobUrl, filename);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -88,7 +90,7 @@ DownloadManager.prototype = {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pdfjsLib.PDFJS.disableCreateObjectURL) {
|
if (PDFJS.disableCreateObjectURL) {
|
||||||
// URL.createObjectURL is not supported
|
// URL.createObjectURL is not supported
|
||||||
this.downloadUrl(url, filename);
|
this.downloadUrl(url, filename);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -13,9 +13,9 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as pdfjsLib from 'pdfjs-web/pdfjs';
|
|
||||||
import { CSS_UNITS } from 'pdfjs-web/ui_utils';
|
import { CSS_UNITS } from 'pdfjs-web/ui_utils';
|
||||||
import { PDFPrintServiceFactory } from 'pdfjs-web/app';
|
import { PDFPrintServiceFactory } from 'pdfjs-web/app';
|
||||||
|
import { shadow } from 'pdfjs-web/pdfjs';
|
||||||
|
|
||||||
// Creates a placeholder with div and canvas with right size for the page.
|
// Creates a placeholder with div and canvas with right size for the page.
|
||||||
function composePage(pdfDocument, pageNumber, size, printContainer) {
|
function composePage(pdfDocument, pageNumber, size, printContainer) {
|
||||||
|
@ -96,7 +96,7 @@ PDFPrintServiceFactory.instance = {
|
||||||
var canvas = document.createElement('canvas');
|
var canvas = document.createElement('canvas');
|
||||||
var value = 'mozPrintCallback' in canvas;
|
var value = 'mozPrintCallback' in canvas;
|
||||||
|
|
||||||
return pdfjsLib.shadow(this, 'supportsPrinting', value);
|
return shadow(this, 'supportsPrinting', value);
|
||||||
},
|
},
|
||||||
|
|
||||||
createPrintService: function (pdfDocument, pagesOverview, printContainer) {
|
createPrintService: function (pdfDocument, pagesOverview, printContainer) {
|
||||||
|
|
|
@ -13,7 +13,9 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as pdfjsLib from 'pdfjs-web/pdfjs';
|
import {
|
||||||
|
createObjectURL, PDFDataRangeTransport, shadow
|
||||||
|
} from 'pdfjs-web/pdfjs';
|
||||||
import { PDFViewerApplication } from 'pdfjs-web/app';
|
import { PDFViewerApplication } from 'pdfjs-web/app';
|
||||||
import { Preferences } from 'pdfjs-web/preferences';
|
import { Preferences } from 'pdfjs-web/preferences';
|
||||||
|
|
||||||
|
@ -94,7 +96,7 @@ var DownloadManager = (function DownloadManagerClosure() {
|
||||||
|
|
||||||
downloadData: function DownloadManager_downloadData(data, filename,
|
downloadData: function DownloadManager_downloadData(data, filename,
|
||||||
contentType) {
|
contentType) {
|
||||||
var blobUrl = pdfjsLib.createObjectURL(data, contentType, false);
|
var blobUrl = createObjectURL(data, contentType, false);
|
||||||
|
|
||||||
FirefoxCom.request('download', {
|
FirefoxCom.request('download', {
|
||||||
blobUrl: blobUrl,
|
blobUrl: blobUrl,
|
||||||
|
@ -168,10 +170,10 @@ Preferences._readFromStorage = function (prefObj) {
|
||||||
})();
|
})();
|
||||||
|
|
||||||
function FirefoxComDataRangeTransport(length, initialData) {
|
function FirefoxComDataRangeTransport(length, initialData) {
|
||||||
pdfjsLib.PDFDataRangeTransport.call(this, length, initialData);
|
PDFDataRangeTransport.call(this, length, initialData);
|
||||||
}
|
}
|
||||||
FirefoxComDataRangeTransport.prototype =
|
FirefoxComDataRangeTransport.prototype =
|
||||||
Object.create(pdfjsLib.PDFDataRangeTransport.prototype);
|
Object.create(PDFDataRangeTransport.prototype);
|
||||||
FirefoxComDataRangeTransport.prototype.requestDataRange =
|
FirefoxComDataRangeTransport.prototype.requestDataRange =
|
||||||
function FirefoxComDataRangeTransport_requestDataRange(begin, end) {
|
function FirefoxComDataRangeTransport_requestDataRange(begin, end) {
|
||||||
FirefoxCom.request('requestDataRange', { begin: begin, end: end });
|
FirefoxCom.request('requestDataRange', { begin: begin, end: end });
|
||||||
|
@ -247,23 +249,22 @@ PDFViewerApplication.externalServices = {
|
||||||
|
|
||||||
get supportsIntegratedFind() {
|
get supportsIntegratedFind() {
|
||||||
var support = FirefoxCom.requestSync('supportsIntegratedFind');
|
var support = FirefoxCom.requestSync('supportsIntegratedFind');
|
||||||
return pdfjsLib.shadow(this, 'supportsIntegratedFind', support);
|
return shadow(this, 'supportsIntegratedFind', support);
|
||||||
},
|
},
|
||||||
|
|
||||||
get supportsDocumentFonts() {
|
get supportsDocumentFonts() {
|
||||||
var support = FirefoxCom.requestSync('supportsDocumentFonts');
|
var support = FirefoxCom.requestSync('supportsDocumentFonts');
|
||||||
return pdfjsLib.shadow(this, 'supportsDocumentFonts', support);
|
return shadow(this, 'supportsDocumentFonts', support);
|
||||||
},
|
},
|
||||||
|
|
||||||
get supportsDocumentColors() {
|
get supportsDocumentColors() {
|
||||||
var support = FirefoxCom.requestSync('supportsDocumentColors');
|
var support = FirefoxCom.requestSync('supportsDocumentColors');
|
||||||
return pdfjsLib.shadow(this, 'supportsDocumentColors', support);
|
return shadow(this, 'supportsDocumentColors', support);
|
||||||
},
|
},
|
||||||
|
|
||||||
get supportedMouseWheelZoomModifierKeys() {
|
get supportedMouseWheelZoomModifierKeys() {
|
||||||
var support = FirefoxCom.requestSync('supportedMouseWheelZoomModifierKeys');
|
var support = FirefoxCom.requestSync('supportedMouseWheelZoomModifierKeys');
|
||||||
return pdfjsLib.shadow(this, 'supportedMouseWheelZoomModifierKeys',
|
return shadow(this, 'supportedMouseWheelZoomModifierKeys', support);
|
||||||
support);
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -13,9 +13,9 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as pdfjsLib from 'pdfjs-web/pdfjs';
|
|
||||||
import { mozL10n } from 'pdfjs-web/ui_utils';
|
import { mozL10n } from 'pdfjs-web/ui_utils';
|
||||||
import { OverlayManager } from 'pdfjs-web/overlay_manager';
|
import { OverlayManager } from 'pdfjs-web/overlay_manager';
|
||||||
|
import { PasswordResponses } from 'pdfjs-web/pdfjs';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} PasswordPromptOptions
|
* @typedef {Object} PasswordPromptOptions
|
||||||
|
@ -71,7 +71,7 @@ var PasswordPrompt = (function PasswordPromptClosure() {
|
||||||
var promptString = mozL10n.get('password_label', null,
|
var promptString = mozL10n.get('password_label', null,
|
||||||
'Enter the password to open this PDF file.');
|
'Enter the password to open this PDF file.');
|
||||||
|
|
||||||
if (this.reason === pdfjsLib.PasswordResponses.INCORRECT_PASSWORD) {
|
if (this.reason === PasswordResponses.INCORRECT_PASSWORD) {
|
||||||
promptString = mozL10n.get('password_invalid', null,
|
promptString = mozL10n.get('password_invalid', null,
|
||||||
'Invalid password. Please try again.');
|
'Invalid password. Please try again.');
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,10 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as pdfjsLib from 'pdfjs-web/pdfjs';
|
import {
|
||||||
|
createObjectURL, createPromiseCapability, getFilenameFromUrl, PDFJS,
|
||||||
|
removeNullCharacters
|
||||||
|
} from 'pdfjs-web/pdfjs';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} PDFAttachmentViewerOptions
|
* @typedef {Object} PDFAttachmentViewerOptions
|
||||||
|
@ -41,7 +44,7 @@ var PDFAttachmentViewer = (function PDFAttachmentViewerClosure() {
|
||||||
this.eventBus = options.eventBus;
|
this.eventBus = options.eventBus;
|
||||||
this.downloadManager = options.downloadManager;
|
this.downloadManager = options.downloadManager;
|
||||||
|
|
||||||
this._renderedCapability = pdfjsLib.createPromiseCapability();
|
this._renderedCapability = createPromiseCapability();
|
||||||
this.eventBus.on('fileattachmentannotation',
|
this.eventBus.on('fileattachmentannotation',
|
||||||
this._appendAttachment.bind(this));
|
this._appendAttachment.bind(this));
|
||||||
}
|
}
|
||||||
|
@ -56,7 +59,7 @@ var PDFAttachmentViewer = (function PDFAttachmentViewerClosure() {
|
||||||
if (!keepRenderedCapability) {
|
if (!keepRenderedCapability) {
|
||||||
// NOTE: The *only* situation in which the `_renderedCapability` should
|
// NOTE: The *only* situation in which the `_renderedCapability` should
|
||||||
// not be replaced is when appending file attachment annotations.
|
// not be replaced is when appending file attachment annotations.
|
||||||
this._renderedCapability = pdfjsLib.createPromiseCapability();
|
this._renderedCapability = createPromiseCapability();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -81,8 +84,8 @@ var PDFAttachmentViewer = (function PDFAttachmentViewerClosure() {
|
||||||
var blobUrl;
|
var blobUrl;
|
||||||
button.onclick = function() {
|
button.onclick = function() {
|
||||||
if (!blobUrl) {
|
if (!blobUrl) {
|
||||||
blobUrl = pdfjsLib.createObjectURL(
|
blobUrl = createObjectURL(
|
||||||
content, 'application/pdf', pdfjsLib.PDFJS.disableCreateObjectURL);
|
content, 'application/pdf', PDFJS.disableCreateObjectURL);
|
||||||
}
|
}
|
||||||
var viewerUrl;
|
var viewerUrl;
|
||||||
if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) {
|
if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) {
|
||||||
|
@ -142,8 +145,7 @@ var PDFAttachmentViewer = (function PDFAttachmentViewerClosure() {
|
||||||
|
|
||||||
for (var i = 0; i < attachmentsCount; i++) {
|
for (var i = 0; i < attachmentsCount; i++) {
|
||||||
var item = attachments[names[i]];
|
var item = attachments[names[i]];
|
||||||
var filename = pdfjsLib.getFilenameFromUrl(item.filename);
|
var filename = removeNullCharacters(getFilenameFromUrl(item.filename));
|
||||||
filename = pdfjsLib.removeNullCharacters(filename);
|
|
||||||
|
|
||||||
var div = document.createElement('div');
|
var div = document.createElement('div');
|
||||||
div.className = 'attachmentsItem';
|
div.className = 'attachmentsItem';
|
||||||
|
|
|
@ -13,9 +13,9 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as pdfjsLib from 'pdfjs-web/pdfjs';
|
import {
|
||||||
|
addLinkAttributes, PDFJS, removeNullCharacters
|
||||||
var PDFJS = pdfjsLib.PDFJS;
|
} from 'pdfjs-web/pdfjs';
|
||||||
|
|
||||||
var DEFAULT_TITLE = '\u2013';
|
var DEFAULT_TITLE = '\u2013';
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ var PDFOutlineViewer = (function PDFOutlineViewerClosure() {
|
||||||
*/
|
*/
|
||||||
_bindLink: function PDFOutlineViewer_bindLink(element, item) {
|
_bindLink: function PDFOutlineViewer_bindLink(element, item) {
|
||||||
if (item.url) {
|
if (item.url) {
|
||||||
pdfjsLib.addLinkAttributes(element, {
|
addLinkAttributes(element, {
|
||||||
url: item.url,
|
url: item.url,
|
||||||
target: (item.newWindow ? PDFJS.LinkTarget.BLANK : undefined),
|
target: (item.newWindow ? PDFJS.LinkTarget.BLANK : undefined),
|
||||||
});
|
});
|
||||||
|
@ -189,7 +189,7 @@ var PDFOutlineViewer = (function PDFOutlineViewerClosure() {
|
||||||
this._bindLink(element, item);
|
this._bindLink(element, item);
|
||||||
this._setStyles(element, item);
|
this._setStyles(element, item);
|
||||||
element.textContent =
|
element.textContent =
|
||||||
pdfjsLib.removeNullCharacters(item.title) || DEFAULT_TITLE;
|
removeNullCharacters(item.title) || DEFAULT_TITLE;
|
||||||
|
|
||||||
div.appendChild(element);
|
div.appendChild(element);
|
||||||
|
|
||||||
|
|
|
@ -13,11 +13,13 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as pdfjsLib from 'pdfjs-web/pdfjs';
|
|
||||||
import {
|
import {
|
||||||
approximateFraction, CSS_UNITS, DEFAULT_SCALE, getOutputScale, RendererType,
|
approximateFraction, CSS_UNITS, DEFAULT_SCALE, getOutputScale, RendererType,
|
||||||
roundToDivide
|
roundToDivide
|
||||||
} from 'pdfjs-web/ui_utils';
|
} from 'pdfjs-web/ui_utils';
|
||||||
|
import {
|
||||||
|
CustomStyle, PDFJS, RenderingCancelledException, SVGGraphics
|
||||||
|
} from 'pdfjs-web/pdfjs';
|
||||||
import { domEvents } from 'pdfjs-web/dom_events';
|
import { domEvents } from 'pdfjs-web/dom_events';
|
||||||
import { RenderingStates } from 'pdfjs-web/pdf_rendering_queue';
|
import { RenderingStates } from 'pdfjs-web/pdf_rendering_queue';
|
||||||
|
|
||||||
|
@ -216,17 +218,17 @@ var PDFPageView = (function PDFPageViewClosure() {
|
||||||
}
|
}
|
||||||
|
|
||||||
var isScalingRestricted = false;
|
var isScalingRestricted = false;
|
||||||
if (this.canvas && pdfjsLib.PDFJS.maxCanvasPixels > 0) {
|
if (this.canvas && PDFJS.maxCanvasPixels > 0) {
|
||||||
var outputScale = this.outputScale;
|
var outputScale = this.outputScale;
|
||||||
if (((Math.floor(this.viewport.width) * outputScale.sx) | 0) *
|
if (((Math.floor(this.viewport.width) * outputScale.sx) | 0) *
|
||||||
((Math.floor(this.viewport.height) * outputScale.sy) | 0) >
|
((Math.floor(this.viewport.height) * outputScale.sy) | 0) >
|
||||||
pdfjsLib.PDFJS.maxCanvasPixels) {
|
PDFJS.maxCanvasPixels) {
|
||||||
isScalingRestricted = true;
|
isScalingRestricted = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.canvas) {
|
if (this.canvas) {
|
||||||
if (pdfjsLib.PDFJS.useOnlyCssZoom ||
|
if (PDFJS.useOnlyCssZoom ||
|
||||||
(this.hasRestrictedScaling && isScalingRestricted)) {
|
(this.hasRestrictedScaling && isScalingRestricted)) {
|
||||||
this.cssTransform(this.canvas, true);
|
this.cssTransform(this.canvas, true);
|
||||||
|
|
||||||
|
@ -272,8 +274,6 @@ var PDFPageView = (function PDFPageViewClosure() {
|
||||||
},
|
},
|
||||||
|
|
||||||
cssTransform: function PDFPageView_transform(target, redrawAnnotations) {
|
cssTransform: function PDFPageView_transform(target, redrawAnnotations) {
|
||||||
var CustomStyle = pdfjsLib.CustomStyle;
|
|
||||||
|
|
||||||
// Scale target (canvas or svg), its wrapper, and page container.
|
// Scale target (canvas or svg), its wrapper, and page container.
|
||||||
var width = this.viewport.width;
|
var width = this.viewport.width;
|
||||||
var height = this.viewport.height;
|
var height = this.viewport.height;
|
||||||
|
@ -425,7 +425,7 @@ var PDFPageView = (function PDFPageViewClosure() {
|
||||||
|
|
||||||
if (((typeof PDFJSDev === 'undefined' ||
|
if (((typeof PDFJSDev === 'undefined' ||
|
||||||
!PDFJSDev.test('PDFJS_NEXT')) && error === 'cancelled') ||
|
!PDFJSDev.test('PDFJS_NEXT')) && error === 'cancelled') ||
|
||||||
error instanceof pdfjsLib.RenderingCancelledException) {
|
error instanceof RenderingCancelledException) {
|
||||||
self.error = null;
|
self.error = null;
|
||||||
return Promise.resolve(undefined);
|
return Promise.resolve(undefined);
|
||||||
}
|
}
|
||||||
|
@ -535,7 +535,7 @@ var PDFPageView = (function PDFPageViewClosure() {
|
||||||
var outputScale = getOutputScale(ctx);
|
var outputScale = getOutputScale(ctx);
|
||||||
this.outputScale = outputScale;
|
this.outputScale = outputScale;
|
||||||
|
|
||||||
if (pdfjsLib.PDFJS.useOnlyCssZoom) {
|
if (PDFJS.useOnlyCssZoom) {
|
||||||
var actualSizeViewport = viewport.clone({scale: CSS_UNITS});
|
var actualSizeViewport = viewport.clone({scale: CSS_UNITS});
|
||||||
// Use a scale that will make the canvas be the original intended size
|
// Use a scale that will make the canvas be the original intended size
|
||||||
// of the page.
|
// of the page.
|
||||||
|
@ -544,10 +544,9 @@ var PDFPageView = (function PDFPageViewClosure() {
|
||||||
outputScale.scaled = true;
|
outputScale.scaled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pdfjsLib.PDFJS.maxCanvasPixels > 0) {
|
if (PDFJS.maxCanvasPixels > 0) {
|
||||||
var pixelsInViewport = viewport.width * viewport.height;
|
var pixelsInViewport = viewport.width * viewport.height;
|
||||||
var maxScale =
|
var maxScale = Math.sqrt(PDFJS.maxCanvasPixels / pixelsInViewport);
|
||||||
Math.sqrt(pdfjsLib.PDFJS.maxCanvasPixels / pixelsInViewport);
|
|
||||||
if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
|
if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
|
||||||
outputScale.sx = maxScale;
|
outputScale.sx = maxScale;
|
||||||
outputScale.sy = maxScale;
|
outputScale.sy = maxScale;
|
||||||
|
@ -617,8 +616,8 @@ var PDFPageView = (function PDFPageViewClosure() {
|
||||||
var ensureNotCancelled = function () {
|
var ensureNotCancelled = function () {
|
||||||
if (cancelled) {
|
if (cancelled) {
|
||||||
if ((typeof PDFJSDev !== 'undefined' &&
|
if ((typeof PDFJSDev !== 'undefined' &&
|
||||||
PDFJSDev.test('PDFJS_NEXT')) || pdfjsLib.PDFJS.pdfjsNext) {
|
PDFJSDev.test('PDFJS_NEXT')) || PDFJS.pdfjsNext) {
|
||||||
throw new pdfjsLib.RenderingCancelledException(
|
throw new RenderingCancelledException(
|
||||||
'Rendering cancelled, page ' + self.id, 'svg');
|
'Rendering cancelled, page ' + self.id, 'svg');
|
||||||
} else {
|
} else {
|
||||||
throw 'cancelled'; // eslint-disable-line no-throw-literal
|
throw 'cancelled'; // eslint-disable-line no-throw-literal
|
||||||
|
@ -628,7 +627,6 @@ var PDFPageView = (function PDFPageViewClosure() {
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
var pdfPage = this.pdfPage;
|
var pdfPage = this.pdfPage;
|
||||||
var SVGGraphics = pdfjsLib.SVGGraphics;
|
|
||||||
var actualSizeViewport = this.viewport.clone({scale: CSS_UNITS});
|
var actualSizeViewport = this.viewport.clone({scale: CSS_UNITS});
|
||||||
var promise = pdfPage.getOperatorList().then(function (opList) {
|
var promise = pdfPage.getOperatorList().then(function (opList) {
|
||||||
ensureNotCancelled();
|
ensureNotCancelled();
|
||||||
|
|
|
@ -13,9 +13,9 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as pdfjsLib from 'pdfjs-web/pdfjs';
|
|
||||||
import { CSS_UNITS, mozL10n } from 'pdfjs-web/ui_utils';
|
import { CSS_UNITS, mozL10n } from 'pdfjs-web/ui_utils';
|
||||||
import { OverlayManager } from 'pdfjs-web/overlay_manager';
|
import { OverlayManager } from 'pdfjs-web/overlay_manager';
|
||||||
|
import { PDFJS } from 'pdfjs-web/pdfjs';
|
||||||
import { PDFPrintServiceFactory } from 'pdfjs-web/app';
|
import { PDFPrintServiceFactory } from 'pdfjs-web/app';
|
||||||
|
|
||||||
var activeService = null;
|
var activeService = null;
|
||||||
|
@ -152,8 +152,7 @@ PDFPrintService.prototype = {
|
||||||
img.style.height = printItem.height;
|
img.style.height = printItem.height;
|
||||||
|
|
||||||
var scratchCanvas = this.scratchCanvas;
|
var scratchCanvas = this.scratchCanvas;
|
||||||
if (('toBlob' in scratchCanvas) &&
|
if (('toBlob' in scratchCanvas) && !PDFJS.disableCreateObjectURL) {
|
||||||
!pdfjsLib.PDFJS.disableCreateObjectURL) {
|
|
||||||
scratchCanvas.toBlob(function (blob) {
|
scratchCanvas.toBlob(function (blob) {
|
||||||
img.src = URL.createObjectURL(blob);
|
img.src = URL.createObjectURL(blob);
|
||||||
});
|
});
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as pdfjsLib from 'pdfjs-web/pdfjs';
|
|
||||||
import {
|
import {
|
||||||
CSS_UNITS, DEFAULT_SCALE, DEFAULT_SCALE_VALUE, getVisibleElements,
|
CSS_UNITS, DEFAULT_SCALE, DEFAULT_SCALE_VALUE, getVisibleElements,
|
||||||
MAX_AUTO_SCALE, RendererType, SCROLLBAR_PADDING, scrollIntoView,
|
MAX_AUTO_SCALE, RendererType, SCROLLBAR_PADDING, scrollIntoView,
|
||||||
|
@ -24,6 +23,7 @@ import {
|
||||||
} from 'pdfjs-web/pdf_rendering_queue';
|
} from 'pdfjs-web/pdf_rendering_queue';
|
||||||
import { AnnotationLayerBuilder } from 'pdfjs-web/annotation_layer_builder';
|
import { AnnotationLayerBuilder } from 'pdfjs-web/annotation_layer_builder';
|
||||||
import { domEvents } from 'pdfjs-web/dom_events';
|
import { domEvents } from 'pdfjs-web/dom_events';
|
||||||
|
import { PDFJS } from 'pdfjs-web/pdfjs';
|
||||||
import { PDFPageView } from 'pdfjs-web/pdf_page_view';
|
import { PDFPageView } from 'pdfjs-web/pdf_page_view';
|
||||||
import { SimpleLinkService } from 'pdfjs-web/pdf_link_service';
|
import { SimpleLinkService } from 'pdfjs-web/pdf_link_service';
|
||||||
import { TextLayerBuilder } from 'pdfjs-web/text_layer_builder';
|
import { TextLayerBuilder } from 'pdfjs-web/text_layer_builder';
|
||||||
|
@ -362,7 +362,7 @@ var PDFViewer = (function pdfViewer() {
|
||||||
var viewport = pdfPage.getViewport(scale * CSS_UNITS);
|
var viewport = pdfPage.getViewport(scale * CSS_UNITS);
|
||||||
for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
|
for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
|
||||||
var textLayerFactory = null;
|
var textLayerFactory = null;
|
||||||
if (!pdfjsLib.PDFJS.disableTextLayer) {
|
if (!PDFJS.disableTextLayer) {
|
||||||
textLayerFactory = this;
|
textLayerFactory = this;
|
||||||
}
|
}
|
||||||
var pageView = new PDFPageView({
|
var pageView = new PDFPageView({
|
||||||
|
@ -388,7 +388,7 @@ var PDFViewer = (function pdfViewer() {
|
||||||
// starts to create the correct size canvas. Wait until one page is
|
// starts to create the correct size canvas. Wait until one page is
|
||||||
// rendered so we don't tie up too many resources early on.
|
// rendered so we don't tie up too many resources early on.
|
||||||
onePageRendered.then(function () {
|
onePageRendered.then(function () {
|
||||||
if (!pdfjsLib.PDFJS.disableAutoFetch) {
|
if (!PDFJS.disableAutoFetch) {
|
||||||
var getPagesLeft = pagesCount;
|
var getPagesLeft = pagesCount;
|
||||||
for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
|
for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
|
||||||
pdfDocument.getPage(pageNum).then(function (pageNum, pdfPage) {
|
pdfDocument.getPage(pageNum).then(function (pageNum, pdfPage) {
|
||||||
|
@ -500,7 +500,7 @@ var PDFViewer = (function pdfViewer() {
|
||||||
|
|
||||||
if (!noScroll) {
|
if (!noScroll) {
|
||||||
var page = this._currentPageNumber, dest;
|
var page = this._currentPageNumber, dest;
|
||||||
if (this._location && !pdfjsLib.PDFJS.ignoreCurrentPositionOnZoom &&
|
if (this._location && !PDFJS.ignoreCurrentPositionOnZoom &&
|
||||||
!(this.isInPresentationMode || this.isChangingPresentationMode)) {
|
!(this.isInPresentationMode || this.isChangingPresentationMode)) {
|
||||||
page = this._location.pageNumber;
|
page = this._location.pageNumber;
|
||||||
dest = [null, { name: 'XYZ' }, this._location.left,
|
dest = [null, { name: 'XYZ' }, this._location.left,
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as pdfjsLib from 'pdfjs-web/pdfjs';
|
|
||||||
import { domEvents } from 'pdfjs-web/dom_events';
|
import { domEvents } from 'pdfjs-web/dom_events';
|
||||||
|
import { renderTextLayer } from 'pdfjs-web/pdfjs';
|
||||||
|
|
||||||
var EXPAND_DIVS_TIMEOUT = 300; // ms
|
var EXPAND_DIVS_TIMEOUT = 300; // ms
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ var TextLayerBuilder = (function TextLayerBuilderClosure() {
|
||||||
|
|
||||||
this.textDivs = [];
|
this.textDivs = [];
|
||||||
var textLayerFrag = document.createDocumentFragment();
|
var textLayerFrag = document.createDocumentFragment();
|
||||||
this.textLayerRenderTask = pdfjsLib.renderTextLayer({
|
this.textLayerRenderTask = renderTextLayer({
|
||||||
textContent: this.textContent,
|
textContent: this.textContent,
|
||||||
container: textLayerFrag,
|
container: textLayerFrag,
|
||||||
viewport: this.viewport,
|
viewport: this.viewport,
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as pdfjsLib from 'pdfjs-web/pdfjs';
|
import { PDFJS } from 'pdfjs-web/pdfjs';
|
||||||
|
|
||||||
var CSS_UNITS = 96.0 / 72.0;
|
var CSS_UNITS = 96.0 / 72.0;
|
||||||
var DEFAULT_SCALE_VALUE = 'auto';
|
var DEFAULT_SCALE_VALUE = 'auto';
|
||||||
|
@ -32,8 +32,6 @@ var RendererType = {
|
||||||
|
|
||||||
var mozL10n = document.mozL10n || document.webL10n;
|
var mozL10n = document.mozL10n || document.webL10n;
|
||||||
|
|
||||||
var PDFJS = pdfjsLib.PDFJS;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disables fullscreen support, and by extension Presentation Mode,
|
* Disables fullscreen support, and by extension Presentation Mode,
|
||||||
* in browsers which support the fullscreen API.
|
* in browsers which support the fullscreen API.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue