如何在使用URL提取文档的同时在PDFTron Webviewer中添加请求配置?

问题描述 投票:1回答:1

我正在尝试在服务器A上托管的角度应用程序中使用PDFNet / PDFTron WebViewer,我想从服务器B加载PDF文件。为了加载需要pdf文件认证的信息,服务器B在我的浏览器上设置了一个cookie。因此,我在GET请求中传递了withCredentials: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);

我无法理解我可以在哪里传递请求配置,以便对我进行身份验证以提取该文档。有什么方法可以使我通过凭据进行HTTP调用以获取PDF文件。预先感谢。

authentication webview pdftron
1个回答
0
投票

您需要下载WebViewer 2.2.2的最新版本,包括设置withCredentials的功能。

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

© www.soinside.com 2019 - 2024. All rights reserved.