Back to Devexpress

PdfFitVerticallyDestination Class

officefileapi-devexpress-dot-pdf-222ff655.md

latest7.0 KB
Original Source

PdfFitVerticallyDestination Class

A destination that positions a specific X coordinate at the top left corner of the document window, and zooms a page so that it fits the window vertically.

Namespace : DevExpress.Pdf

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

NuGet Package : DevExpress.Pdf.Core

Declaration

csharp
public class PdfFitVerticallyDestination :
    PdfDestination
vb
Public Class PdfFitVerticallyDestination
    Inherits PdfDestination

The following members return PdfFitVerticallyDestination objects:

Remarks

The FitV destination displays a page as follows:

  • A specific X coordinate (returned by the Left property) is positioned at the top left corner of the document window
  • The page is fit into the document window vertically (the Fit Height zoom)

You can associate any number of bookmarks and link annotations with a destination.

Associate a Bookmark with a Destination

The code sample below creates a bookmark with a destination that displays the first page as follows:

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

    // Create a FitV destination that refers to the first page
    PdfPage page = pdfDocumentProcessor.Document.Pages[0];
    PdfFitVerticallyDestination destination =
       new PdfFitVerticallyDestination(page, 612);

    // Create a bookmark
    PdfBookmark bookmark = new PdfBookmark();
    bookmark.Title = "DevExtreme Complete";

    // Associate the bookmark with the destination
    bookmark.Destination = destination;

    // Add the bookmark to the document collection
    pdfDocumentProcessor.Document.Bookmarks.Add(bookmark);

    // Save the result
    pdfDocumentProcessor.SaveDocument("out.pdf");
}
vb
Using pdfDocumentProcessor As New PdfDocumentProcessor()

  ' Load a document
  pdfDocumentProcessor.LoadDocument("Documents//print_titles.pdf")

  ' Create a FitV destination that refers to the first page
  Dim page As PdfPage = pdfDocumentProcessor.Document.Pages(0)
  Dim destination As New PdfFitVerticallyDestination(page, 612)

  ' Create a bookmark
  Dim bookmark As New PdfBookmark()
  bookmark.Title = "DevExtreme Complete"

  ' Associate the bookmark with the destination
  bookmark.Destination = destination

  ' Add the bookmark to the document collection
  pdfDocumentProcessor.Document.Bookmarks.Add(bookmark)

  ' Save the result
  pdfDocumentProcessor.SaveDocument("out.pdf")
End Using

Call the PdfPageFacade.AddLinkAnnotation method and pass a PdfFitVerticallyDestination object as a parameter to create a link annotation associated with a destination.

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

Inheritance

Object DevExpress.Pdf.Native.PdfDocumentItem DevExpress.Pdf.Native.PdfObject PdfDestination PdfFitVerticallyDestination

See Also

PdfFitVerticallyDestination Members

DevExpress.Pdf Namespace