function pdfViewOpen(file, scale, password,
                             pdfDataRangeTransport, args) {
    if (this.pdfDocument) {
      // Reload the preferences if a document was previously opened.
      Preferences.reload();
    }
    this.close();

    var parameters = {password: password};
    if (typeof file === 'string') { // URL
      this.setTitleUsingUrl(file);
      parameters.url = file;
    } else if (file && 'byteLength' in file) { // ArrayBuffer
      parameters.data = file;
    } else if (file.url && file.originalUrl) {
      this.setTitleUsingUrl(file.originalUrl);
      parameters.url = file.url;
    }
    if (args) {
      for (var prop in args) {
        parameters[prop] = args[prop];
      }
    }

    var self = this;
    self.downloadComplete = false;

    var passwordNeeded = function passwordNeeded(updatePassword, reason) {
      PasswordPrompt.updatePassword = updatePassword;
      PasswordPrompt.reason = reason;
      PasswordPrompt.open();
    };

    function getDocumentProgress(progressData) {
      self.progress(progressData.loaded / progressData.total);
    }

    PDFJS.getDocument(parameters, pdfDataRangeTransport, passwordNeeded,
                      getDocumentProgress).then(
      function getDocumentCallback(pdfDocument) {
        self.load(pdfDocument, scale);
      },
      function getDocumentError(exception) {
        var message = exception && exception.message;
        var loadingErrorMessage = mozL10n.get('loading_error', null,
          'An error occurred while loading the PDF.');

        if (exception instanceof PDFJS.InvalidPDFException) {
          // change error message also for other builds
          loadingErrorMessage = mozL10n.get('invalid_file_error', null,
                                            'Invalid or corrupted PDF file.');
        } else if (exception instanceof PDFJS.MissingPDFException) {
          // special message for missing PDF's
          loadingErrorMessage = mozL10n.get('missing_file_error', null,
                                            'Missing PDF file.');
        } else if (exception instanceof PDFJS.UnexpectedResponseException) {
          loadingErrorMessage = mozL10n.get('unexpected_response_error', null,
                                            'Unexpected server response.');
        }

        var moreInfo = {
          message: message
        };
        self.error(loadingErrorMessage, moreInfo);
      }
    );

    if (args && args.length) {
      PDFViewerApplication.pdfDocumentProperties.setFileSize(args.length);
    }
  }
// TODO(mack): This function signature should really be pdfViewOpen(url, args)
This function signature should really be pdfViewOpen(url, args)
This function signature should really be pdfViewOpen ( url args )
function pdfViewOpen(file, scale, password,
                             pdfDataRangeTransport, args) {
    if (this.pdfDocument) {
      Preferences.reload();
    }
    this.close();
    var parameters = {password: password};
    if (typeof file === 'string') { 
      this.setTitleUsingUrl(file);
      parameters.url = file;
    } else if (file && 'byteLength' in file) { 
      parameters.data = file;
    } else if (file.url && file.originalUrl) {
      this.setTitleUsingUrl(file.originalUrl);
      parameters.url = file.url;
    }
    if (args) {
      for (var prop in args) {
        parameters[prop] = args[prop];
      }
    }
    var self = this;
    self.downloadComplete = false;
    var passwordNeeded = function passwordNeeded(updatePassword, reason) {
      PasswordPrompt.updatePassword = updatePassword;
      PasswordPrompt.reason = reason;
      PasswordPrompt.open();
    };
    function getDocumentProgress(progressData) {
      self.progress(progressData.loaded / progressData.total);
    }
    PDFJS.getDocument(parameters, pdfDataRangeTransport, passwordNeeded,
                      getDocumentProgress).then(
      function getDocumentCallback(pdfDocument) {
        self.load(pdfDocument, scale);
      },
      function getDocumentError(exception) {
        var message = exception && exception.message;
        var loadingErrorMessage = mozL10n.get('loading_error', null,
          'An error occurred while loading the PDF.');
        if (exception instanceof PDFJS.InvalidPDFException) {
          loadingErrorMessage = mozL10n.get('invalid_file_error', null,
                                            'Invalid or corrupted PDF file.');
        } else if (exception instanceof PDFJS.MissingPDFException) {
          loadingErrorMessage = mozL10n.get('missing_file_error', null,
                                            'Missing PDF file.');
        } else if (exception instanceof PDFJS.UnexpectedResponseException) {
          loadingErrorMessage = mozL10n.get('unexpected_response_error', null,
                                            'Unexpected server response.');
        }
        var moreInfo = {
          message: message
        };
        self.error(loadingErrorMessage, moreInfo);
      }
    );
    if (args && args.length) {
      PDFViewerApplication.pdfDocumentProperties.setFileSize(args.length);
    }
  }
function pdfViewOpen ( file , scale , password , pdfDataRangeTransport , args ) { if ( this . pdfDocument ) { Preferences . reload ( ) ; } this . close ( ) ; var parameters = { password : password } ; if ( typeof file === 'string' ) { this . setTitleUsingUrl ( file ) ; parameters . url = file ; } else if ( file && 'byteLength' in file ) { parameters . data = file ; } else if ( file . url && file . originalUrl ) { this . setTitleUsingUrl ( file . originalUrl ) ; parameters . url = file . url ; } if ( args ) { for ( var prop in args ) { parameters [ prop ] = args [ prop ] ; } } var self = this ; self . downloadComplete = false ; var passwordNeeded = function passwordNeeded ( updatePassword , reason ) { PasswordPrompt . updatePassword = updatePassword ; PasswordPrompt . reason = reason ; PasswordPrompt . open ( ) ; } ; function getDocumentProgress ( progressData ) { self . progress ( progressData . loaded / progressData . total ) ; } PDFJS . getDocument ( parameters , pdfDataRangeTransport , passwordNeeded , getDocumentProgress ) . then ( function getDocumentCallback ( pdfDocument ) { self . load ( pdfDocument , scale ) ; } , function getDocumentError ( exception ) { var message = exception && exception . message ; var loadingErrorMessage = mozL10n . get ( 'loading_error' , null , 'An error occurred while loading the PDF.' ) ; if ( exception instanceof PDFJS . InvalidPDFException ) { loadingErrorMessage = mozL10n . get ( 'invalid_file_error' , null , 'Invalid or corrupted PDF file.' ) ; } else if ( exception instanceof PDFJS . MissingPDFException ) { loadingErrorMessage = mozL10n . get ( 'missing_file_error' , null , 'Missing PDF file.' ) ; } else if ( exception instanceof PDFJS . UnexpectedResponseException ) { loadingErrorMessage = mozL10n . get ( 'unexpected_response_error' , null , 'Unexpected server response.' ) ; } var moreInfo = { message : message } ; self . error ( loadingErrorMessage , moreInfo ) ; } ) ; if ( args && args . length ) { PDFViewerApplication . pdfDocumentProperties . setFileSize ( args . length ) ; } }
TODO(mack): This function signature should really be pdfViewOpen(url, args)
TODO ( mack ) : This function signature should really be pdfViewOpen ( url args )
// Reload the preferences if a document was previously opened. // URL // ArrayBuffer // change error message also for other builds // special message for missing PDF's