Skip to main content

PdfViewer.Select(RectangleF) Method

Selects the document content located in the specified rectangle.

Namespace: DevExpress.XtraPdfViewer

Assembly: DevExpress.XtraPdfViewer.v23.1.dll

NuGet Package: DevExpress.Win.PdfViewer


public void Select(
    RectangleF clientRectangle


Name Type Description
clientRectangle RectangleF

A RectangleF structure that is the target rectangle.


The overloaded Select method uses the client coordinate system. Refer to the Coordinate Systems topic for more information.

If the passed RectangleF object contains a part of the image, the method selects the entire image.

The code sample below shows how to copy selected text to the Clipboard.

bool mouseButtonPressed = false;
PdfDocumentPosition startPosition;
PdfDocumentPosition endPosition;

void pdfViewer1_MouseDown(object sender, MouseEventArgs e)
  if (e.Button == MouseButtons.Left)
      //Retrieve the initial mouse position
      startPosition = pdfViewer1.GetDocumentPosition(e.Location);
      endPosition = null;
      mouseButtonPressed = true;

void pdfViewer1_MouseMove(object sender, MouseEventArgs e)
  if (mouseButtonPressed)
      //Obtain the final position
      endPosition = pdfViewer1.GetDocumentPosition(e.Location);

void pdfViewer1_MouseUp(object sender, MouseEventArgs e)
    mouseButtonPressed = false;
    if (startPosition == null || endPosition == null)
    var start = pdfViewer1.GetClientPoint(startPosition);
    var end = pdfViewer1.GetClientPoint(endPosition);
    RectangleF rect = new RectangleF(Math.Min(start.X, end.X),
        Math.Min(start.Y, end.Y),
        Math.Abs(start.X - end.X),
        Math.Abs(start.Y - end.Y));

    //Select the content located in the target rectangle
    PdfSelectionContent content = pdfViewer1.GetSelectionContent();
    if (content.ContentType == PdfSelectionContentType.Text)

    //Copy selection to Clipboard
    MessageBox.Show("The selection is copied to Clipboard");
See Also