Copy link to clipboard
Copied
Hi
I am currently facing an issue where we have built a view that uses the PDF Embed API.
Next to the view, we have located some user fields like "filename, date, notes, ..."
Bellow these fields is a "save" button, to save the data.
The issue:
- I can't seem to find a way to detect if the PDF has unsaved changes. Because now when the user clicks our "save" button, he loses his PDF changes.
What have we tried:
- Annotation listener. This works for "marking", "drawing", ... but NOT for "text fields", "radio buttons", ...
I understand why, as these are not "annotations.
- I have tried to always show the save button but without changes, it is greyed out, so I still can't force the user to first update his document.
What I would like (if order of preference):
Option 1: To be able to trigger the save programmatically. This way, our button can work as the main save button.
Option 2: have an event listener that exposes when the adobe save button is showed and enabled. This way, I can disable my button and show text that they first need to click the other button. not so user friendly but it would work.
Option 3: have an event listener on field, radiobutton, checkbox, ... changes. this I can then add to our current annotation listeners to have a "workaround".
Option 4: maybe someone has a much better idea but visually we want to have the PDF next to the fields as they are in a "bootstrap modal".
Hoping for a solution.
Greetings
Brent
Copy link to clipboard
Copied
I have a CodePen showing how to submit to a server via the Save button here.
Copy link to clipboard
Copied
Having the same issue here, did you find any solution?
I tried to check the existence of an enabled save button in the DOM as well, but since it is within an iframe I'm running into cross origin issues.
I think there needs to be at least one way to reliably check if a PDF is in an unsaved state.
Copy link to clipboard
Copied
Hi Alexander
I didn't find a solution for the auto save.
For the detection, there I did find a partial solution.
In the method "previewFile"
{ defaultViewMode: "FIT_WIDTH", enableAnnotationAPIs: true, includePDFAnnotations: true }
=> I thnk the "enableAnnotationAPIs" was the import one. Maybe the other one also.
=> If you don't enable the API then the next part won't fire events.
const eventOptions = {
// Pass the events to receive.
// If no event is passed in listenOn, then all the annotation events will be received.
listenOn: ["ANNOTATION_ADDED", "ANNOTATION_UPDATED", "ANNOTATION_DELETED"]
}
previewFilePromise.then(adobeViewer => {
adobeViewer.getAnnotationManager().then(annotationManager => {
annotationManager.registerEventListener((e) => { <this code is triggered when annotation event is received> },
eventOptions
);
});
})
The above works for "text marking", "text comments", "drawing" (with delay of few seconds)
But it doesn't work for text that is being filled in, in fields in the PDF.
As this does not count as "annotation".
Copy link to clipboard
Copied
Also looking for a solution to this problem. We are trying out the Embed API by opening it in a modal window. I need to be able to detect if there are unsaved changes so that I can prevent the modal from being closed before they've saved, or let them ignore the changes and close anyway.
Having the events for DOCUMENT_PRISTINE, and DOCUMENT_DIRTY would solve this. Or even adding a `dirty` class to the iframe that we can inspect would work.