PageNo: Get Current Page Number [ 11 ]
This function returns the current page number of the PDF document being built. It does not take any parameter and returns an integer which is the current page number.
C calling syntax
int PageNo (void)
Cobol calling syntax
Call "PageNo" returning PgNumb.
C sample code
#include "fpdf.h" static char f_ini ??(??) = ??< "ini??/??/demofpdf.ini" ??>; static char f_out ??(??) = ??< "pdf??/??/demo_d.pdf" ??>; static char buf0 ??(128??); /* ----------------------------------------------------------------- */ int main (int argc, char *argv ) ??< int ii, jj; char *ptr; NewPdfy (f_ini, 1); jj = P_MODIFY + P_ANNOT_FORMS; SetProtection (jj, "USER-PSWD", "OWNER-PSWD"); for (ii = 0; ii < 9; ii ++) begin AddPage("L"); jj = PageNo (); sprintf (buf0, "numbers%d", jj); if ((ii & 1) == 0) ptr = ""; else ptr = "http://www.cnn.com"; Image (buf0, 50, 20, 200, 0, "jpg", ptr); sprintf (buf0, "Page %d", jj); Bookmark (buf0, 0, 0); end Output (f_out); ??>
Description of sample code
This piece of code illustrates various functions found in FPDF4ZOS interface. It opens a PDF context and specifies that the document ought to be protected at both levels: - It requires from users to key the string USER-PSWD in order to be able to read the document => encryption at user level. - It further encodes the document at owner level, forbidding Print and copy-paste features. In order to change these protections, a user should key password OWNER-PSWD. Program then performs a loop on 9 pages in each of which a different image is inserted. Note that in the even pages, the image carries a link to web site www.cnn.com. The following functions are used in this piece: - NewPdfy() --> Initialisation of a pdf context - AddPage() --> As it says - SetProtection() --> Instruct that PDF is to be protected at user and owner levels - Image() --> Insert an image into a PDF document - Bookmark() --> Insert an bookmark into a PDF document - PageNo() --> Retrieve current page number while building PDF document - FlushPdf() --> Output PDF file taking into account all the instructions invoked since NewPdfy or previous FlushPdf
See sample source code in 'C' as well as PDF execution result - NB: For encrypted PDFs, user password is USER-PSWD