Back to Devexpress

PdfPageFacade.CreateFitHorizontallyDestination(Single) Method

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

latest4.5 KB
Original Source

PdfPageFacade.CreateFitHorizontallyDestination(Single) Method

Creates a FitH destination.

Namespace : DevExpress.Pdf

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

NuGet Package : DevExpress.Pdf.Core

Declaration

csharp
public PdfFitHorizontallyDestination CreateFitHorizontallyDestination(
    float top
)
vb
Public Function CreateFitHorizontallyDestination(
    top As Single
) As PdfFitHorizontallyDestination

Parameters

NameTypeDescription
topSingle

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

|

Returns

TypeDescription
PdfFitHorizontallyDestination

The FitH destination on the page.

|

Example

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

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

    // Access first page properties
    PdfPageFacade pageFacade = pdfDocumentProcessor.DocumentFacade.Pages[0];

    // Access third page properties
    PdfPageFacade destinationPageFacade =
      pdfDocumentProcessor.DocumentFacade.Pages[2];

    // Create a FitH destination that refers to the fourth page
    PdfFitHorizontallyDestination destination =
      destinationPageFacade.CreateFitHorizontallyDestination(134);

    // Find a specific phrase
    string linkText = "Rattlesnake Canyon Grocery Total";
    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;

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

  ' Access first page properties
  Dim pageFacade As PdfPageFacade =
    pdfDocumentProcessor.DocumentFacade.Pages(0)

  ' Access third page properties
  Dim destinationPageFacade As PdfPageFacade =
    pdfDocumentProcessor.DocumentFacade.Pages(2)

  ' Create a destination that refers to the fourth page
  Dim destination As PdfFitHorizontallyDestination =
    destinationPageFacade.CreateFitHorizontallyDestination(134)

  ' Find a specific phrase
  Dim linkText As String = "Rattlesnake Canyon Grocery Total"
  Dim linkSearchResults As PdfTextSearchResults =
    pdfDocumentProcessor.FindText(linkText)

  ' If the phrase is found, obtain its bounding rectangle
  If linkSearchResults.Status = PdfTextSearchStatus.Found Then
    Dim linkRectangle As PdfRectangle = linkSearchResults.Rectangles(0).BoundingRectangle

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

See Also

PdfPageFacade Class

PdfPageFacade Members

DevExpress.Pdf Namespace