Skip to main content
All docs
V25.1
  • PdfPageFacade.CreateFitRectangleDestination(PdfRectangle) Method

    Creates a FitR destination.

    Namespace: DevExpress.Pdf

    Assembly: DevExpress.Pdf.v25.1.Core.dll

    NuGet Package: DevExpress.Pdf.Core

    Declaration

    public PdfFitRectangleDestination CreateFitRectangleDestination(
        PdfRectangle rectangle
    )

    Parameters

    Name Type Description
    rectangle PdfRectangle

    The rectangle that is fit into the document viewer window. Specify this rectangle in the user coordinate system.

    Returns

    Type Description
    PdfFitRectangleDestination

    The FitR destination.

    Remarks

    If the horizontal and vertical magnification factors are different, the PdfFitRectangleDestination object uses the smaller of the two, and centers the rectangle on the window.

    Example

    The code sample below creates a link annotation with a destination that displays the second page’s area as follows:

    fit rectangle

    using (PdfDocumentProcessor pdfDocumentProcessor = new PdfDocumentProcessor())
    {
        // Load a document
        pdfDocumentProcessor.LoadDocument("Demo.pdf");
    
        // Access second page properties
        PdfPageFacade destinationPageFacade =
          pdfDocumentProcessor.DocumentFacade.Pages[1];
    
        // Define a page rectangle
        PdfRectangle destRectangle = new PdfRectangle(50, 50, 300, 300);
    
        // Create a FitR destination that refers to the second page
        PdfFitRectangleDestination destination =
          destinationPageFacade.CreateFitRectangleDestination(destRectangle);
    
        // Find a specific phrase
        string linkText = "JPX images";
        PdfTextSearchResults linkSearchResults = pdfDocumentProcessor.FindText(linkText);
    
        // If the phrase is found, obtain its bounding rectangle
        if (linkSearchResults.Status == PdfTextSearchStatus.Found)
        {
            PdfRectangle linkRectangle = linkSearchResults.Rectangles[0].BoundingRectangle;
    
            // Access first page properties
            PdfPageFacade pageFacade =
               pdfDocumentProcessor.DocumentFacade.Pages[linkSearchResults.PageNumber-1];
    
            // Create a link annotation associated with the bounding rectangle
            // and destination
            PdfLinkAnnotationFacade pdfLink =
              pageFacade.AddLinkAnnotation(linkRectangle, destination);
            pdfLink.HighlightMode = PdfAnnotationHighlightingMode.Push;
        }
            // Save the result
            pdfDocumentProcessor.SaveDocument("out.pdf");
    }
    
    See Also