SetFont: Set Current Font [ 21 ]
Description
Set current font with which subsequent text is to be output by either Text(), Write() or Cell() functions. This function takes 3 parameters:
- Font Family: character string which may take five values which points at one of the 14 type 1 character fonts supported by PDF format without their being embedded in target file: Arial, Times, Courier, Zapfdingbats and Symbol.
- Font Syle : character string which points at the style of the font: can be either empty string (Normal style) or any combination of 3 charaters B, I, U: B meaning Bold, I meaning Italic and U meaning Underline. NB: a value of N is equivalent to an empty string.
- Font size : float number in the range 4 -> 72 which is the size of the character font to be applied.
- Helvetica name is systematically replaced by Arial, so that for either names may be used.
- For Symbol or ZapfDingbats fonts, Style is ignored. In other words, this style parameter is taken into account only for "Courier", "Arial" or "Times".
- Although empty string are supported for font style, it is nevertheless recommanded to use "N" instead, N standing for Normal. When this instruction is found in forms, N is mandatory because for technical reasons, empty strings are not supported when read from forms
C calling syntax
void SetFont (char *font_family, char *font_style, float font_size)
Cobol calling syntax
Call "SetFont" Using by value Pt1, Pt2, W.
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