GetPageCount
IPDFDocument4 :: General document management :: Common

See Also Example
Collapse All

This method gets the number of pages in the current PDF document.

Syntax

LONG GetPageCount ()
Return value
Number of pages in the current PDF document

Remarks

PageCount returns the total number of pages in the PDF document.

Example

Using the PageCount Method

Delphi
[copy to clipboard]
{ PDF object is supposed to be created }
font := PDF.AddFont('Arial', false, false, false, false, fcDefault);
PDF.NewPage;
PDF.NewPage;
for i := 0 to PDF.GetPageCount()-1 do
begin
    PDF.CurrentPage := i;
    PDF.UseFont(font, 10);
    PDF.ShowTextAt(10, 10, 'Page ' + IntToStr(i + 1));
end;
PDF.SaveToFile('test.pdf', true);
C/C++
[copy to clipboard]
// PDF object is supposed to be created
long font = PDF->AddFont("Arial", false, false, false, false, fcDefault);
PDF->NewPage();
PDF->NewPage();
for (int i = 0; i < PDF->GetPageCount(); i++)
{
    PDF->CurrentPage = i;
    PDF->UseFont(font, 10);
    CString str;
    str->Format("Page %d", i + 1);
    PDF->ShowTextAt(10, 10, str);
}
PDF->SaveToFile("test.pdf", true);
C#
[copy to clipboard]
// PDF object is supposed to be created
long font = PDF.AddFont("Arial", false, false, false, false, FontCharset.fcDefault);
PDF.NewPage();
PDF.NewPage();
for (int i = 0; i < PDF.GetPageCount(); i++)
{
    PDF.CurrentPage = i;
    PDF.UseFont(font, 10);
    string str = "Page " + (i + 1).ToString();
    PDF.ShowTextAt(10, 10, str);
}
PDF.SaveToFile("test.pdf", true);
Visual Basic
[copy to clipboard]
' PDF object is supposed to be created
font = PDF.AddFont("Arial", false, false, false, false, 1) 'fcDefault
PDF.NewPage
PDF.NewPage
for i = 0 to PDF.GetPageCount() - 1
    PDF.CurrentPage = i
    PDF.UseFont font, 10
    PDF.ShowTextAt 10, 10, "Page " & i + 1
next
PDF.SaveToFile "test.pdf", true

See Also

Reference