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