PDFRasterizer.NET 4.0 is now available. Supports .NET Core. Renders pixel-perfectly.

Add a link with an internal destination to PDF

This code sample helps with internal links in a PDF.

In this code sample we will look at internal destinations and how you can use them. They are particularly useful in index pages, where you want to “jump” from the overview page to a specific chapter or part.

using (FileStream fileIn = new FileStream(@"..\..\..\inputDocuments\SellingYourHome.pdf", FileMode.Open, FileAccess.Read))
    Document document = new Document(fileIn);

    //creates a new internal destination pointing to page 3
    InternalDestination destination = new InternalDestination();
    destination.Page = document.Pages[2];
    destination.PageDisplay = PageDisplay.FitEntire;

    //the action associated with the link is a go-to action
    GoToAction action = new GoToAction(destination);

    //specify link attributes
    Link link = new Link(100, 100, 300, 200);
    link.BorderStyle = BorderStyle.Solid;
    link.BorderWidth = 1;
    link.BorderColor = RgbColor.Red;


    using (FileStream fileOut = new FileStream(@"..\..\internaldestination.pdf", FileMode.Create, FileAccess.Write))
        Using fileIn As New FileStream("..\..\..\inputDocuments\SellingYourHome.pdf", FileMode.Open, FileAccess.Read)
	Dim document As New Document(fileIn)

	Dim destination As New InternalDestination()
	destination.Page = document.Pages(2)
	destination.PageDisplay = PageDisplay.FitEntire
	Dim action As New GoToAction(destination)
	Dim link As New Link(100, 100, 300, 200)
	link.BorderStyle = BorderStyle.Solid
	link.BorderWidth = 1
	link.BorderColor = RgbColor.Red

    Using fileOut As New FileStream("..\..\internaldestination.pdf", FileMode.Create, FileAccess.Write)
    End Using
End Using
Download PDFKit.NET 5.0
We will send you a download link

  • This field is for validation purposes and should be left unchanged.
Why do we ask your email address?
We send tips that speed up your evaluation
We let you know about bug fixes
You can always unsubscribe with one click
We never share your address with a 3rd party
Thank you for your download

We have sent an email with a download link.