ASP.NET 或 HTML 页面中的 PDFTron Web 查看器 - 加载 pdf 或 xod 显示错误
PDFTron Web Viewer in ASP.NET or HTML page - loading pdf or xod displays error
在 ASP.NET 或 HTML 页面中使用 PDFTron Web 查看器显示 PDF 或 XOD 文件,我收到的错误为 - "Failed to load resource file. This could be due to an incorrect worker path or unsupported .res mime type on the server."
<script>
$(function () {
var viewerElement = document.getElementById('viewer');
var myWebViewer = new PDFTron.WebViewer({
path: 'lib',
type: 'html5',
documentType: "pdf",
initialDoc: "lib/GettingStarted.pdf",
config: '',
streaming: false,
enableAnnotations: false,
enableOfflineMode: false,
enableReadOnlyMode: true
}, viewerElement);
});
</script>
浏览器控制台window显示如下:
HTML1300: Navigation occurred.
View
DOM7011: The code on this page disabled back and forward caching. For more information, see: http://go.microsoft.com/fwlink/?LinkID=291337
View
SCRIPT7016: Use of XMLHttpRequest with the synchronous flag set to true is deprecated due to its impact on user-perceived site performance.
browserLink (37,85652)
SCRIPT7015: Setting withCredentials attribute for synchronous XMLHttpRequest is deprecated
View
asm.js has been disabled as the script debugger is connected. Disconnect the debugger to enable asm.js.
PDFNetC.js
HTTP range requests not supported. Switching to streaming mode.
ControlUtils.js (170,25)
Error: error.ResourceLoadError
PDFReaderControl.js (14,13)
HTTP404: NOT FOUND - The server has not found anything matching the requested URI (Uniform Resource Identifier).
(XHR)GET - http://localhost:63936/lib/html5/pdf/pdfnet.res
Could not use incremental download for url /lib/GettingStarted.pdf. Reason: Byte ranges are not supported by the server.
CoreControls.js (669,43)
asm.js has been disabled as the script debugger is connected. Disconnect the debugger to enable asm.js.
PDFNetC.js
Error: No response from frame: # 697
browserLink (363,16590)
{
[functions]: ,
__proto__: { },
description: "No response from frame: # 697",
message: "No response from frame: # 697",
name: "Error",
stack: "Error: No response from frame: # 697
at A (http://localhost:56824/e61cf52526d049168d3be50fd1b6a801/browserLink:363:5795)
at Anonymous function (http://localhost:56824/e61cf52526d049168d3be50fd1b6a801/browserLink:363:21639)"
}
SCRIPT0: could not load memory initializer PDFNetC.js.mem
PDFNetC.js (36,1)
将以下内容添加到您的 web.config,确保删除并添加其中一些以防您 运行 来自 IISExpress。
<system.webServer>
<staticContent>
<remove fileExtension=".js" />
<mimeMap fileExtension=".js" mimeType="text/javascript" />
<!-- PDFViewer -->
<!--Remove statement for each extension is for running it on IIS Express-->
<remove fileExtension=".json" />
<mimeMap fileExtension=".json" mimeType="application/json" />
<remove fileExtension=".woff" />
<mimeMap fileExtension=".woff" mimeType="application/font-woff" />
<mimeMap fileExtension=".res" mimeType="text/plain" />
<mimeMap fileExtension=".nmf" mimeType="text/plain" />
<mimeMap fileExtension=".pexe" mimeType="text/plain" />
<mimeMap fileExtension=".mem" mimeType="text/plain" />
<mimeMap fileExtension=".brotli" mimeType="text/plain" />
</staticContent>
在 ASP.NET 或 HTML 页面中使用 PDFTron Web 查看器显示 PDF 或 XOD 文件,我收到的错误为 - "Failed to load resource file. This could be due to an incorrect worker path or unsupported .res mime type on the server."
<script>
$(function () {
var viewerElement = document.getElementById('viewer');
var myWebViewer = new PDFTron.WebViewer({
path: 'lib',
type: 'html5',
documentType: "pdf",
initialDoc: "lib/GettingStarted.pdf",
config: '',
streaming: false,
enableAnnotations: false,
enableOfflineMode: false,
enableReadOnlyMode: true
}, viewerElement);
});
</script>
浏览器控制台window显示如下:
HTML1300: Navigation occurred.
View
DOM7011: The code on this page disabled back and forward caching. For more information, see: http://go.microsoft.com/fwlink/?LinkID=291337
View
SCRIPT7016: Use of XMLHttpRequest with the synchronous flag set to true is deprecated due to its impact on user-perceived site performance.
browserLink (37,85652)
SCRIPT7015: Setting withCredentials attribute for synchronous XMLHttpRequest is deprecated
View
asm.js has been disabled as the script debugger is connected. Disconnect the debugger to enable asm.js.
PDFNetC.js
HTTP range requests not supported. Switching to streaming mode.
ControlUtils.js (170,25)
Error: error.ResourceLoadError
PDFReaderControl.js (14,13)
HTTP404: NOT FOUND - The server has not found anything matching the requested URI (Uniform Resource Identifier).
(XHR)GET - http://localhost:63936/lib/html5/pdf/pdfnet.res
Could not use incremental download for url /lib/GettingStarted.pdf. Reason: Byte ranges are not supported by the server.
CoreControls.js (669,43)
asm.js has been disabled as the script debugger is connected. Disconnect the debugger to enable asm.js.
PDFNetC.js
Error: No response from frame: # 697
browserLink (363,16590)
{
[functions]: ,
__proto__: { },
description: "No response from frame: # 697",
message: "No response from frame: # 697",
name: "Error",
stack: "Error: No response from frame: # 697
at A (http://localhost:56824/e61cf52526d049168d3be50fd1b6a801/browserLink:363:5795)
at Anonymous function (http://localhost:56824/e61cf52526d049168d3be50fd1b6a801/browserLink:363:21639)"
}
SCRIPT0: could not load memory initializer PDFNetC.js.mem
PDFNetC.js (36,1)
将以下内容添加到您的 web.config,确保删除并添加其中一些以防您 运行 来自 IISExpress。
<system.webServer>
<staticContent>
<remove fileExtension=".js" />
<mimeMap fileExtension=".js" mimeType="text/javascript" />
<!-- PDFViewer -->
<!--Remove statement for each extension is for running it on IIS Express-->
<remove fileExtension=".json" />
<mimeMap fileExtension=".json" mimeType="application/json" />
<remove fileExtension=".woff" />
<mimeMap fileExtension=".woff" mimeType="application/font-woff" />
<mimeMap fileExtension=".res" mimeType="text/plain" />
<mimeMap fileExtension=".nmf" mimeType="text/plain" />
<mimeMap fileExtension=".pexe" mimeType="text/plain" />
<mimeMap fileExtension=".mem" mimeType="text/plain" />
<mimeMap fileExtension=".brotli" mimeType="text/plain" />
</staticContent>