DynaPDF Manual - Page 668

Previous Page 667   Index   Next Page 669

Function Reference
Page 668 of 777
LBOOL pdfSetFieldIndex(
const PPDF* IPDF, // Instance pointer
UI32 AField,
// Field handle
UI32 Index)
// New field index (this represents the tab order)
This function can be used to set the tab order of interactive form fields. All fields, independently
whether they are created with DynaPDF or imported from external documents, holds in internal
index which can be used to reorder or sort the fields with this index.
The start index of a new field is not zero, it is 1000 instead. This makes it easier to set a field in front
of all other fields without changing all field indices. However, changing a field index changes not the
tab order directly, the fields of a page must be sorted before the page will be closed with the function
The tab order of interactive form fields must be set for each page separately.
Return values:
If the function succeeds the return value is 1. If the function fails the return value is 0.
Example (C++):
In this example we create 50 text fields in two columns. The order in which the fields are created is
line by line, not column by column. Execute the example and open the file with Acrobat or Reader.
You can see now that the tab order is column by column, not line by line as the fields were created.
Comment out the SortFieldsByIndex() function call and create the file again; the tab order is now line
by line.
Take a look onto the for-statement; we set the field index of the text fields of the first column only.
The other fields can be left unchanged because their index lies between 1001 and 1049.
#include "dynapdf.h"
using namespace DynaPDF;
// First we declare our error callback function
SI32 PDF_CALL PDFError(const void* Data, SI32 ErrCode, const char*
ErrMessage, SI32 ErrType)
printf("%s\n", ErrMessage);
return 0;
int main(int argc, char* argv[])
char tmp[30]; double y; SI32 field, index;
PPDF* pdf = pdfNewPDF(); // Create a PDF instance
if (!pdf) return 2;
// Out of memory?
pdfSetOnErrorProc(pdf, NULL, PDFError);
pdfSetDocInfo(pdf, diCreator, "C++ sample project");
pdfSetDocInfo(pdf, diSubject, "Tab order");

Previous topic: SetFieldFontSize, SetFieldHighlightMode

Next topic: SetFieldMapName, SetFieldName