0

I want to get the file from the code behind in c# with adobe dc view , and i don't know how to do it , and i don't find examples on internet.

If anyone can help , here is The code

<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>
Raymond Camden
  • 10,661
  • 3
  • 34
  • 68
Bennani HAMZA
  • 163
  • 2
  • 10

1 Answers1

1

Instead of using content.location.url, pass the content as a Promise that resolves to a ByteArray. Have your C# application return a Blob to the HTML page and then load that into Embed API (view-sdk) via the Promise.

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

The full code is at this CodePen

joelgeraci
  • 4,606
  • 1
  • 12
  • 19