ngx-extended-pdf-viewer icon indicating copy to clipboard operation
ngx-extended-pdf-viewer copied to clipboard

Event for the inital formData load from PDF

Open luke-rogers opened this issue 2 years ago • 4 comments

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.

  1. Initial formData to have been correctly set by the time the pdfLoaded event is triggered
  2. Or, the initial load of the formData to emit the formDataChange event
  3. 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 pdfLoaded to get the formData

Additional context Add any other context or screenshots about the feature request here.

luke-rogers avatar Oct 19 '23 15:10 luke-rogers

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?

stephanrauh avatar Oct 19 '23 20:10 stephanrauh

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.

luke-rogers avatar Oct 20 '23 10:10 luke-rogers

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.

stephanrauh avatar Oct 20 '23 20:10 stephanrauh

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.

luke-rogers avatar Oct 30 '23 08:10 luke-rogers

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.

stephanrauh avatar Apr 21 '24 20:04 stephanrauh

The feature has landed with version 20.0.0-alpha.3.

stephanrauh avatar Apr 21 '24 20:04 stephanrauh