When importing a PDF document, opening the stream in using statement, and using the default constructor of the PdfDocumentSource class, an exception is thrown:
using (Stream stream = ofd.OpenFile())
{
this.pdfViewer.DocumentSource = new PdfDocumentSource(stream);
}
using (Stream stream = ofd.OpenFile())
{
PdfImportSettings importSettings = new PdfImportSettings
{
CopyStream = true
};
this.pdfViewer.DocumentSource = new PdfDocumentSource(stream, importSettings);
}
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.
XAML:
<telerik:CurrentPageTextBox x:Name="PART_CurrentPageNumberTextBox"
KeyDown="PART_CurrentPageNumberTextBox_KeyDown"
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;
}
}
}
}
Hello,
We are using PdfViewer and its command descriptor.
Right now, I don't find how to set the name of the file being saved. In my humble opinion, the command parameter should be the fileName of the PDF being exported.
The documentation doesn't tell how to set the fileName which is a basic thing to do for a save file command.
I didn't find a solution in the forum. Weird nobody ever talked about it.
Thanks for evaluating this feedback