简体   繁体   English

如何在acrobat中链接表单字段,以便它们表现为单个字段

[英]How to link form fields in acrobat so that they behave as a single field

How can I link together multiple fields in Acrobat, such that the user can continue to write in the next field when the current field is full? 如何在Acrobat中将多个字段链接在一起,以便当当前字段已满时用户可以继续在下一个字段中书写? Ideally, pasting data into one field would continue to paste into the next field(s) as well if the pasted string is too long for that field. 理想情况下,如果粘贴的字符串对于该字段来说太长,则将数据粘贴到一个字段中也将继续粘贴到下一个字段中。

In this specific case the fields are for entering an IBAN number in groups of 4 digits because that is the layout used on the paper form that lies under the PDF form fields: 在此特定情况下,这些字段用于输入4位数字的IBAN编号,因为这是在PDF表单字段下的纸质表单上使用的布局: IBAN字段

While it is not perfect, you can use the following function as a document-wide function. 虽然它并不完美,但是您可以将以下功能用作文档范围的功能。 The only problem is that the cursor is not currectly moved to the correct field when pasting text that spans multiple fields. 唯一的问题是,粘贴跨多个字段的文本时,光标不会正确地移动到正确的字段。

Acrobat 9: Advanced > Document Processing > Document JavaScripts Acrobat 9: 高级>文档处理>文档JavaScript
Acrobat 10: Tools > JavaScript > Document JavaScript Acrobat 10: 工具> JavaScript>文档JavaScript

function tab_chain(prev_field_name, next_fields) {
    // Move to next field if the current keystroke
    // fills the field. Move to the previous field
    // if the current keystroke empties the field.

    // Pasted data that is too long for the current
    // will be continued into the fields listed in
    // the next_fields array.

    var rest, prev, next, i;
    event.change = event.change.toUpperCase();
    rest = event.changeEx.toUpperCase();
    var merged = AFMergeChange(event);
    //console.println("Name: '" + event.target.name + "'");
    //console.println("Merged: '" + merged + "'");

    if (merged.length === event.target.charLimit) {
        //console.println("Limit: " + event.target.charLimit);
        i = 0;
        prev = event.target;
        next = getField(next_fields[i++]);
        rest = rest.substr(event.change.length);
        while (next !== null && rest.length > 0) {
            //console.println("Rest: " + rest);
            merged = rest.substr(0, next.charLimit);
            rest = rest.substr(merged.length);
            next.value = merged;
            prev = next;
            next = getField(next_fields[i++]);
        }
        // Update focus if previous pasted field is full.
        if (next !== null && merged.length === prev.charLimit) {
            next.setFocus();
        }
    }
    else if (merged.length === 0) {
        getField(prev_field_name).setFocus();
    }
}

Then, call this function as a custom keystroke script under Properties > Format . 然后,在“ 属性”>“格式”下,将此函数作为自定义按键脚本调用。 As the first parameter you pass the previous field in the chain (or the field itself if it is the first). 作为第一个参数,您传递链中的前一个字段(如果是第一个,则传递字段本身)。 As the second parameter you pass a list of the following fields in the chain. 作为第二个参数,您传递了链中以下字段的列表。 For example if your fields are called IBAN1, IBAN2, ..., IBAN6: 例如,如果您的字段称为IBAN1,IBAN2,...,IBAN6:

Script for IBAN1: tab_chain("IBAN1", ["IBAN2", "IBAN3", "IBAN4", "IBAN5", "IBAN6"]); IBAN1的脚本: tab_chain("IBAN1", ["IBAN2", "IBAN3", "IBAN4", "IBAN5", "IBAN6"]);
Script for IBAN2: tab_chain("IBAN1", ["IBAN3", "IBAN4", "IBAN5", "IBAN6"]); IBAN2的脚本: tab_chain("IBAN1", ["IBAN3", "IBAN4", "IBAN5", "IBAN6"]);
Script for IBAN3: tab_chain("IBAN2", ["IBAN4", "IBAN5", "IBAN6"]); IBAN3的脚本: tab_chain("IBAN2", ["IBAN4", "IBAN5", "IBAN6"]);
etc. 等等

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM