We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Move to a specific Pdf page

Hi,
I have a ViewModel:

    public class ImportPdfViewModel : ReactiveObject
    {
        public ImportPdfViewModel(MainViewModel mainViewModel, IIOService openFileDialogService)
        {
            MainViewModel = mainViewModel;
            //
            this.WhenAnyValue(This => This.PdfFilePath).Where(x => x != null).Subscribe((pdfFilePath) =>
                  {
                      PdfDocumentStream = new FileStream(pdfFilePath, FileMode.OpenOrCreate, FileAccess.Read);
                  });
            //
            SelectFilePathCommand = ReactiveCommand
                .Create(() => openFileDialogService.OpenFileDialog(@"D:\jr-T\VS\Hardyman\DudleyVoidsProcessor\DataIn"));
            SelectFilePathCommand.Subscribe((pdfFilePath) => { PdfFilePath = pdfFilePath; });
            //
            ImportPdfDataCommand = ReactiveCommand.Create(() => { }, this.WhenAnyValue(This => This.PdfFilePath).Where(pdfFilePath => PdfFilePath != null).Any());
        }

        public MainViewModel MainViewModel { get; set; }

        private string _PdfFilePath;
        public string PdfFilePath
        {
            get => _PdfFilePath;
            set => this.RaiseAndSetIfChanged(ref _PdfFilePath, value);
        }

        private Stream _PdfDocumentStream;
        public Stream PdfDocumentStream
        {
            get => _PdfDocumentStream;
            set => this.RaiseAndSetIfChanged(ref _PdfDocumentStream, value);
        }

        public ReactiveCommand<Unit, String> SelectFilePathCommand { get; set; }

        public ReactiveCommand<Unit, Unit> ImportPdfDataCommand { get; set; }
    }

I would like to add a command that moves to a particular page eg:

        public ReactiveCommand<int, Unit> MoveToPageCommand{ get; set; }

that I can call like this (eg move to page 12):

        MoveToPageCommand.Execute(12);

The problem I have is that I cannot figure out what bindings i need to put in place on the PdfViewControl?

Cheers,
James.

3 Replies

KC Karthikeyan Chandrasekar Syncfusion Team November 7, 2018 12:34 PM UTC

Hi James,  
As per your requirements, we have “GoToPageCommand” ICommand to navigate to pages in a PDF document. We can execute this command with page number as its parameter. Please find the UG link below to get further details on this:  
We have created a simple sample to explain, how to bind GoToPageCommand to a button. Please confirm whether this sample helps you to achieve your requirement.  
Regards, 
Karthikeyan 



JR James Randle November 7, 2018 02:57 PM UTC

Hi,
No I'm afraid that doesn't help.

I want to be able to set the page number from within my ViewModel not via binding to a command.
I would expect this to be acheivable by doing something like binding to PdfViewerControl.PageNumber, but that property is not available in Xaml.

Cheers,
James.


KK Karthik Krishnaraj Syncfusion Team November 12, 2018 08:59 AM UTC

Hi James, 
 
We have planned to expose API to get and set PageNumber in PdfViewer control and it will be available from our essential studio Volume 4 release which will be rolled out in the month of December 2018. 
 
Regards, 
Karthik. 


Loader.
Live Chat Icon For mobile
Up arrow icon