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

PDF Add Rectangle in viewer

1 Answer 133 Views
PdfViewer and PdfViewerNavigator
This is a migrated thread and some comments may be shown as answers.
Alexandru
Top achievements
Rank 1
Alexandru asked on 14 Oct 2014, 11:28 AM
Hello,

How can i add a rectangle (or a button) in the PDF viewer, only on the first page?

Thank you

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 17 Oct 2014, 08:46 AM
Hello Alexandru,

Thank you for writing.

The appropriate solution that I can suggest is to add a RadButton to the Form.Controls collection. However, you need to specify the RadButton.Location to match the RadPdfViewer location. Initially, the button will not be visible. When a document is loaded in the RadPdfViewer, the RadButton.Visible property will be set to true. Changing the pages via the vertical scroll bar will force the button to be hidden again if the current page is not the first one. Here is a sample implementation:
RadButton btn = new RadButton();
 
public Form1()
{
    InitializeComponent();
 
    this.radPdfViewer1.DocumentLoaded += radPdfViewer1_DocumentLoaded;
    this.radPdfViewer1.PdfViewerElement.VScrollBar.ValueChanged += VScrollBar_ValueChanged;
   
    btn.Text = "Click";
    
    btn.Location = new Point(50, 50);
 
    btn.Visible = false;
    this.Controls.Add(btn);
    this.Controls.SetChildIndex(btn, 0);
}
 
private void VScrollBar_ValueChanged(object sender, EventArgs e)
{
    if (this.radPdfViewer1.PdfViewerElement.Document.Pages.Count > 0 &&
        this.radPdfViewer1.PdfViewerElement.CurrentPage ==
        this.radPdfViewer1.PdfViewerElement.Document.Pages.First())
    {
        btn.Visible = true;
    }
    else
    {
        btn.Visible = false;
    }
}
 
private void radPdfViewer1_DocumentLoaded(object sender, EventArgs e)
{
    btn.Visible = true;
}

Note that this is just a sample approach and it may not cover all possible cases. Feel free to modify it on a way which suits your requirement best.

I hope this information helps. Should you have further questions, I would be glad to help.

Regards,
Desislava
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

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