PDF Add Rectangle in viewer

2 posts, 0 answers
  1. Alexandru
    Alexandru avatar
    1 posts
    Member since:
    Oct 2014

    Posted 14 Oct 2014 Link to this post


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

    Thank you
  2. Dess
    Dess avatar
    1561 posts

    Posted 17 Oct 2014 Link to this post

    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()
        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.SetChildIndex(btn, 0);
    private void VScrollBar_ValueChanged(object sender, EventArgs e)
        if (this.radPdfViewer1.PdfViewerElement.Document.Pages.Count > 0 &&
            this.radPdfViewer1.PdfViewerElement.CurrentPage ==
            btn.Visible = true;
            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.


    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.

  3. DevCraft R3 2016 release webinar banner
Back to Top