ApplyTextProp: output a string with anchor properties   [ 52 ]

Description

This function applies the properties of a given anchor and outputs a text.  If the text length is null, the properties are still applied.  Finally, it returns a pointer to a {textprop} stucture which contains the properties thus retrieved.  It takes 2 parameters:
  1. A pointer to a character string which contains the anchor Id the properties of which are to be applied.
  2. Another pointer to a character string which is to be output if its length is positive.
Developers Notes:
  • The pointer returned actually points to a memory area located in the engine.  It is recommanded that the upper level program copies that area into one of its own areas, especially if for some reasons it wishes to modify it.  See Forms & Anchor page for a description of a text property structure.
  • If the anchor does not exist, internal structure pointed to by return address will have an anchor ID equal to "NOTFOUND".  Moreover, variables within that structure will be assigned the following default values:
    • x    →  20
    • y    →  20
    • ix   →  15
    • iy   →  5
    • cr   →  0                  // Black text color
    • cg   →  0
    • cb   →  0
    • font →  "Courier"
    • fst  →  "B"
    • fsz  →  10

C calling syntax
textprop * ApplyTextProp (char *anchor, char *text)
Cobol calling syntax
CALL "ApplyTextProp" using by value ANCHOR,TEXT returning PTXTP.
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