indesign interactive pdf tab order

Sort the tab order for interactive pdfs.

Name your fields:

1,field name

2,another field

3, and another field

If you need to insert fields, name the field 1.5, inserted field. This would insert the field between 1 and 2

No error checking.

Always backup your work before using this script.

//DESCRIPTION: Form Field order.

//kerntiff.co.uk


#targetengine "FormFieldOrder";


main ();

function main ()

{

if ( app.documents.length <= 0 )

return;


var formFields = [];


formFields = app.activeDocument.layoutWindows[0].activePage.tabOrder;


formFields.sort ( function ( a, b )

{

var aN = Number ( a.name.split ( ",")[0] );

var bN = Number ( b.name.split ( ",")[0] );

if ( aN < bN )

return ( -1 );

if ( aN > bN )

return ( 1 );

return ( 0 );

});


app.activeDocument.layoutWindows[0].activePage.tabOrder = formFields;


}