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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Move to a specific Pdf page

Thread ID:

Created:

Updated:

Platform:

Replies:

140771 Nov 6,2018 04:02 PM UTC Nov 12,2018 08:59 AM UTC WPF 3
loading
Tags: PdfViewer
James Randle
Asked On November 6, 2018 04:02 PM UTC

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.

KarthikeyanC [Syncfusion]
Replied On 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 


James Randle
Replied On 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.

Karthik Krishnaraj [Syncfusion]
Replied On 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. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;