Authentication 在使用URL获取文档时,如何在PDFTron Webviewer中添加请求配置?

Authentication 在使用URL获取文档时,如何在PDFTron Webviewer中添加请求配置?,authentication,webview,pdftron,Authentication,Webview,Pdftron,我试图在服务器A上托管的angular应用程序中使用PDFNet/PDFTron WebViewer,我想从服务器B加载PDF文件。 要加载需要验证的pdf文件,服务器B在我的浏览器上设置cookie。因此,我在GET请求中使用credentials:true传递 在使用WebViewer时,我将该URL传递给WebViewer的initialDoc参数,API返回401状态代码 var viewerElement = $('#viewer'); var myWebViewer = new PD

我试图在服务器A上托管的angular应用程序中使用PDFNet/PDFTron WebViewer,我想从服务器B加载PDF文件。 要加载需要验证的pdf文件,服务器B在我的浏览器上设置cookie。因此,我在GET请求中使用credentials:true传递

在使用WebViewer时,我将该URL传递给WebViewer的initialDoc参数,API返回401状态代码

var viewerElement = $('#viewer');
var myWebViewer = new PDFTron.WebViewer({
            type: "html5",
            path: "path/to/lib",
            streaming : "true",
            initialDoc: "**Server B URL to load pdf file**",
            documentType : "pdf",
            config: "path/to/config"
        }, viewerElement);
我无法理解在哪里可以传递请求configs,以便通过身份验证获取该文档。 是否有任何方法可以使用凭据进行HTTP调用以获取PDF文件。
提前感谢。

您需要下载的最新版本,其中包括设置凭据的功能

下载后,需要将以下代码添加到config.js

var oldLoadDocument = ReaderControl.prototype.loadDocument;
var loadDocument = function(doc, options) {
  options.withCredentials = true;
  return oldLoadDocument.call(this, doc, options);
}
ReaderControl.prototype.loadDocument = loadDocument;

您需要下载的最新版本,其中包括设置凭据的功能

下载后,需要将以下代码添加到config.js

var oldLoadDocument = ReaderControl.prototype.loadDocument;
var loadDocument = function(doc, options) {
  options.withCredentials = true;
  return oldLoadDocument.call(this, doc, options);
}
ReaderControl.prototype.loadDocument = loadDocument;