DrawPageCounterObject

Draws a page counter object on each page of the document at the given coordinates.

DrawPageCounterObject(x As Single, y As Single, Text As String, FontDictionaryName As String,
                      FontSize As Single, TextAlignment As pdf.TextAlignment, TextColor As Color)

Values passed to this procedure:

x, yThe x, y coordinates on the page to draw the page object.
TextThe text that makes up the page object.
FontDictionaryNameThe name used to reference the font within the document Font Dictionary. The FontDictionaryName is assigned to the font when you call LoadFont.
FontSizeThe em-size of the font.
TextAlignmentThe alignment of the text.
TextColorThe foreground color of the text.

Should be called right before ClosePDFFile.

Example

This exampe will show you how to create a ten page report, with a running page total on the top right corner of each page.

Dim cPDF As New vbPDF

With cPDF
  .ReportFileName = "c:\Page Numbers.pdf"
  .ScaleMode = pdf.ScaleMode.Inch
  .PaperSize = pdf.PaperSize.A4
  'To include a running page counter in the report, DisplayPageCounter must be true.
  .DisplayPageCounter = True

  If Not .CreatePDFFile() Then
    Exit Sub
  End If

  .LoadFont("ArialRegular", pdf.FontName.Arial, pdf.FontStyle.Regular)

  'Use a for loop to create a ten page document. Each page will contain "Page # of #,###" in the top right
  'corner of each page.

  For i As Integer = 0 To 9
    .StartPage()

    'We need to draw the "Page #" part of the running page counter on each page. The " of #,###" part will
    'be drawn right before the document is closed.

    'GetCurrentPageNumber returns the total number of pages currently in the document.

    .DrawText(.PageWidthInInch - 0.5, .PageHeightInInch - 0.2, "Page " & .GetCurrentPageNumber.ToString,
              "ArialRegular", 8, pdf.TextAlignment.Right, Color.Black)

    .EndPage()
  Next i

  'This will draw the " of #,###" on all pages.
  Dim strPageCount As String = " of " & Format(.GetCurrentPageNumber(), "###,###")

  .DrawPageCounterObject(.PageWidthInInch - 0.5, .PageHeightInInch - 0.2, strPageCount, "ArialRegular",
                         8, pdf.TextAlignment.Left, Color.Black)
  .ClosePDFFile()
End With