DynaPDF Manual - Page 303

Previous Page 302   Index   Next Page 304

Function Reference
Page 303 of 839
Notice: If a form contains a button with a Submit Form Action then it is recommended to exclude
the button field from locking so that it is still possible to submit the form data. Otherwise, the entire
form is locked, incl. the submit button, and it is impossible to submit the form data to a web server.
Example (C++):
In this example we create a simple form with only one text field and an empty signature field. The
form should be signed by the user after it has been filled in and then submitted to a web server. The
submit button is hidden when the form is created; it becomes visible after the document has been
signed. Note that this example works only with the full version of Adobe's Acrobat 5 or higher.
#include "dynapdf.h"
using namespace DynaPDF;
// Error callback function.
SI32 PDF_CALL PDFError(const void* Data, SI32 ErrCode, const char*
ErrMessage, SI32 ErrType)
printf("%s\n", ErrMessage);
return -1; // We break processing if an error occurs
int main(int argc, char* argv[])
PPDF* pdf = pdfNewPDF();
if (!pdf) return 2; // Out of memory?
char outFile[] = "c:/cppout.pdf";
// Error messages and warnings are passed to the callback function.
pdfSetOnErrorProc(pdf, NULL, PDFError);
if (!pdfCreateNewPDF(pdf, outFile))
return 1;
pdfSetPageCoords(pdf, pcTopDown);
pdfCreateTextField(pdf, "Test", -1, false, 0, 50.0, 50.0, 200.0, 16.0);
SI32 sig = pdfCreateSigField(pdf,"Signature",-1,50.0,70.0,200.0,30.0);
// We exclude the button from locking, otherwise it would be impossible
// to execute the submit form action. The submit button becomes
// visible after the document has been signed.
char s[] = "AFSignature_Format(\"EXCEPT\", new Array(\"Submit\"));\n"
"var f = this.getField(\"Submit\");\nf.hidden=false;\n";
SI32 act = pdfCreateJSAction(pdf, s);
pdfAddActionToObj(pdf, otField, oeOnFormat, act, sig);
pdfSetBorderStyle(pdf, bsBevelled);
pdfSetFieldBackColor(pdf, PDF_SILVER);
SI32 btn = pdfCreateButton(pdf,"Submit","Submit",1,50,110,100, 20);
pdfSetFieldFlags(pdf, btn, ffHidden, false);

Previous topic: CreateSigField, How to lock an Interactive Form after signing?

Next topic: CreateSigFieldAP