Class PdfDestination
- Namespace
- Syncfusion.Pdf.Interactive
- Assembly
- Syncfusion.Pdf.Portable.dll
Represents an anchor in the document where bookmarks or annotations can direct when clicked.
public class PdfDestination
- Inheritance
-
PdfDestination
- Derived
- Inherited Members
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)
Remarks
We can set the destination page for bookmarks or annotation using this PdfDestination class.Please refer the UG docuemntation link
Constructors
PdfDestination(PdfPageBase)
Initializes a new instance of the PdfDestination class with specified page.
public PdfDestination(PdfPageBase page)
Parameters
page
PdfPageBaseThe 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.
public PdfDestination(PdfPageBase page, PointF location)
Parameters
page
PdfPageBaseThe page where the destination should be placed.
location
PointFThe 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.
public bool IsValid { get; }
Property Value
- bool
true
if this instance is valid; otherwise,false
.
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.
public PointF Location { get; set; }
Property Value
- 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.
public PdfDestinationMode Mode { get; set; }
Property Value
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.
public PdfPageBase Page { get; set; }
Property Value
- See Also
PageIndex
Gets the page index of bookmark destination
public int PageIndex { get; }
Property Value
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)
- See Also
Zoom
Gets or sets zoom factor.
public float Zoom { get; set; }
Property Value
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)
- See Also