WebViewer Version: v10.6
Do you have an issue with a specific file(s)? Particular XFDF fields (see below)
Can you reproduce using one of our samples or online demos? N/A
Are you using the WebViewer server? No
Does the issue only happen on certain browsers? No
Is your issue related to a front-end framework? No
Is your issue related to annotations? Yes/Fields
Please give a brief summary of your issue:
We have a feature we’re trying to build that allows users to right click on a field and then fill the field from a custom context menu we provide them. We are having trouble accessing the Field object from the contextMenu event.
Please describe your issue and provide steps to reproduce it:
Our code is a bit janky - very keen on feedback if there’s an easier way to achieve this. We can access the Field in most cases by:
- Get the parent div of the input element. Then get the id of that div.
- Use
const field = fieldManager.getFieldByName(parentDivId)
const.setValue(clickedValue)
However, this feels hacky and breaks when we have fields that are nested in a PDF document. An example of XFDF data where this doesn’t work is:
<field name="Text1">
<field name="0">
<field name="0">
<value>%^last_name^%</value>
</field>
<field name="2">
<field name="0">
<field name="0">
<value>%^first_name^%</value>
</field>
<field name="1">
<value>%^middle_name^%</value>
</field>
<field name="2">
<value></value>
</field>
</field>
</field>
</field>
</field>
Unfortunately as this feature is designed to allow user uploaded PDF Forms we can’t always control the format of the incoming PDF Form so handling nested fields like this is a requirement of ours.
Is there an easier way to achieve what we’re trying to do? We have also tried using the annotationManager.getAnnotationByMouseEvent(event)
function but found that this doesn’t get the Field - I believe because Field objects are different than Annotation objects.