Back to Devexpress

PdfPageFacade.CreateFitVerticallyDestination(Single) Method

officefileapi-devexpress-dot-pdf-dot-pdfpagefacade-dot-createfitverticallydestination-x28-system-dot-single-x29.md

latest4.5 KB
Original Source

PdfPageFacade.CreateFitVerticallyDestination(Single) Method

Creates a FitV destination.

Namespace : DevExpress.Pdf

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

NuGet Package : DevExpress.Pdf.Core

Declaration

csharp
public PdfFitVerticallyDestination CreateFitVerticallyDestination(
    float left
)
vb
Public Function CreateFitVerticallyDestination(
    left As Single
) As PdfFitVerticallyDestination

Parameters

NameTypeDescription
leftSingle

The X coordinate that is positioned at the left corner of the document window. Specify this coordinate in the user coordinate system.

|

Returns

TypeDescription
PdfFitVerticallyDestination

The FitV destination.

|

Example

The code sample below creates a link annotation with a destination that displays the sixth page as follows:

csharp
using (PdfDocumentProcessor pdfDocumentProcessor = new PdfDocumentProcessor())
{
    // Load a document
    pdfDocumentProcessor.LoadDocument("Documents//Demo.pdf");

    // Access sixth page properties
    PdfPageFacade pageFacade = pdfDocumentProcessor.DocumentFacade.Pages[5];

    // Create a FitV destination that refers to the fifth page
    PdfFitVerticallyDestination destination =
       pageFacade.CreateFitVerticallyDestination(396);

    // Find a specific phrase
    PdfTextSearchResults textSearchResults = pdfDocumentProcessor.FindText("Patterns");

    // If the phrase is found, obtain the page that contains it
    // and the top vertical coordinate of the phrase's rectangle
    if (textSearchResults.Status == PdfTextSearchStatus.Found)
    {
        PdfPageFacade linkPageFacade =
           pdfDocumentProcessor.DocumentFacade.Pages[textSearchResults.PageNumber-1];
        PdfRectangle linkRectangle =
          textSearchResults.Rectangles[0].BoundingRectangle;

        // 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");
}
vb
Using pdfDocumentProcessor As New PdfDocumentProcessor()
  ' Load a document
  pdfDocumentProcessor.LoadDocument("Documents//Demo.pdf")

  ' Access sixth page properties
  Dim pageFacade As PdfPageFacade =
    pdfDocumentProcessor.DocumentFacade.Pages(5)

  ' Create a FitV destination that refers to the fifth page
  Dim destination As PdfFitVerticallyDestination =
    pageFacade.CreateFitVerticallyDestination(396)

  ' Find a specific phrase
  Dim textSearchResults As PdfTextSearchResults = pdfDocumentProcessor.FindText("Patterns")

  ' If the phrase is found, obtain the page that contains it
   ' and the top vertical coordinate of the phrase's rectangle
  If textSearchResults.Status = PdfTextSearchStatus.Found Then
    Dim linkPageFacade As PdfPageFacade =
       pdfDocumentProcessor.DocumentFacade.Pages(textSearchResults.PageNumber-1)
    Dim linkRectangle As PdfRectangle =
       textSearchResults.Rectangles(0).BoundingRectangle

    ' Create a link annotation associated with the bounding rectangle
    ' and destination
    Dim linkAnnotation As PdfLinkAnnotationFacade =
       linkPageFacade.AddLinkAnnotation(linkRectangle, destination)
    linkAnnotation.HighlightMode = PdfAnnotationHighlightingMode.Push
  End If
  ' Save the result
  pdfDocumentProcessor.SaveDocument("out.pdf")
End Using

See Also

PdfPageFacade Class

PdfPageFacade Members

DevExpress.Pdf Namespace