Adds deprecation warning for the API calls.
This commit is contained in:
parent
58c3ea0820
commit
5135aa9bec
@ -19,7 +19,7 @@
|
|||||||
Promise, PasswordResponses, PasswordException, InvalidPDFException,
|
Promise, PasswordResponses, PasswordException, InvalidPDFException,
|
||||||
MissingPDFException, UnknownErrorException, FontFaceObject,
|
MissingPDFException, UnknownErrorException, FontFaceObject,
|
||||||
loadJpegStream, createScratchCanvas, CanvasGraphics, stringToBytes,
|
loadJpegStream, createScratchCanvas, CanvasGraphics, stringToBytes,
|
||||||
UnexpectedResponseException */
|
UnexpectedResponseException, deprecated */
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@ -259,6 +259,10 @@ PDFJS.getDocument = function getDocument(src,
|
|||||||
var task = new PDFDocumentLoadingTask();
|
var task = new PDFDocumentLoadingTask();
|
||||||
|
|
||||||
// Support of the obsolete arguments (for compatibility with API v1.0)
|
// Support of the obsolete arguments (for compatibility with API v1.0)
|
||||||
|
if (arguments.length > 1) {
|
||||||
|
deprecated('getDocument is called with pdfDataRangeTransport, ' +
|
||||||
|
'passwordCallback or progressCallback argument');
|
||||||
|
}
|
||||||
if (pdfDataRangeTransport) {
|
if (pdfDataRangeTransport) {
|
||||||
if (!(pdfDataRangeTransport instanceof PDFDataRangeTransport)) {
|
if (!(pdfDataRangeTransport instanceof PDFDataRangeTransport)) {
|
||||||
// Not a PDFDataRangeTransport instance, trying to add missing properties.
|
// Not a PDFDataRangeTransport instance, trying to add missing properties.
|
||||||
@ -786,6 +790,7 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
|
|||||||
|
|
||||||
// Obsolete parameter support
|
// Obsolete parameter support
|
||||||
if (params.continueCallback) {
|
if (params.continueCallback) {
|
||||||
|
deprecated('render is used with continueCallback parameter');
|
||||||
renderTask.onContinue = params.continueCallback;
|
renderTask.onContinue = params.continueCallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -900,10 +905,10 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cleans up resources allocated by the page.
|
* Cleans up resources allocated by the page. (deprecated)
|
||||||
* Deprecated, use cleanup() instead.
|
|
||||||
*/
|
*/
|
||||||
destroy: function() {
|
destroy: function() {
|
||||||
|
deprecated('page destroy method, use cleanup() instead');
|
||||||
this.cleanup();
|
this.cleanup();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -213,6 +213,11 @@ function warn(msg) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deprecated API function -- treated as warnings.
|
||||||
|
function deprecated(details) {
|
||||||
|
warn('Deprecated API usage: ' + details);
|
||||||
|
}
|
||||||
|
|
||||||
// Fatal errors that should trigger the fallback UI and halt execution by
|
// Fatal errors that should trigger the fallback UI and halt execution by
|
||||||
// throwing an exception.
|
// throwing an exception.
|
||||||
function error(msg) {
|
function error(msg) {
|
||||||
|
@ -457,9 +457,9 @@ var PDFPageView = (function PDFPageViewClosure() {
|
|||||||
canvasContext: ctx,
|
canvasContext: ctx,
|
||||||
viewport: this.viewport,
|
viewport: this.viewport,
|
||||||
// intent: 'default', // === 'display'
|
// intent: 'default', // === 'display'
|
||||||
continueCallback: renderContinueCallback
|
|
||||||
};
|
};
|
||||||
var renderTask = this.renderTask = this.pdfPage.render(renderContext);
|
var renderTask = this.renderTask = this.pdfPage.render(renderContext);
|
||||||
|
renderTask.onContinue = renderContinueCallback;
|
||||||
|
|
||||||
this.renderTask.promise.then(
|
this.renderTask.promise.then(
|
||||||
function pdfPageRenderCallback() {
|
function pdfPageRenderCallback() {
|
||||||
|
@ -285,10 +285,10 @@ var PDFThumbnailView = (function PDFThumbnailViewClosure() {
|
|||||||
|
|
||||||
var renderContext = {
|
var renderContext = {
|
||||||
canvasContext: ctx,
|
canvasContext: ctx,
|
||||||
viewport: drawViewport,
|
viewport: drawViewport
|
||||||
continueCallback: renderContinueCallback
|
|
||||||
};
|
};
|
||||||
var renderTask = this.renderTask = this.pdfPage.render(renderContext);
|
var renderTask = this.renderTask = this.pdfPage.render(renderContext);
|
||||||
|
renderTask.onContinue = renderContinueCallback;
|
||||||
|
|
||||||
renderTask.promise.then(
|
renderTask.promise.then(
|
||||||
function pdfPageRenderCallback() {
|
function pdfPageRenderCallback() {
|
||||||
|
@ -526,6 +526,9 @@ var PDFViewerApplication = {
|
|||||||
this.setTitleUsingUrl(file.originalUrl);
|
this.setTitleUsingUrl(file.originalUrl);
|
||||||
parameters.url = file.url;
|
parameters.url = file.url;
|
||||||
}
|
}
|
||||||
|
if (pdfDataRangeTransport) {
|
||||||
|
parameters.range = pdfDataRangeTransport;
|
||||||
|
}
|
||||||
if (args) {
|
if (args) {
|
||||||
for (var prop in args) {
|
for (var prop in args) {
|
||||||
parameters[prop] = args[prop];
|
parameters[prop] = args[prop];
|
||||||
@ -535,18 +538,19 @@ var PDFViewerApplication = {
|
|||||||
var self = this;
|
var self = this;
|
||||||
self.downloadComplete = false;
|
self.downloadComplete = false;
|
||||||
|
|
||||||
var passwordNeeded = function passwordNeeded(updatePassword, reason) {
|
var loadingTask = PDFJS.getDocument(parameters);
|
||||||
|
|
||||||
|
loadingTask.onPassword = function passwordNeeded(updatePassword, reason) {
|
||||||
PasswordPrompt.updatePassword = updatePassword;
|
PasswordPrompt.updatePassword = updatePassword;
|
||||||
PasswordPrompt.reason = reason;
|
PasswordPrompt.reason = reason;
|
||||||
PasswordPrompt.open();
|
PasswordPrompt.open();
|
||||||
};
|
};
|
||||||
|
|
||||||
function getDocumentProgress(progressData) {
|
loadingTask.onProgress = function getDocumentProgress(progressData) {
|
||||||
self.progress(progressData.loaded / progressData.total);
|
self.progress(progressData.loaded / progressData.total);
|
||||||
}
|
};
|
||||||
|
|
||||||
PDFJS.getDocument(parameters, pdfDataRangeTransport, passwordNeeded,
|
loadingTask.promise.then(
|
||||||
getDocumentProgress).then(
|
|
||||||
function getDocumentCallback(pdfDocument) {
|
function getDocumentCallback(pdfDocument) {
|
||||||
self.load(pdfDocument, scale);
|
self.load(pdfDocument, scale);
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user