Class PdfDestination
Represents an anchor in the document where bookmarks or annotations can direct when clicked.
Namespace: Syncfusion.Pdf.Interactive
Assembly: Syncfusion.Pdf.NET.dll
Syntax
public class PdfDestination : Object, IPdfWrapper
Remarks
We can set the destination page for bookmarks or annotation using this PdfDestination class.Please refer the UG docuemntation link https://help.syncfusion.com/file-formats/pdf/working-with-bookmarks#adding-bookmarks-in-a-pdf for more details.
Examples
//Create a new document.
PdfDocument document = new PdfDocument();
//Add a page.
PdfPage page = document.Pages.Add();
//Create document bookmarks.
PdfBookmark bookmark = document.Bookmarks.Add("Page 1");
//Create the destination.
PdfDestination destination = new PdfDestination(page);
//Set the destination page.
bookmark.Destination = destination;
//Set the destination location.
bookmark.Destination.Location = new PointF(20, 20);
//Set the text style and color.
bookmark.TextStyle = PdfTextStyle.Bold;
bookmark.Color = Color.Red;
//Save and close the PDF document.
document.Save("Output.pdf");
document.Close(true);
'Create a new document.
Dim document As New PdfDocument()
'Add a page.
Dim page As PdfPage = document.Pages.Add()
'Create document bookmarks.
Dim bookmark As PdfBookmark = document.Bookmarks.Add("Page 1")
'Create the destination.
Dim destination As PdfDestination = New PdfDestination(page)
'Set the destination location.
destination.Location = New PointF(20, 20)
'Set the destination page.
bookmark.Destination = destination
'Set the text style and color.
bookmark.TextStyle = PdfTextStyle.Bold
bookmark.Color = Color.Red
'Save and close the PDF document.
document.Save("Output.pdf")
document.Close(True)
Constructors
PdfDestination(PdfPageBase)
Initializes a new instance of the PdfDestination class with specified page.
Declaration
public PdfDestination(PdfPageBase page)
Parameters
Type | Name | Description |
---|---|---|
PdfPageBase | page | The page where the destination should be placed. |
Examples
//Create a new document.
PdfDocument document = new PdfDocument();
//Add a page.
PdfPage page = document.Pages.Add();
//Create document bookmarks.
PdfBookmark bookmark = document.Bookmarks.Add("Page 1");
//Create the destination
PdfDestination destination = new PdfDestination(page);
//Set the destination page.
bookmark.Destination = destination;
//Set the text style and color.
bookmark.TextStyle = PdfTextStyle.Bold;
bookmark.Color = Color.Red;
//Save and close the PDF document.
document.Save("Output.pdf");
document.Close(true);
'Create a new document.
Dim document As New PdfDocument()
'Add a page.
Dim page As PdfPage = document.Pages.Add()
'Create document bookmarks.
Dim bookmark As PdfBookmark = document.Bookmarks.Add("Page 1")
'Create the destination
Dim destination As PdfDestination = New PdfDestination(page)
'Set the destination page.
bookmark.Destination = destination
'Set the text style and color.
bookmark.TextStyle = PdfTextStyle.Bold
bookmark.Color = Color.Red
'Save and close the PDF document.
document.Save("Output.pdf")
document.Close(True)
See Also
PdfDestination(PdfPageBase, PointF)
Initializes a new instance of the PdfDestination class with specified page base and location.
Declaration
public PdfDestination(PdfPageBase page, PointF location)
Parameters
Type | Name | Description |
---|---|---|
PdfPageBase | page | The page where the destination should be placed. |
PointF | location | The location of the page. |
Examples
//Create a new document.
PdfDocument document = new PdfDocument();
//Add a page.
PdfPage page = document.Pages.Add();
//Create document bookmarks.
PdfBookmark bookmark = document.Bookmarks.Add("Page 1");
//Create the destination.
PdfDestination destination = new PdfDestination(page,new PointF(0, 100));
//Set the destination page.
bookmark.Destination = destination;
//Set the text style and color.
bookmark.TextStyle = PdfTextStyle.Bold;
bookmark.Color = Color.Red;
//Save and close the PDF document.
document.Save("Output.pdf");
document.Close(true);
'Create a new document.
Dim document As New PdfDocument()
'Add a page.
Dim page As PdfPage = document.Pages.Add()
'Create document bookmarks.
Dim bookmark As PdfBookmark = document.Bookmarks.Add("Page 1")
'Create the destination
Dim destination As PdfDestination = New PdfDestination(page,new PointF(0, 100))
'Set the destination page.
bookmark.Destination = destination
'Set the text style and color.
bookmark.TextStyle = PdfTextStyle.Bold
bookmark.Color = Color.Red
'Save and close the PDF document.
document.Save("Output.pdf")
document.Close(True)
See Also
Properties
IsValid
Gets a value indicating whether this instance is valid.
Declaration
public bool IsValid { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Examples
//Create a new document.
PdfDocument document = new PdfDocument();
//Add a page.
PdfPage page = document.Pages.Add();
//Create document bookmarks.
PdfBookmark bookmark = document.Bookmarks.Add("Page 1");
//Create the destination
PdfDestination destination = new PdfDestination(page);
//Gets a value indicating whether this instance is valid.
bool isValid = destination.IsValid;
//Set the destination page.
bookmark.Destination = destination;
//Set the text style and color.
bookmark.TextStyle = PdfTextStyle.Bold;
bookmark.Color = Color.Red;
//Save and close the PDF document.
document.Save("Output.pdf");
document.Close(true);
'Create a new document.
Dim document As New PdfDocument()
'Add a page.
Dim page As PdfPage = document.Pages.Add()
'Create document bookmarks.
Dim bookmark As PdfBookmark = document.Bookmarks.Add("Page 1")
'Create the destination
Dim destination As PdfDestination = New PdfDestination(page)
'Gets a value indicating whether this instance is valid.
bool isValid = destination.IsValid
'Set the destination page.
bookmark.Destination = destination
'Set the text style and color.
bookmark.TextStyle = PdfTextStyle.Bold
bookmark.Color = Color.Red
'Save and close the PDF document.
document.Save("Output.pdf")
document.Close(True)
See Also
Location
Gets or sets a location of the destination.
Declaration
public PointF Location { get; set; }
Property Value
Type |
---|
PointF |
Examples
//Create a new document.
PdfDocument document = new PdfDocument();
//Add a page.
PdfPage page = document.Pages.Add();
//Create document bookmarks.
PdfBookmark bookmark = document.Bookmarks.Add("Page 1");
//Create the destination
PdfDestination destination = new PdfDestination(page);
//Set the location of the destination.
destination.Location = new PointF(20, 20);
//Set the destination page.
bookmark.Destination = destination;
//Set the text style and color.
bookmark.TextStyle = PdfTextStyle.Bold;
bookmark.Color = Color.Red;
//Save and close the PDF document.
document.Save("Output.pdf");
document.Close(true);
'Create a new document.
Dim document As New PdfDocument()
'Add a page.
Dim page As PdfPage = document.Pages.Add()
'Create document bookmarks.
Dim bookmark As PdfBookmark = document.Bookmarks.Add("Page 1")
'Create the destination
Dim destination As PdfDestination = New PdfDestination(page)
'Set the location of the destinatioin.
destination.Location = new PointF(20, 20)
'Set the destination page.
bookmark.Destination = destination
'Set the text style and color.
bookmark.TextStyle = PdfTextStyle.Bold
bookmark.Color = Color.Red
'Save and close the PDF document.
document.Save("Output.pdf")
document.Close(True)
See Also
Mode
Gets or sets mode of the destination.
Declaration
public PdfDestinationMode Mode { get; set; }
Property Value
Type |
---|
PdfDestinationMode |
Examples
//Create a new document.
PdfDocument document = new PdfDocument();
//Add a page.
PdfPage page = document.Pages.Add();
//Create document bookmarks.
PdfBookmark bookmark = document.Bookmarks.Add("Page 1");
//Create the destination.
PdfDestination destination = new PdfDestination(page,new PointF(0, 100));
//Set the destination mode.
destination.Mode = PdfDestinationMode.FitToPage;
//Set the destination page.
bookmark.Destination = destination;
//Set the text style and color.
bookmark.TextStyle = PdfTextStyle.Bold;
bookmark.Color = Color.Red;
//Save and close the PDF document.
document.Save("Output.pdf");
document.Close(true);
'Create a new document.
Dim document As New PdfDocument()
'Add a page.
Dim page As PdfPage = document.Pages.Add()
'Create document bookmarks.
Dim bookmark As PdfBookmark = document.Bookmarks.Add("Page 1")
'Create the destination.
Dim destination As PdfDestination = New PdfDestination(page,new PointF(0, 100))
'Set the destination mode.
destination.Mode = PdfDestinationMode.FitToPage
'Set the destination page.
bookmark.Destination = destination
'Set the text style and color.
bookmark.TextStyle = PdfTextStyle.Bold
bookmark.Color = Color.Red
'Save and close the PDF document.
document.Save("Output.pdf")
document.Close(True)
See Also
Page
Gets or sets a page where the destination is situated.
Declaration
public PdfPageBase Page { get; set; }
Property Value
Type |
---|
PdfPageBase |
PageIndex
Gets the page index of bookmark destination
Declaration
public int PageIndex { get; }
Property Value
Type |
---|
System.Int32 |
Examples
//Loads the PDF document.
PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf");
//Gets all the bookmarks.
PdfBookmarkBase bookmarks = document.Bookmarks;
//Gets the first bookmark and changes the properties of the bookmark.
PdfLoadedBookmark bookmark = bookmarks[0] as PdfLoadedBookmark;
//int pageIndex = bookmark.Destination.PageIndex;
//Saves the document
document.Save("Output.pdf");
document.Close(true);
'Loads the PDF document.
Dim document As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf")
'Gets all the bookmarks.
Dim bookmarks As PdfBookmarkBase = document.Bookmarks
'Gets the first bookmark and changes the properties of the bookmark.
Dim bookmark As PdfLoadedBookmark = TryCast(bookmarks(0), PdfLoadedBookmark)
Dim pageIndex As Integer = bookmark.Destination.PageIndex
'Saves the document.
document.Save("Output.pdf")
document.Close(True)
Zoom
Gets or sets zoom factor.
Declaration
public float Zoom { get; set; }
Property Value
Type |
---|
System.Single |
Examples
//Create a new document.
PdfDocument document = new PdfDocument();
//Add a page.
PdfPage page = document.Pages.Add();
//Create document bookmarks.
PdfBookmark bookmark = document.Bookmarks.Add("Page 1");
//Create the destination.
PdfDestination destination = new PdfDestination(page,new PointF(0, 100));
//Set the zoom factor.
destination.Zoom = 100;
//Set the destination page.
bookmark.Destination = destination;
//Set the text style and color.
bookmark.TextStyle = PdfTextStyle.Bold;
bookmark.Color = Color.Red;
//Save and close the PDF document.
document.Save("Output.pdf");
document.Close(true);
'Create a new document.
Dim document As New PdfDocument()
'Add a page.
Dim page As PdfPage = document.Pages.Add()
'Create document bookmarks.
Dim bookmark As PdfBookmark = document.Bookmarks.Add("Page 1")
'Create the destination
Dim destination As PdfDestination = New PdfDestination(page,new PointF(0, 100))
'Set the zoom factor.
destination.Zoom = 100
'Set the destination page.
bookmark.Destination = destination
'Set the text style and color.
bookmark.TextStyle = PdfTextStyle.Bold
bookmark.Color = Color.Red
'Save and close the PDF document.
document.Save("Output.pdf")
document.Close(True)