문제

I use pdf.js library to generate html5 page from pdf but some capabilities not working. I try to get value for input radio but still abortively:( For example, in core.js script there are a few lines of code that take type of field:

var fieldType = getInheritableProperty(annotation, 'FT');
            if (!isName(fieldType))
              break;
            item.fieldType = fieldType.name;

How I can get feild value?

도움이 되었습니까?

해결책

I found the solution that work form me! Add this code around line 260 of core.js file:

function setRadioButton(annotation, item) {
    var ap = annotation.get('AP');
    var nVal = ap.get('N');
    var i = 0;
    nVal.forEach(function(key, value){
        i++;
        if(i == 1 || i == 2) {
            if(key != 'Off')
                item.value = key;
        }
    });
}

And this code around line 370 of core.js file:

if (item.fieldType == 'Btn') {
    if (item.flags & 32768) {                   
        setRadioButton(annotation, item);
    }
}

Also, if you want to get values from select input, you can use this code:

if(item.fieldType == 'Ch') {
    item.value = annotation.get('Opt') || []; //return array of values
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top