Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fieldValue always empty #6995

Closed
ezsper opened this issue Feb 15, 2016 · 9 comments
Closed

fieldValue always empty #6995

ezsper opened this issue Feb 15, 2016 · 9 comments

Comments

@ezsper
Copy link

ezsper commented Feb 15, 2016

When getting form fields with getAnnotation, fieldValue is always empty for checkboxes and radios. Look at the console screenshot, the correct value should be Male for the named radio field of gender.

fieldvalueempty

@timvandermeij
Copy link
Contributor

We are not handling all widget annotation types yet, so this might be a consequence of that.

@ezsper
Copy link
Author

ezsper commented Feb 15, 2016

I'm aware that annotations are not fully supported, but this seems to be an issue of the beta version or maybe it's not meant to support forms at all, but 1.3 get the values just fine.

@xlc
Copy link
Contributor

xlc commented Feb 15, 2016

I don't see any issue here. The fieldValue is the FT field and you are looking at sub dictionary of AP (appearance dictionary) field.

@ezsper
Copy link
Author

ezsper commented Feb 16, 2016

No, it's not. At least not for radios and checkboxes, or at least not in this version of pdf.js. I just know for sure that the field has the specified value Male, and the pdf form that is being parsed was created by hand. In the pdf.js 1.3 it came the correct value for the field, but in the 1.4 beta, it came as empty.

@ezsper
Copy link
Author

ezsper commented Feb 16, 2016

This doesn't work for buttons either.

What I'm doing is injecting in core/annotation.js close to line 572 something like this:

var fieldValue = Util.getInheritableProperty(dict, 'V');

if(fieldType == 'Btn') {
  if(fieldFlags & 65536) {
    //buttons
    try{
      fieldValue = dict.get('MK').get('CA');
    } catch(e) {}
  } else {
    //radios and checkboxes
    try{
      var values = Object.keys(dict.get('AP').get('N').map).reverse(), found = false;
      values.forEach(function(value) {
        if(value !== 'Off') {
          found = true;
          fieldValue = value;
        }
      })
      if(!found) fieldValue = 'Off';
    } catch(e) {}
  }
}

fieldValue = stringToPDFString(fieldValue || ''); 

Probably not the best approach, but is doing the trick at least.

@brendandahl
Copy link
Contributor

Can you post an example pdf?

@ezsper
Copy link
Author

ezsper commented Feb 16, 2016

@timvandermeij
Copy link
Contributor

Closing as fixed by #7898. Pushbuttons are tracked in #7613.

@drakar4ik
Copy link

now if radio's parent has no value (all radios unchecked), radio's buttonValue ("on" value) is null.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants