NewPdfy: Creation of a PDF context   [ 56 ]

Description

Initialisation of FPDF4MVS library while setting parameters according to the content of a configuration file name.  Maximum anticipated page number is also specified and should be positive. This function gives a return code: true if successful, false otherwise, especially in case configuration file is not found. For a description of Configuration file, see page related to Configuration File. This function MUST be called before any other action may be invoked from FPDF4ZOS engine.  If another function is called before a PDF context is allocated byt that very function, that call will be ignored with a warning message in SYSOUT - stdout. If NewPdfy() is called a second time before any Output() or FlushPdf() function is invoked, it will be also ignored with yet another warning message.

Developper Notes:


In order to build a PDF, FPDF4ZOS engine allocates various memory areas the sizes of which obviously depend on anticipated PDF content.  It has been established that a basic information about PDF content is the number of pages it will contain and therefore, this anticipated page number is an important basic information for memory allocations.  However, users are cautioned that:
  • Too high a value may cause too large memory areas allocated, resulting in resource wasting.
  • Too low a value may cause a failure to build target PDF somewhere down the line.
 

C calling syntax
int Newpdfy (char *file_ini, int nb_pages)
Cobol calling syntax
CALL CALLPDF USING BY CONTENT APDF-NEWPDFY, PTRI, FILE_INI, NB_PAGES.
C sample code
#include   "fpdf.h"

static char   f_ini ??(??) = ??< "ini??/??/demofpdf.ini" ??>;
static char   f_out ??(??) = ??< "pdf??/??/demo_a.pdf" ??>;

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

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

??<
NewPdfy (f_ini, 1);
AddPage ("P");
SetFont ("Times", "B", 24);
SetTextColor (0, 100, 200);
Text (20, 25, "What is written below is TRUE");
SetTextColor (0, 200, 100);
Text (20, 50, "What is written above is FALSE");
Output (f_out);
??>
Cobol sample code
       Procedure division.
           Set Pt0 to Address of T0.
           Set Pt1 to Address of T1.
      *
           String 'DD:FINI' Low-Value delimited by size into T0.
           Move 2 to NbPages.
           Call "NewPdfy" Using by value Pt0, NbPages returning PdfRC.
      *
           String 'P' Low-Value delimited by size into T0.
           Call "AddPage" Using by value Pt0.
      *
           Move  20 to W.
           String 'Times' Low-Value delimited by size into T0.
           String 'N' Low-Value delimited by size into T1.
           Call "SetFont" Using by value Pt0, Pt1, W.
      *
           Move   0 to R.
           Move   100 to G.
           Move   200 to B.
           Call "SetTextColor" Using by value R,G,B.
           Move   0 to R.
           Move   100 to G.
           Move   200 to B.
           Call "SetTextColor" Using by value R,G,B.
           Move   20 to X.
           Move   25 to Y.
           String 'What is written below is TRUE ' Low-Value delimited by size into T0.
           Call "Text" Using by value X, Y, Pt0.
      *
           Move   200 to G.
           Move   100 to B.
           String 'What is written above is FALSE ' Low-Value delimited by size into T0.
           Move   50 to Y.
           Call "Text" Using by value X, Y, Pt0.
      *
           String  'DD:FOUT' Low-Value delimited by size into T0.
           Call "Output" using by value Pt0.
      *
Description of sample code
This piece of code illustrates the most basic functions found in FPDF4ZOS interface.
- NewPdfy()       -->  Initialisation of a pdf context
- AddPage()       -->  As it says
- SetFont()       -->  Set current font
- SetTextColor()  -->  Set Text Color
- Text()          -->  Write a piece of Text at position [X,Y]
- Output()        -->  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