Copy link to clipboard
Copied
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
}
);
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()
...
Copy link to clipboard
Copied
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
}
);
Copy link to clipboard
Copied
Thank you. It is working now.