PdfDocumentProcessor.CreateDestination(Int32, Single) Method
Creates a destination for targets in the document (e.g., bookmarks) using a page number, and zoom factor.
Namespace: DevExpress.Pdf
Assembly: DevExpress.Docs.v20.2.dll
NuGet Package: DevExpress.Document.Processor
Declaration
Parameters
Name | Type | Description |
---|---|---|
pageNumber | Int32 | An integer value that is the page number where the destination is created. |
zoomFactor | Single | The zoom level by which a page destination is created. |
Returns
Type | Description |
---|---|
PdfDestination | A PdfDestination object that is the page destination. |
Remarks
The overloaded CreateDestination method converts world coordinates to page coordinates. See the Coordinate Systems topic to learn more.
Use this method to create a destination that points to a specific location and view in a document. The created destination is assigned to the PdfBookmark.Destination property.
For more information about the bookmarks creation, see the Bookmarks topic.
Example
This example shows how to create bookmarks in code.
To do this:
- Create a PdfBookmark object;
- Specify the bookmark title and destination using the PdfBookmark.Title and PdfBookmark.Destination properties. To create a destination, call one of the PdfDocumentProcessor.CreateDestination overloaded methods.
- Add the bookmark to the PdfBookmark collection, which is accessed from the PdfDocument.Bookmarks property.
using DevExpress.Pdf;
namespace AddBookmarks {
class Program {
static void Main(string[] args) {
using (PdfDocumentProcessor processor = new PdfDocumentProcessor()) {
// Load a document.
processor.LoadDocument("..\\..\\Document.pdf");
// Create bookmarks and add them to the PDF document.
PdfDestination destination1 = processor.CreateDestination(1, 180, 150);
PdfDestination destination2 = processor.CreateDestination(1, 168, 230);
PdfDestination destination3 = processor.CreateDestination(1, 20, 350);
processor.Document.Bookmarks.Add(new PdfBookmark() { Title = "PDF Document Processor", Destination = destination1 });
processor.Document.Bookmarks.Add(new PdfBookmark() { Title = "Display, Print and Export PDF Documents", Destination = destination2 });
processor.Document.Bookmarks.Add(new PdfBookmark() { Title = "Learn More", Destination = destination3 });
// Save the result document.
processor.SaveDocument("..\\..\\Result.pdf");
}
}
}
}