【发布时间】:2020-07-29 19:22:16
【问题描述】:
我正在处理项目中的一个模块(.Net Core)的需求,该模块包含多个 PDF 操作,例如从 PDF 转换为 HTML,然后在 Web 视图编辑器中编辑 HTML,最后将其转换为PDF。
我使用提供的 JavaScript 代码来使用基于 Web 的 PDF 编辑器 (PDFTRON)。我在提供的官方文档PDFTron MANUAL INTEGRATION GUIDE 的帮助下尝试了手动集成。当我通过节点 js 运行时,我能够成功使用该库,但是当我在 Dotnet 核心中使用它时,它无法加载作为 memgrow.js 子部分的 simple_wasm/MemGrow.js.mem 文件,请在下面找到截图发生错误。
索引.cshtml
<div class="text-center">
<h1 class="display-4">Welcome</h1>
<p>
Learn about <a href="https://docs.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.
<label for="file_upload">Choose A file</label>
<input type="file" id="file_upload" name="file_upload" accept=".pdf">
</p>
</div>
<div id='viewer' style='width: 1024px; height: 600px;'> </div>
<script src="~/WebViewer/lib/webviewer.min.js"> </script>
<script>
const input = document.getElementById('file_upload');
WebViewer({
path: 'WebViewer/lib', // path to the PDFTron 'lib' folder on your server
licenseKey: 'Insert commercial license key here after purchase',
initialDoc: 'files/sample.pdf', // You can also use documents on your server
}, document.getElementById('viewer'))
.then(instance => {
const docViewer = instance.docViewer;
const annotManager = instance.annotManager;
// const Annotations = instance.Annotations;
input.addEventListener('change', () => {
debugger;
// Get the file from the input
const file = input.files[0];
instance.loadDocument(file, { filename: file.name });
});
docViewer.on('documentLoaded', () => {
// call methods relating to the loaded document
});
});
寻求帮助以在 .net 核心中提供解决方案。
【问题讨论】:
-
我怀疑可能没有为 IIS 设置 mime 类型,这就是它返回 404 的原因。尝试为此处列出的扩展添加 mime 类型pdftron.com/documentation/web/faq/mime-types/#pdf-and-office
-
@mparizeau 我在 IIS 中配置了文档链接中提供的所有 MIME 类型,但问题仍然存在。接下来我创建了新的网络解决方案并再次在 wwwroot 文件夹中配置了 webviewer,但没有成功,我不知道我还错过了什么。
标签: javascript .net pdf .net-core pdftron