DynaPDF Manual - Page 705

Previous Page 704   Index   Next Page 706

Function Reference
Page 705 of 818
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");
pdfSetDocInfo(pdf, diCreator, "Tab order");
pdfCreateNewPDF(pdf, "c:/cppout.pdf");
pdfSetPageCoords(pdf, pcTopDown);
pdfAppend(pdf);
y = 50.0; index = 0;
for (SI32 i = 0; i < 50; i++)
{
sprintf(tmp, "Field %d", i);
if (i & 1)
{
// This is the second column, the field indices can be left
// unchanged because they are above 1000.
pdfCreateTextField(pdf, tmp, -1, false, 0, 210, y, 150, 20);
y += 25.0; // goto the next line
}else
{
field = pdfCreateTextField(pdf, tmp, -1, false,0,50,y,150,20);
 

Previous topic: SetFieldFontSize, SetFieldHighlightMode, SetFieldIndex

Next topic: SetFieldMapName, SetFieldName


Start Chat