Back to Devexpress

PdfPageFacade.CreateFitBBoxHorizontallyDestination(Single) Method

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

latest4.1 KB
Original Source

PdfPageFacade.CreateFitBBoxHorizontallyDestination(Single) Method

Creates a FitBH destination.

Namespace : DevExpress.Pdf

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

NuGet Package : DevExpress.Pdf.Core

Declaration

csharp
public PdfFitBBoxHorizontallyDestination CreateFitBBoxHorizontallyDestination(
    float top
)
vb
Public Function CreateFitBBoxHorizontallyDestination(
    top As Single
) As PdfFitBBoxHorizontallyDestination

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
PdfFitBBoxHorizontallyDestination

The FitBH destination.

|

Example

The code sample below creates a link annotation with a destination that displays the first page’s area 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];

    // Create a FitBH destination that refers to the first page
    PdfFitBBoxHorizontallyDestination destination =
       pageFacade.CreateFitBBoxHorizontallyDestination(134);

    // Find a specific phrase
    PdfTextSearchResults linkText = pdfDocumentProcessor.FindText("Go to Total");

    // If the phrase is found, obtain its bounding rectangle
    if (linkText.Status == PdfTextSearchStatus.Found)
    {
        PdfRectangle linkRectangle = linkText.Rectangles[0].BoundingRectangle;

        // Create a link annotation associated with the bounding rectangle
        // and destination
        PdfLinkAnnotationFacade linkAnnotation =
           pageFacade.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("Roll Paper.pdf")

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

  ' Create a FitBH destination that refers to the first page
  Dim destination As PdfFitBBoxHorizontallyDestination =
    pageFacade.CreateFitBBoxHorizontallyDestination(134)

  ' Find a specific phrase
  Dim linkText As PdfTextSearchResults = pdfDocumentProcessor.FindText("Go to Total")

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

    ' Create a link annotation associated with the bounding rectangle
    ' and destination
    Dim linkAnnotation As PdfLinkAnnotationFacade =
      pageFacade.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