【问题标题】:adobe-dc-view dynamic URLadobe-dc-view 动态 URL
【发布时间】:2021-06-04 06:50:59
【问题描述】:

我想用 adobe dc view 从 c# 后面的代码中获取文件, 而且我不知道该怎么做,而且我在互联网上找不到示例。

如果有人可以帮忙,这里是代码

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">  
  <meta charset="UTF-8">
  <meta name="Generator" content="EditPlus®">
  <meta name="Author" content="">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
  <title>Document</title>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<div id="adobe-dc-view"></div>
<script src="https://documentcloud.adobe.com/view-sdk/main.js"></script>
<script type="text/javascript">
    document.addEventListener("adobe_dc_view_sdk.ready", function () {
        var adobeDCView = new AdobeDC.View({ clientId: "xxxxxxxxxx", divId: "adobe-dc-view" });
        adobeDCView.previewFile({
            content: { location: { url: "myfile.pdf" } },
            metaData: { fileName: "myfile.pdf" }
        }, {
showAnnotationTools: false, showLeftHandPanel: false, showDownloadPDF: false,showPrintPDF: false });
    });
</script>
</asp:Content>

【问题讨论】:

    标签: c# asp.net pdf adobe adobe-embed-api


    【解决方案1】:

    不使用 content.location.url,而是将内容作为解析为 ByteArray 的 Promise 传递。让您的 C# 应用程序将 Blob 返回到 HTML 页面,然后通过 Promise 将其加载到 Embed API (view-sdk) 中。

    adobeDCView.previewFile(
          {
            content: { promise: Promise.resolve(blob.arrayBuffer()) },
            metaData: { fileName: url.split("/").slice(-1)[0] }
          },
    

    完整代码在this CodePen

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多