Gets the current page number.
public virtual int CurrentPageNumber {get;}
Public Overridable ReadOnly Property CurrentPageNumber() As Integer
Get
public:
virtual property int CurrentPageNumber
{
int get()
}
The 1-based number of the current page.
The CurrentPageNumber is the page with the largest area currently visible in the View.
This is obtained by calling View.ImageViewer.GetLargestVisibleItemIndex.
The value changes when the user scrolls the view or zooms in or out and should not be saved. Instead, use CurrentPageNumber every time the "largest visible page" is needed. For example, the application can have a "Find text in this page" or "Find text in the whole document" operations. When the user runs the "Find text in this page", they are referring to the largest page in the viewer, and the application should call CurrentPageNumber to get this value when the action is invoked.
CurrentPageNumber is used in end-user applications as well as internally with many Commands. The value will update automatically as the user scrolls through and interacts with the View. The CurrentPageNumber algorithm is "smart" and will generally either show one of the following states:
To tie CurrentPageNumber with the current View's ImageViewer.ActiveItem and not update when the user scrolls the view, set the value of SmartCurrentPageNumber to false
.
Users can listen for changes to CurrentPageNumber (and cancel incoming changes) by listening for the DocumentViewerOperation.CurrentPageNumberChanged operation. CurrentPageNumberChangeData and CurrentPageNumberChangedCause will be available to inspect the changing page number and its cause.
Start with the example created in DocumentViewer, remove all the code in the Example function and add the code below.
When the user clicks the Example button and then the user changes the page number, the change is intercepted and the current page is shown in the label.
using Leadtools;
using Leadtools.Controls;
using Leadtools.Document;
using Leadtools.Document.Viewer;
using Leadtools.Codecs;
using Leadtools.Caching;
using Leadtools.Annotations.Engine;
using Leadtools.Ocr;
// Disable the example button, this should only run once
exampleButton.Enabled = false;
_documentViewer.Operation += (sender, e) =>
{
if (e.Operation == DocumentViewerOperation.GotoPage && e.IsPostOperation)
{
var pageNumber = _documentViewer.CurrentPageNumber;
var infoLabel = this.Controls.Find("infoLabel", true)[0];
infoLabel.Text = "Current page number is " + pageNumber;
}
};
Imports Leadtools
Imports Leadtools.Controls
Imports Leadtools.Document
Imports Leadtools.Document.Viewer
Imports Leadtools.Codecs
Imports Leadtools.Caching
Imports Leadtools.Annotations.Engine
Imports Leadtools.Ocr
' Disable the example button, this should only run once
exampleButton.Enabled = False
AddHandler _documentViewer.Operation,
Sub(sender, e)
If e.Operation = DocumentViewerOperation.GotoPage AndAlso e.IsPostOperation Then
Dim pageNumber As Integer = _documentViewer.CurrentPageNumber
Dim infoLabel As Control = Me.Controls.Find("infoLabel", True)(0)
infoLabel.Text = "Current page number is " + pageNumber.ToString()
End If
End Sub
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.