Back to Devexpress

PdfPageFacade.CreateXYZDestination(Single, Single, Single) Method

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

latest4.5 KB
Original Source

PdfPageFacade.CreateXYZDestination(Single, Single, Single) Method

Creates an XYZ destination.

Namespace : DevExpress.Pdf

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

NuGet Package : DevExpress.Pdf.Core

Declaration

csharp
public PdfXYZDestination CreateXYZDestination(
    float destinationX,
    float destinationY,
    float zoom
)
vb
Public Function CreateXYZDestination(
    destinationX As Single,
    destinationY As Single,
    zoom As Single
) As PdfXYZDestination

Parameters

NameTypeDescription
destinationXSingle

The X page coordinate in user coordinate system.

| | destinationY | Single |

The Y page coordinate in user coordinate system.

| | zoom | Single |

The zoom factor.

|

Returns

TypeDescription
PdfXYZDestination

The XYZ destination.

|

Example

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

csharp
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");
    }
}
vb
Using pdfDocumentProcessor As New PdfDocumentProcessor()
  ' Load a document
  pdfDocumentProcessor.LoadDocument("Demo.pdf")
  Dim documentFacade As PdfDocumentFacade = pdfDocumentProcessor.DocumentFacade

  ' Create an XYZ destination that refers to the fifth page
  Dim destination As PdfXYZDestination =
     documentFacade.Pages(4).CreateXYZDestination(100, 524, 1.2F)

  ' Find a specific phrase
  Dim word As String = "Type 3 fonts"
  Dim results As PdfTextSearchResults = pdfDocumentProcessor.FindText(word)

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

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

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

    pdfDocumentProcessor.SaveDocument("out.pdf")
  End If
End Using

See Also

PdfPageFacade Class

PdfPageFacade Members

DevExpress.Pdf Namespace