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

    Creates a Fit destination.

    Namespace: DevExpress.Pdf

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

    NuGet Package: DevExpress.Pdf.Core

    Declaration

    public PdfFitDestination CreateFitDestination()

    Returns

    Type Description
    PdfFitDestination

    The Fit destination.

    Example

    The following code snippet creates a link annotation with a destination that displays the third page with the Zoom to Page Level view:

    destination link

    View Example

    using (PdfDocumentProcessor pdfDocumentProcessor = new PdfDocumentProcessor())
    {
        // Load a document
        pdfDocumentProcessor.LoadDocument("Demo.pdf");
    
        // Access third page properties
        PdfPageFacade pageFacade = pdfDocumentProcessor.DocumentFacade.Pages[2];
    
        // Create a Fit destination that refers to the third page
        PdfFitDestination destination = pageFacade.CreateFitDestination();
    
        // Find a specific phrase
        string linkText = "JBIG2 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 linkPageFacade =
               pdfDocumentProcessor.DocumentFacade.Pages[linkSearchResults.PageNumber -1];
    
            // Create a link annotation associated with the bounding rectangle
            // and destination
            PdfLinkAnnotationFacade linkAnnotation =
                linkPageFacade.AddLinkAnnotation(linkRectangle, destination);
            linkAnnotation.HighlightMode = PdfAnnotationHighlightingMode.Push;
        }
        // Save the result
        pdfDocumentProcessor.SaveDocument("out.pdf");
    }
    
    See Also