Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

File Preview Events no longer firing

Community Beginner ,
Feb 18, 2021 Feb 18, 2021

Hello,

 

Are there any possible reasons, why FilePreviewEvents are no longer firing?

We registered the 2 callbacks below, the PDFAnalyticsEvents are firing but not the FilePreviewEvents.

This is working before, but we don't what has changed. We don't get any javascript errors on the browser console.

 

 

    adobeDCView.registerCallback(
        AdobeDC.View.Enum.CallbackType.EVENT_LISTENER,
        function (event) {
            alert.log("Event: " + event.type);
            if (event.type === "PREVIEW_SELECTION_END") {
                previewFilePromise.then(adobeViewer => {
                    adobeViewer.getAPIs().then(apis => {
                        apis.getSelectedContent()
                            .then(result => {
                                selectedText = result.data;
                                console.log("selectedText = " + selectedText);
                            })
                            .catch(error => console.log(error));
                    });
                });
            }
        }, {
            enableFilePreviewEvents: true
        }
    );


    adobeDCView.registerCallback(
        AdobeDC.View.Enum.CallbackType.EVENT_LISTENER,
        function (event) { 
            alert("event", event);
            var copiedText = event.data.copiedText;

            var frame = document.querySelector('#propIFrame');
            if (frame && frame.contentWindow) {
                var selectedField = frame.contentWindow.lastFocusedField; 
                if (selectedField && /(input|select|textarea)/i.test(selectedField.nodeName)) {
                    selectedField.value = copiedText;
                }
            }
        }, {
            //Pass the PDF analytics events to receive.
            //If no event is passed in listenOn, then all PDF analytics events will be received.
            listenOn: [AdobeDC.View.Enum.PDFAnalyticsEvents.TEXT_COPY],
            enablePDFAnalytics: true
        }
    );

 

TOPICS
PDF Embed API
816
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Employee , Feb 18, 2021 Feb 18, 2021

Thanks for using PDF Embed API. Your code snippet is overriding the previous event listener. To handle such scenarios, you can do something like that

adobeDCView.registerCallback(
        AdobeDC.View.Enum.CallbackType.EVENT_LISTENER,
        function (event) {
            if (event.type === "PREVIEW_SELECTION_END") {
                previewFilePromise.then(adobeViewer => {
                    adobeViewer.getAPIs().then(apis => {
                        apis.getSelectedContent()
                
...
Translate
Adobe Employee ,
Feb 18, 2021 Feb 18, 2021

Thanks for using PDF Embed API. Your code snippet is overriding the previous event listener. To handle such scenarios, you can do something like that

adobeDCView.registerCallback(
        AdobeDC.View.Enum.CallbackType.EVENT_LISTENER,
        function (event) {
            if (event.type === "PREVIEW_SELECTION_END") {
                previewFilePromise.then(adobeViewer => {
                    adobeViewer.getAPIs().then(apis => {
                        apis.getSelectedContent()
                            .then(result => {
                                selectedText = result.data;
                                console.log("selectedText = " + selectedText);
                            })
                            .catch(error => console.log(error));
                    });
                });
            } else if (event.type === AdobeDC.View.Enum.PDFAnalyticsEvents.TEXT_COPY) {
            
            var copiedText = event.data.copiedText;
            var frame = document.querySelector('#propIFrame');
            if (frame && frame.contentWindow) {
                var selectedField = frame.contentWindow.lastFocusedField; 
                if (selectedField && /(input|select|textarea)/i.test(selectedField.nodeName)) {
                    selectedField.value = copiedText;
                }
            }
}
        }, {
            enableFilePreviewEvents: true,
            enablePDFAnalytics: true
        }
    );

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 21, 2021 Feb 21, 2021
LATEST

Thank you. It is working now.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources