The pdform.js library is not encoded korean only in selectbox and checkbox

Viewed 25

enter image description here

Using the js library called pdform.js, the pdf form was read as follows:

Other text forms and individual check boxes encode normally.

Only check boxes, radio buttons, and select boxes cannot be encoded. No matter how hard I look, I can't answer.

The code is too long to attach, but I think there is a problem with the code below here.

function list(buf) {
    
    var list_form = document.querySelector('.list_form');
    empty(list_form);

    var cnt = 1;
    var field_specs;
    try {
        field_specs = make_pdfform().list_fields(buf);
    } catch (e) {
        on_error(e);
        return;
    }
    for (var field_key in field_specs) {
        var row = document.createElement('div');
        row.appendChild(document.createTextNode(field_key));
        list_form.appendChild(row);
        field_specs[field_key].forEach(function(spec, i) {
            for(var key in spec) console.log(key + " = " + spec[key]);
            if ((spec.type === 'radio') && spec.options) {
                var fieldset_el = document.createElement('fieldset');
                spec.options.forEach(function(ostr) {
                    var label = document.createElement('label');
                    var radio = document.createElement('input');
                    radio.setAttribute('type', 'radio');
                    radio.setAttribute('value', ostr);
                    radio.setAttribute('name', field_key + '_' + i);
                    radio.setAttribute('data-idx', i);
                    radio.setAttribute('data-key', field_key);
                    label.appendChild(radio);
                    label.appendChild(document.createTextNode(ostr));
                    fieldset_el.appendChild(label);
                });
                row.appendChild(fieldset_el);
                return;
            }

            var input = document.createElement((spec.type === 'select') ? 'select' : 'input');
            input.setAttribute('data-idx', i);
            input.setAttribute('data-key', field_key);
            if (spec.type === 'boolean') {
                input.setAttribute('type', 'checkbox');
            } else if (spec.type === 'string') {
                
            } else if ((spec.type === 'select') && spec.options) {
                spec.options.forEach(function(ostr) {
                    var option_el = document.createElement('option');
                    
                    //problem part
                    option_el.appendChild(document.createTextNode(ostr));
                    option_el.setAttribute('value', ostr);
                    input.appendChild(option_el);
                     
                });
            }
                    
            row.appendChild(input);

        });
    }
}

0 Answers
Related