.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

PdfFitBBoxHorizontallyDestination Class

A destination that positions a specific Y coordinate at the top left corner of the document window, and zooms a page’s bounding box so that it fits the window horizontally.

Namespace: DevExpress.Pdf

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

Declaration

public class PdfFitBBoxHorizontallyDestination :
    PdfDestination

Remarks

The FitBH destination displays a page as follows:

  • A specific Y coordinate (returned by the Top property) is positioned at the top left corner of the document window
  • The page’s bounding box fits the document window horizontally

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 specific page area as follows:

bookmark

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

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

    // 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)
    {
        PdfPage destinationPage = textSearchResults.Page;
        double top = textSearchResults.Rectangles[0].Top;

        // Create a FitBH destination
        // that positions the phrase at the top left corner of the document window
        PdfFitBBoxHorizontallyDestination destination =
                new PdfFitBBoxHorizontallyDestination(destinationPage, top);

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

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

        // Add a bookmark to the collection
        pdfDocumentProcessor.Document.Bookmarks.Add(bookmark);
    }
    pdfDocumentProcessor.SaveDocument("out.pdf");
}

Call the PdfPageFacade.AddLinkAnnotation method and pass a PdfFitBBoxHorizontallyDestination 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 first page’s area as follows:

fit b box horizontally

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");
}

Inheritance

Object
DevExpress.Pdf.Native.PdfDocumentItem
DevExpress.Pdf.Native.PdfObject
PdfDestination
PdfFitBBoxHorizontallyDestination
See Also