SetForm: Import a Form   [ 38 ]


This function enables a program to take into account a page layout found in forms library.  It takes a parameter which is a pointer on an 8 character string which identifies target form to be imported.  If successful, it returns a form handle which is a positive integer which should be specified in function InclForm() when program wishes to include a layout. Developper Notes:
  1. For MVS environment, this form is supposed to be stored as a member of a PDS or PDSE the name of which is defined in configuration file read upon execution NewPdfy() function.  For Windows-Linux environment, FPDF4ZOS will automatically build an absolute file name formed of { the concatenation of root name  defined in configuration file, that 8 character string and a final suffix for extension ".frm". }
  2. If this function is called again with the same form ID, it will return without doing anything while a warning message will appear in stdout indicating that the form has already been taken into account.

C calling syntax
int SetForm (char *pfrm)
Cobol calling syntax
Call "SetForm" returning NBFORM using by value PFRM.
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