InclForm: Include a form in current page   [ 39 ]

Description

Once function SetForm() has been invoked, usually at the start of the process meaning just after NewPdfy() function has been called, an integer number has been returned which will act as a kind of form handle.  Then, a program can issue this InclForm() function after the AddPage() one whenever it is required that a page includes the layout specified in Form.

This function takes one positive integer as a parameter which is assumed to be the "handle" of the form to be included.

 

C calling syntax
void InclForm (int formnumb)
Cobol calling syntax
Call "InclForm" using by value FORMNUMB.
C sample code
#include   "fpdf.h"

static char   f_ini ??(??) = ??< "ini??/??/demofpdf.ini" ??>;
static char   f_out ??(??) = ??< "pdf??/??/demo_h.pdf" ??>;
static char   bufr ??(128??), fieldname ??(8+1??);

/* ----------------------------------------------------------------- */

int  main (int argc, char *argv [])

??<
int    ii, jj, formnumb;

NewPdfy (f_ini, 10);
AliasNbPages ("#####");
formnumb = SetForm ("demo_h");

for (ii = 0; ii < 10; ii ++)
     ??<
     AddPage ("P");
     InclForm (formnumb);
     sprintf (bufr, "Page #%d / #####", ii + 1);
     ApplyTextProp ("PAGENUMB", bufr);
     for (jj = 0; jj < 18; jj ++)
         ??<
         sprintf (fieldname, "FIELD%03d", jj);
         sprintf (bufr, "Field #%d Value of page %d", jj, ii + 1);
         ApplyTextProp (fieldname, bufr);
         ??>
     ??>

FlushPdf (f_out, 2, "CUSTZZ", "demo_h");
??>
Description of sample code
This programs illustrates the power of forms related functions available in FPDF4ZOS.  It opens a PDF context, and imports a form and loops on 10 pages where this form is included.  In the loop, keeping in mind that this form includes 18+1 anchors, there is a scond loop in order ti fill all these fields with dummy data.

The following functions are used in this piece:
- NewPdfy()       -->  Initialisation of a pdf context
- AddPage()       -->  As it says
- SetLineWidth()  -->  Instruct that PDF is to be protected at user and owner levels
- SetDrawColor()  -->  Set the color of lines to be drawn
- SetFillColor()  -->  Set the color of area to be filled
- SetFont()       -->  Set current font
- SetForm()       -->  Specify a form to be included
- InclForm()      -->  Include a form within current page
- ApplyTextProp() -->  Display a piece of text with an anchor properties (Font, Color, Position)
- AliasNbPages()  -->  Specify an Alias for document total number of pages
- FlushPdf()      -->  Output PDF file taking into account all the instructions invoked since context initialization
See sample source code in 'C' as well as PDF execution result  -  NB: For encrypted PDFs, user password is USER-PSWD