Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

DynaPDF Manual - Page 643

Previous Page 642   Index   Next Page 644

Function Reference
Page 643 of 750
SetFieldIndex
Syntax:
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
SortFieldByIndex().
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: SetFieldHighlightMode

Next topic: SetFieldName