SetCurrentPage
IPDFDocument3 :: General document methods

See Also Example
Collapse All

This method selects a specified page of the PDF document.

Syntax

HRESULT SetCurrentPage (
LONG pageIndex
)
Parameters
pageIndex
Index of the page (starts at zero and continues to the existing page count minus 1)

Return value
If successful, this method returns S_OK. If it fails, this method should return one of the error values.

Remarks

SetCurrentPage sets the current page to a new value. The PDF page index can be retrieved from the GetCurrentPageIndex method.

Equivalent in new interface: IPDFDocument4::CurrentPage.

Example

Setting the Current Page of a PDF Document

Delphi
[copy to clipboard]
{ PDF object is supposed to be created }
PDF.BeginDoc;
PDF.NewPage;
PDF.NewPage;
for i := 0 to PDF.PageCount-1 do
begin
    PDF.SetCurrentPage(i);
    PDF.PDFPAGE_SetActiveFont('Verdana', False, False, False, False, 8.0, 0);
    PDF.PDFPAGE_TextOut(100, 100, 0.0, 'Page ' + IntToStr(i + 1));
end;
PDF.EndDoc;
C/C++
[copy to clipboard]
// PDF object is supposed to be created
PDF->BeginDoc();
PDF->NewPage();
PDF->NewPage();
for (LONG i = 0; i < PDF.PageCount; i++)
{
    PDF->SetCurrentPage(i);
    PDF->PDFPAGE_SetActiveFont("Verdana", FALSE, FALSE, FALSE, FALSE, 8.0, 0);
    CString str;
    str->Format("Page %d", i + 1);
    PDF->PDFPAGE_TextOut(100, 100, 0.0, str);
}
PDF.EndDoc();
C#
[copy to clipboard]
// PDF object is supposed to be created
PDF.BeginDoc();
PDF.NewPage();
PDF.NewPage();
for (long i = 0; i < PDF.PageCount; i++)
{
    PDF.SetCurrentPage(i);
    PDF.PDFPAGE_SetActiveFont("Verdana", FALSE, FALSE, FALSE, FALSE, 8, 0);
    string str = "Page " + (i + 1).ToString();
    PDF.PDFPAGE_TextOut(100, 100, 0, str);
}
PDF.EndDoc();
Visual Basic
[copy to clipboard]
' PDF object is supposed to be created
PDF.BeginDoc
PDF.NewPage
PDF.NewPage
for i=0 to PDF.PageCount-1
    PDF.SetCurrentPage i
    PDF.PDFPAGE_SetActiveFont "Verdana", FALSE, FALSE, FALSE, FALSE, 8, 0
    PDF.PDFPAGE_TextOut 100, 100, 0, "Page " & (i + 1)
next
PDF.EndDoc

See Also

Reference