officefileapi-devexpress-dot-pdf-6c59dbc9.md
A destination that displays a page that fits the document window.
Namespace : DevExpress.Pdf
Assembly : DevExpress.Pdf.v25.2.Core.dll
NuGet Package : DevExpress.Pdf.Core
public class PdfFitDestination :
PdfDestination
Public Class PdfFitDestination
Inherits PdfDestination
The following members return PdfFitDestination objects:
The Fit destination displays a page that fits the document window. You can associate any number of bookmarks and link annotations with a destination.
The code sample below creates a bookmark with a destination that displays the third page as follows:
using (PdfDocumentProcessor pdfDocumentProcessor = new PdfDocumentProcessor())
{
// Load a document
pdfDocumentProcessor.LoadDocument("Demo.pdf");
// Create a Fit destination that refers to the third page
PdfFitDestination destination =
new PdfFitDestination(pdfDocumentProcessor.Document.Pages[2]);
// Create a bookmark
PdfBookmark bookmark = new PdfBookmark();
bookmark.Title = "JBIG2 Images";
// Associate the bookmark with the created destination
bookmark.Destination = destination;
// Add a bookmark to the document collection
pdfDocumentProcessor.Document.Bookmarks.Add(bookmark);
// Save the result
pdfDocumentProcessor.SaveDocument("out.pdf");
}
Using pdfDocumentProcessor As New PdfDocumentProcessor()
' Load a document
pdfDocumentProcessor.LoadDocument("Demo.pdf")
' Create a Fit destination that refers to the third page
Dim destination As New
PdfFitDestination(pdfDocumentProcessor.Document.Pages(2))
' Create a bookmark
Dim bookmark As New PdfBookmark()
bookmark.Title = "JBIG2 Images"
' Associate the bookmark with the created destination
bookmark.Destination = destination
' Add a 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 PdfFitDestination object as a parameter to create a link annotation associated with a destination.
The following code snippet creates a link annotation with a destination that displays the third page with the Zoom to Page Level view:
using (PdfDocumentProcessor pdfDocumentProcessor = new PdfDocumentProcessor())
{
// Load a document
pdfDocumentProcessor.LoadDocument("Demo.pdf");
// Access third page properties
PdfPageFacade pageFacade = pdfDocumentProcessor.DocumentFacade.Pages[2];
// Create a Fit destination that refers to the third page
PdfFitDestination destination = pageFacade.CreateFitDestination();
// Find a specific phrase
string linkText = "JBIG2 images";
PdfTextSearchResults linkSearchResults = pdfDocumentProcessor.FindText(linkText);
// If the phrase is found, obtain its bounding rectangle
if (linkSearchResults.Status == PdfTextSearchStatus.Found)
{
PdfRectangle linkRectangle = linkSearchResults.Rectangles[0].BoundingRectangle;
// Access first page properties
PdfPageFacade linkPageFacade =
pdfDocumentProcessor.DocumentFacade.Pages[linkSearchResults.PageNumber -1];
// 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");
}
Using pdfDocumentProcessor As New PdfDocumentProcessor()
' Load a document
pdfDocumentProcessor.LoadDocument("Demo.pdf")
' Access third page properties
Dim pageFacade As PdfPageFacade = pdfDocumentProcessor.DocumentFacade.Pages(2)
' Create a Fit destination that refers to the third page
Dim destination As PdfFitDestination = pageFacade.CreateFitDestination()
' Find a specific phrase
Dim linkText As String = "JBIG2 images"
Dim linkSearchResults As PdfTextSearchResults = pdfDocumentProcessor.FindText(linkText)
' If the phrase is found, obtain its bounding rectangle
If linkSearchResults.Status = PdfTextSearchStatus.Found Then
Dim linkRectangle As PdfRectangle = linkSearchResults.Rectangles(0).BoundingRectangle
' Access first page properties
Dim linkPageFacade As PdfPageFacade = pdfDocumentProcessor.DocumentFacade.Pages(linkSearchResults.PageNumber -1)
'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
Object DevExpress.Pdf.Native.PdfDocumentItem DevExpress.Pdf.Native.PdfObject PdfDestination PdfFitDestination
See Also