ngx-extended-pdf-viewer
ngx-extended-pdf-viewer copied to clipboard
Event for the inital formData load from PDF
Is your feature request related to a problem? Please describe.
We are trying to track if a user has made changes to the formData - however it's not easy to track the 'starting data' because formDataChange event is not triggered on the initial population of the form data when loading the PDF - nor does it seem to be populated by the time the pdfLoaded event is triggered.
Describe the solution you'd like A clear and concise description of what you want to happen.
- Initial
formDatato have been correctly set by the time thepdfLoadedevent is triggered - Or, the initial load of the
formDatato emit theformDataChangeevent - Or, an specific event for the loading of the initial form fields/data being complete
Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.
- Using the
pdfLoadedto get theformData
Additional context Add any other context or screenshots about the feature request here.
I think your request makes sense. I've spent some thought on which data should have priority: the form data stored in the PDF file, or the data provided by the Angular application? It seems I didn't find the perfect solution yet.
If I get you correctly, the problem is not (formDataChange) with the original file. What's missing is an option to receive a (formDataChange) event if the user is opening another PDF. Did I get you right?
The issue happens with the original file too. You can see this if you bind (formDataChange), where you will see it's not fired until the user actually interacts with the inputs. I am looking for it to fire when the initial data from the PDF is loaded so I can capture that state before the user makes any changes.
Come to think about it, that's an interesting inconsistency of my API. I didn't want to fire (formDataChange) when the PDF form is loaded because at this point in time, there's no change at all. So Angular never learns about the data embedded in the form. However, when the user hits a key, that changes radically. The Angular application is sent all the embedded form data, not just the modified field.
I'm afraid modifying (formDataChange) amounts to a breaking change, so I don't want to do that. Maybe it's better to implement something like (initialFormData) or adding an attribute [sendInitialFormData]="true". However, both solutions look clumsy.
Agree those changes maybe a little clumsy but at least the (initialFormData) is explicit and simple. Another alternative is including the initial form data in the PdfLoadedEvent, alongside the pagesCount.
You had to wait a long time - but now your feature has landed. I didn't implement a new event because I noticed that the (annotationLayerRendered) can do that as well. Now the event emits a new field initialFormDataStoredInThePDF.
The feature has landed with version 20.0.0-alpha.3.