This is a migrated thread and some comments may be shown as answers.

Current Page event

2 Answers 333 Views
PdfViewer and PdfViewerNavigator
This is a migrated thread and some comments may be shown as answers.
Andrea
Top achievements
Rank 1
Andrea asked on 09 Jun 2014, 03:45 PM
Is there an event to sync with the current page on pdf viewer document?

Since the navigator is in sync there should be, i guess, such an event, but I can't find it.

Can you please help?
Best Regards
Andrea

2 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 10 Jun 2014, 08:42 AM
Hi Andrea,

Thank you for writing.

You can use the ScrollerUpdated method for the purpose:
radPdfViewer1.PdfViewerElement.Scroller.ScrollerUpdated += Scroller_ScrollerUpdated;
 
void Scroller_ScrollerUpdated(object sender, EventArgs e)
{
    this.Text =  this.radPdfViewer1.PdfViewerElement.CurrentPage.PageNo.ToString() + " : " + this.radPdfViewer1.PdfViewerElement.Document.Pages.Count.ToString() ;
}

I hope this helps.

Regards,
Stefan
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Andrea
Top achievements
Rank 1
answered on 10 Jun 2014, 10:42 AM
Thank you that works, this is the first working prototype, if someone needs:


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Telerik.WinControls.UI;
 
namespace BolleWPF
{
    public partial class PdfSplit : Telerik.WinControls.UI.RadForm
    {
        Telerik.WinControls.UI.RadPdfViewer radPdfViewer1;
        LogicLayer.PdfSplitterBatch sb = new LogicLayer.PdfSplitterBatch();
 
        private int currentPage;
        private int CurrentPage
        {
            get {
                return currentPage;
            }
            set {
                currentPage = value;
                if (pdfSplitterBatchBindingSource.RaiseListChangedEvents)
                {
                    pdfSplitterBatchBindingSource.RaiseListChangedEvents = false;
                    pdfSplitterBatchBindingSource.Position = currentPage - 1;
                    pdfSplitterBatchBindingSource.RaiseListChangedEvents = true;
                }
            }
        }
 
        public PdfSplit()
        {
            InitializeComponent();
            pdfSplitterBatchBindingSource.DataSource = sb;
            pdfSplitterBatchBindingSource.PositionChanged += new EventHandler(pdfSplitterBatchBindingSource_PositionChanged);
            radPdfViewer1 = (Telerik.WinControls.UI.RadPdfViewer) Controls.Find("radPdfViewer1", true)[0];
            radPdfViewer1.PdfViewerElement.Scroller.ScrollerUpdated += new EventHandler(Scroller_ScrollerUpdated);
            CurrentPage = 0;
        }
 
        void pdfSplitterBatchBindingSource_PositionChanged(object sender, EventArgs e)
        {
            if (pdfSplitterBatchBindingSource.RaiseListChangedEvents == false || pdfSplitterBatchBindingSource.Position < 0)
                return;
 
            currentPage = pdfSplitterBatchBindingSource.Position + 1;
            pdfSplitterBatchBindingSource.RaiseListChangedEvents = false;
            radPdfViewer1.PdfViewerElement.GoToPage(currentPage);
            pdfSplitterBatchBindingSource.RaiseListChangedEvents = true;
        }
 
        void Scroller_ScrollerUpdated(object sender, EventArgs e)
        {
            if (radPdfViewer1.PdfViewerElement != null && radPdfViewer1.PdfViewerElement.CurrentPage != null)
                CurrentPage = radPdfViewer1.PdfViewerElement.CurrentPage.PageNo;
            else
                CurrentPage = 0;
        }
 
 
        private void radPdfViewer1_DocumentLoaded(object sender, EventArgs e)
        {
            sb.Clear();
            for (int i = 0; i < radPdfViewer1.Document.Pages.Count; ++i)
            {
                sb.Add(new LogicLayer.PdfSplitter(i+1));
            }
            Scroller_ScrollerUpdated(null, null);
        }     
    }
}
Tags
PdfViewer and PdfViewerNavigator
Asked by
Andrea
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Andrea
Top achievements
Rank 1
Share this question
or