PDF - jump to named destination?

Discussions about document viewing.
Post Reply
jckeith
Posts: 3
Joined: Wed Dec 26, 2012 6:56 pm

PDF - jump to named destination?

Post by jckeith » Wed Dec 26, 2012 7:06 pm

We currently have several PDF documents which have named destinations defined in them. We use a third-party component to render the PDFs, and in certain circumstances, to jump to one of the named destinations. Is there a way to navigate to a named destination within a PDF with the GdViewer component? Or perhaps the PDF plugin?

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: PDF - jump to named destination?

Post by Loïc » Wed Dec 26, 2012 9:36 pm

Hello,

Latest version of GdPicture.NET automatically jumps to any kind of destination. Have you tried it?

With best regards,

Loïc

jckeith
Posts: 3
Joined: Wed Dec 26, 2012 6:56 pm

Re: PDF - jump to named destination?

Post by jckeith » Wed Dec 26, 2012 9:58 pm

Hi Loïc,

Yes, I currently have the latest version with a demo license. I've looked through the API, but can't find out how to do this. I can see how to go to different pages within a PDF, or how to scroll through it, but not how to go to a named destination. Let's say my PDF has a destination defined with the name "section1". How would I navigate to that destination after loading the document. Something along these lines:

Code: Select all

LicenseManager l = new LicenseManager();
l.RegisterKEY("...");
GdViewer viewer = new GdViewer();
viewer.DisplayFromFile("test.pdf");
/* viewer.GoToDestination("section1")  <-- what goes here?  */

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: PDF - jump to named destination?

Post by Loïc » Fri Dec 28, 2012 12:02 am

Hello,

In the GdViewer object, destination are reached by user interaction on annotations and bookmarks.

Doing what you need is possible by using the GdPicturePDF class that provides all functions to get information about destination target in the PDF. Se the Action section, particularly in the GetActionPageDestination() method description: https://www.gdpicture.com/guides/gdpicture/v9/html/con ... ingle.html

Let me know if you need further details.

With best regards,

Loïc

jckeith
Posts: 3
Joined: Wed Dec 26, 2012 6:56 pm

Re: PDF - jump to named destination?

Post by jckeith » Fri Dec 28, 2012 6:08 pm

Okay, I'm getting closer now. It looks like what I need is to get the page number associated with a bookmark, so that I can tell the viewer to go to that page. Note that I only know the bookmark's name (maybe the same thing as title), not its integer ID. Looking through the GdPicturePDF class and GdViewer class, I don't see anything like this. Is there any way to do this? Thanks.

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: PDF - jump to named destination?

Post by Loïc » Wed Jan 02, 2013 4:47 pm

Hello,

Could you clarify what you meant by " I don't see anything like this" ?

If you are trying to get the ID of a bookmark based on its name you have to parse the PDF outlines. Here an example:

Code: Select all

 Private Sub parseOutlines(ByVal oGdPicturePDF As GdPicturePDF, ByVal bookmarkID As Integer, ByVal level As Integer)
        While True
            MessageBox.Show("Title: " + oGdPicturePDF.GetBookMarkTitle(bookmarkID) + ". level: " + level.ToString())
            'Check childs
            If oGdPicturePDF.GetBookMarkChildCount(bookmarkID) > 0 Then
                parseOutlines(oGdPicturePDF, oGdPicturePDF.GetBookMarkFirstChildID(bookmarkID), level + 1)
            End If

            'Check for subsequent outlines
            bookmarkID = oGdPicturePDF.GetBookMarkNextID(bookmarkID)
            If bookmarkID = 0 Then
                Exit While
            End If
        End While
    End Sub


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Using oGdPicturePDF As New GdPicturePDF
            oGdPicturePDF.LoadFromFile("c:\outlines.pdf", False)
            parseOutlines(oGdPicturePDF, oGdPicturePDF.GetBookMarkRootID(), 0)
        End Using
    End Sub
Kind regards,

Loïc

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest