Last Updated: 01 Dec 2020 12:59 by ADMIN
Release LIB 2020.3.1207 (07/12/2020)
Created on: 15 Sep 2020 06:34
Category: PDFViewer
Type: Bug Report
PdfViewer: ArgumentOutOfRangeException is thrown when entering in the RadToolBar a page number bigger than the document pages count

When we render any PDF file with 'x' number of page count and try to enter page 'x+1' in telerik:CurrentPageTextBox and hit enter, it will enable the Previous Page RadButton and if we click Previous Page then it will freeze the application.

System.ArgumentOutOfRangeException: 'pageNo should be greater or equal than 1 and less or equal than 4. (Parameter 'pageNo')'

Workaround: A possible approach could be to attach to the CurrentPageTextBox` KeyDown event in order to restrict the input.


<telerik:CurrentPageTextBox x:Name="PART_CurrentPageNumberTextBox" 
							Text="{Binding FixedDocumentViewer.CurrentPageNumber, Mode=TwoWay}"/>

private void PART_CurrentPageNumberTextBox_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
	TextBox textBox = sender as TextBox;
	if (textBox != null)
		if (e.Key == System.Windows.Input.Key.Enter)
			int pagesCount = this.pdfViewer.PagesCount;
			int currentPageNumber = this.pdfViewer.CurrentPageNumber;
			if (this.pdfViewer.Document != null && (currentPageNumber < 1 || currentPageNumber > pagesCount))
				RadFixedPage currentPage = this.pdfViewer.CurrentPage;
				int pageNum = this.pdfViewer.Document.Pages.IndexOf(currentPage) + 1;
				this.pdfViewer.CurrentPageNumber = pageNum;