【发布时间】:2020-09-15 15:13:23
【问题描述】:
MVC c# 应用程序。 我正在使用 CSP,格式如下:
<meta http-equiv="Content-Security-Policy" content="
default-src 'self';
script-src 'self' https://mozilla.github.io/pdf.js/build/pdf.js https://mozilla.github.io/pdf.js/build/pdf.worker.js;
style-src 'self' https://meyerweb.com/eric/tools/css/reset/reset.css;
object-src 'self';
base-uri 'self';
connect-src 'self';
font-src 'self';
frame-src 'self';
img-src 'self';
manifest-src 'self';
media-src 'self';
worker-src blob:;"/>
在项目中,我将 pdf.js 用于 base64 pdf。我看到了我的文档,但我没有看到 pdf.js 的按钮栏。 我的浏览器控制台显示:
和我的javascript函数使用:
var DivContenedorPDF = document.createElement("div");
DivContenedorPDF.id = "pdf-viewer";
var pdfData = atob(b64);
var pdfjsLib = window['pdfjs-dist/build/pdf'];
pdfjsLib.GlobalWorkerOptions.workerSrc = '//mozilla.github.io/pdf.js/build/pdf.worker.js';....
我尝试添加 blob: 在 default-src 中,使用本地 pdf.js(这没有错误但不起作用)...
额外信息:
- api.js 是 pdf.js webpack 的一部分。
- 我的测试处于预生产阶段(在 localhost 中,控制台抛出 0 个错误)。
- 我没有用于 pdf.js 按钮栏的 CSS。
提前致谢!
【问题讨论】:
标签: javascript pdf content-security-policy pdf.js