Working on Other Pages

Let's imagine that you are preparing a long, very long report; you probably would like to number every single page; but the best thing of course should be to put aside each page number, the total number of pages of the report, something like this:

"Page 1 of 22" or "Page 1/22"

Again, you could be interested in creating an index for the whole document. If the index must be in the first page, you still don't know in which page every single chapter starts.

Well, here's come PDFReport's "SetCurrentPage" Method.

Calling this method you can jump back and forth in the Document, so you can for example leave the first page blank, write everything and, every time a capter starts, go back to the initial page and write inside it that chapter's name and page, thus returning to the last page.

Here's an example of page numbering:

Private Sub Command14_Click()
Dim PDFRPT As New PDFDocument
Dim i As Integer
Dim MaxPages As Integer
PDFRPT.NewPDF "This is my first PDF"
PDFRPT.FontName = "Helvetica-Bold"
PDFRPT.FontHeight = 12
' I use RND so i don't know how many ' pages I will have
MaxPages = CInt(Rnd(1) * 20)
For i = 1 To MaxPages
PDFRPT.TextOut "this is some text", 20, 20
If i <> MaxPages Then PDFRPT.AddPage
For i = 1 To MaxPages
PDFRPT.SetCurrentPage i
PDFRPT.TextOut "Page " & CStr(i) &_ " of " & CStr(MaxPages), 180, 280
PDFRPT.SavePDF "c:\provaocx.pdf"
End Sub

and the result (in the bottom right corner you can see the small text "Page 1 of 14")