intercepting the open and save as buttons

1 Answer 62 Views
PdfViewer and PdfViewerNavigator
Martin Hamilton
Top achievements
Rank 1
Iron
Iron
Veteran
Martin Hamilton asked on 13 Sep 2023, 05:15 PM

I'm trying to intercept the Open and Save As Buttons for special handling

I have tried

AddHandler RadPdfViewerNavigator1.CommandBarElement.Rows(0).Strips(0).MouseDown, AddressOf OpenButton_MouseDown

But the addressof sub never gets hit.

Also, when I try to get to the Save As button with the following code; it throws an error.  So, I'm approaching this the wrong way I guess.

AddHandler RadPdfViewerNavigator1.CommandBarElement.Rows(0).Strips(1).MouseDown, AddressOf SaveButton_MouseDown

After searching the forums, I'm not seeing any way to do this (so, I must be missing something).

Can you please tell me how to intercept these buttons?

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 14 Sep 2023, 08:40 AM

Hi, Martin,

If you need to plug into the save as logic in RadPdfViewerNavigator and customize the default logic, I would suggest you to create a custom save button and remove the default one:

 private void RadForm1_Load(object sender, EventArgs e)
        {
            CommandBarButton btn = new CommandBarButton();
            this.radPdfViewerNavigator1.CommandBarElement.Rows[0].Strips[0].Items.Insert(4,btn);
            btn.SvgImage = this.radPdfViewerNavigator1.SaveButton.SvgImage;
            btn.SvgImage.Size = this.radPdfViewerNavigator1.SaveButton.SvgImage.Size;
            btn.Click+=btn_Click; 

           this.radPdfViewerNavigator1.CommandBarElement.Rows[0].Strips[0].Items.Remove(this.radPdfViewerNavigator1.SaveButton);
        }

        private void btn_Click(object sender, EventArgs e)
        {
            SaveFileDialog savefile = new SaveFileDialog(); 
            savefile.Filter = "PDF files (*.pdf)|*.pdf|All files (*.*)|*.*";

            if (savefile.ShowDialog() == DialogResult.OK)
            {
                this.radPdfViewer1.PdfViewerElement.SaveDocument(savefile.FileName);
            }
        }

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
PdfViewer and PdfViewerNavigator
Asked by
Martin Hamilton
Top achievements
Rank 1
Iron
Iron
Veteran
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or