0

I'm trying to display a pdf file using pdf-viewer, and it works on all browsers except IE 11.

The only block of code that is newly created is

buildBinaryFromBase64(data) {
    var BASE64_MARKER = ';base64, ';
    var base64Index = data.indexOf(BASE64_MARKER) + BASE64_MARKER.length;
    var base64 = data.substring(base64Index);
    var raw = window.atob(base64);
    var rawLength = raw.length;
    var array = new Uint8Array(new ArrayBuffer(rawLength));

    for (var i = 0; i < rawLength; i++) {
      array[i] = raw.charCodeAt(i);
    }
    return array;
  }

I'm following

Pdf.js and viewer.js. Pass a stream or blob to the viewer

as an example

I don't know what's causing the error. Some functions are not supported for IE 11?

The error is shown below

InvalidCharacterError
   {
      [functions]: ,
      __proto__: { },
      ABORT_ERR: 20,
      code: 5,
      constructor: { },
      DATA_CLONE_ERR: 25,
      DOMSTRING_SIZE_ERR: 2,
      HIERARCHY_REQUEST_ERR: 3,
      INDEX_SIZE_ERR: 1,
      INUSE_ATTRIBUTE_ERR: 10,
      INVALID_ACCESS_ERR: 15,
      INVALID_CHARACTER_ERR: 5,
      INVALID_MODIFICATION_ERR: 13,
      INVALID_NODE_TYPE_ERR: 24,
      INVALID_STATE_ERR: 11,
      message: "InvalidCharacterError",
      name: "InvalidCharacterError",
      NAMESPACE_ERR: 14,
      NETWORK_ERR: 19,
      NO_DATA_ALLOWED_ERR: 6,
      NO_MODIFICATION_ALLOWED_ERR: 7,
      NOT_FOUND_ERR: 8,
      NOT_SUPPORTED_ERR: 9,
      PARSE_ERR: 81,
      QUOTA_EXCEEDED_ERR: 22,
      SECURITY_ERR: 18,
      SERIALIZE_ERR: 82,
      SYNTAX_ERR: 12,
      TIMEOUT_ERR: 23,
      TYPE_MISMATCH_ERR: 17,
      URL_MISMATCH_ERR: 21,
      VALIDATION_ERR: 16,
      WRONG_DOCUMENT_ERR: 4
   }

I know there are a lot of these posts already on stackoverflow but none helps with my issue. This seems entirely case-specific

JChao
  • 2,178
  • 5
  • 35
  • 65
  • The error points to which line? Could you give [a minimal example to reproduce](https://stackoverflow.com/help/minimal-reproducible-example) the issue as this can be case-specific? So that we can have a better understanding of the issue and see how to help. – Yu Zhou Nov 22 '19 at 06:26
  • @YuZhou i'm sorry I really don't know how to produce a minimal example to reproduce..... this is such a puzzle for me that I can only provide what i've listed above. I don't even know what's actually producing this `InvalidCharacterError`..... my guess is one of the functions being used is not supported by IE11, but I really have no way to tell except "it doesn't work on IE11"..... – JChao Dec 11 '19 at 22:09
  • @YuZhou I don't know how to read this error either. The message doesn't contain any sort of traceback and I don't know how to locate it if it's somewhere – JChao Dec 11 '19 at 22:10
  • It might because `createObjectURL` is not supported in IE. You could try to use `msSaveOrOpenBlob` which is IE's own API for creating and downloading files. You could also refer to [this thread](https://stackoverflow.com/questions/24007073/open-links-made-by-createobjecturl-in-ie11). – Yu Zhou Dec 12 '19 at 05:16

0 Answers0