Skip to main content
Participant
August 6, 2022
Answered

Adobe Embed Not Saving

  • August 6, 2022
  • 1 reply
  • 868 views

Hello! Just started using the Embed API. I am viewing a file from an DigitalOcean Spaces storage but when I save after marking it up, it doesn't update. Any help would be appreciated! Here is my code:

<!DOCTYPE html>
{% load static %}
<html lang="en">
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta id="viewport" name="viewport" content="width=device-width, initial-scale=1"/>

    <link rel="shortcut icon" href="{% static 'assets/images/favicon.png' %}" />
</head>

<body style="margin: 0px">
 <div id="adobe-dc-view"></div>
 <script src="https://documentcloud.adobe.com/view-sdk/viewer.js"></script>
 <script>
        var document_url = '{{ url }}';
        var file_name = '{{ filename }}';
        var read_only = {{ read_only }};
        var adobe_key = '{{ adobe_embed_key }}';

        const profile = {
            userProfile: {
                name: '{{ user.name }}',
                firstName: '{{ user.fname }}',
                lastName: '{{ user.lname }}',
                email: '{{ user.email }}'
            }
        };

        const saveOptions = {
            autoSaveFrequency: 0,
            enableFocusPolling: false,
            showSaveButton: true
        };
    </script>
    <script type="text/javascript" src="{% static 'assets/js/htw/adobe-embed.js' %}"></script>
</body>
</html> 

Here is the JS:

document.addEventListener("adobe_dc_view_sdk.ready", function() {
    var adobeDCView = new AdobeDC.View({
         clientId: adobe_key,
         divId: "adobe-dc-view"
    });

    adobeDCView.registerCallback(
        AdobeDC.View.Enum.CallbackType.SAVE_API,
        function(metadata, content, options) {
            return new Promise((resolve, reject) => {
                resolve({
                    code: AdobeDC.View.Enum.ApiResponseCode.SUCCESS,
                    data: {
                        metaData: { fileName: document_url }
                    }
                });
            });
        }, saveOptions
    );

    adobeDCView.registerCallback(
        AdobeDC.View.Enum.CallbackType.GET_USER_PROFILE_API,
        function() {
            return new Promise((resolve, reject) => {
                resolve({
                    code: AdobeDC.View.Enum.ApiResponseCode.SUCCESS,
                    data: profile
                });
            });
        },
    );

    adobeDCView.previewFile({
        content: {
            location: {
                url: document_url
            }
        },
        metaData: {
            fileName: file_name,
            hasReadOnlyAccess: read_only
        }
    });
});
This topic has been closed for replies.
Correct answer Raymond Camden

Because you need to implement code to take the bits and save it yourself. We give you a hook to notice and customize the save process, but you have to actually handle doing it.

1 reply

Raymond Camden
Community Manager
Raymond CamdenCommunity ManagerCorrect answer
Community Manager
August 8, 2022

Because you need to implement code to take the bits and save it yourself. We give you a hook to notice and customize the save process, but you have to actually handle doing it.

Participant
August 8, 2022

Yup, I realized that shortly after. Working now, thanks!