Skip to main content
.NET Framework 4.5.2+

PdfXYZDestination Class

A destination that positions a specific coordinate at the top left corner of the document window, and zooms a page with the specified zoom factor.

Namespace: DevExpress.Pdf

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

Declaration

public class PdfXYZDestination :
    PdfDestination

Remarks

The XYZ destination displays the page as follows:

  • A specific page point is positioned at the top left corner of the document window.
  • A page is magnified with the specified zoom factor.

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

Associate a Bookmark with a Destination

This example shows how to create a bookmark with a destination that displays the page as follows:

bookmark

using System.Collections.Generic;
using DevExpress.Pdf;

using (PdfDocumentProcessor documentProcessor = new PdfDocumentProcessor())
{
    // Load a document
    documentProcessor.LoadDocument(@"..\..\Document.pdf");

    // Define search words
    string[] words = { "DX-B5000", "DX-RX800" };

    // Specify search parameters
    PdfTextSearchParameters searchParameters = new PdfTextSearchParameters();
    searchParameters.CaseSensitive = true;
    searchParameters.WholeWords = true;

    foreach (string word in words)
    {
        // Get search results
        PdfTextSearchResults results = documentProcessor.FindText(word, searchParameters);

        // If the text is found, create a destination that positions the found text
        // at the upper window corner
        if (results.Status == PdfTextSearchStatus.Found)
        {
            PdfXYZDestination destination = new PdfXYZDestination(results.Page, 0, results.Rectangles[0].Top, null);

            // Create a bookmark associated with the destination
            PdfBookmark bookmark = new PdfBookmark() { Title = word, Destination = destination };

            // Add the bookmark to the bookmark list
            documentProcessor.Document.Bookmarks.Add(bookmark);
        }
    }
    // Save the modified document
    documentProcessor.SaveDocument(@"..\..\Result.pdf");
}

Call the PdfPageFacade.AddLinkAnnotation method and pass a PdfXYZDestination 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 fifth page as follows:

destination

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

    PdfDocumentFacade documentFacade = pdfDocumentProcessor.DocumentFacade;

    // Create an XYZ destination that refers to the fifth page
    PdfXYZDestination destination =
       documentFacade.Pages[4].CreateXYZDestination(100, 524, 1.2f);

    // Find a specific phrase
    string word = "Type 3 fonts";
    PdfTextSearchResults results = pdfDocumentProcessor.FindText(word);

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

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

        // Create a link annotation associated with the bounding rectangle
        // and destination
        PdfLinkAnnotationFacade pdfLinkAnnotation =
           pageFacade.AddLinkAnnotation(textRectangle, destination);
        pdfLinkAnnotation.HighlightMode = PdfAnnotationHighlightingMode.Push;

        pdfDocumentProcessor.SaveDocument("out.pdf");
    }
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the PdfXYZDestination class.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

Inheritance

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