-1

I'm trying to find out dead bookmarks and links on pdf, for that i'm storing all the named destinations in a dictionary and trying to store target page, so that i can validate its valid page or not? I'm trying something like this..

       For Each named As KeyValuePair(Of String, PdfObject) In reader.GetNamedDestinationFromStrings()

            If Not namedDestinations.ContainsKey(named.Key) Then
                namedDestinations.Add(named.Key, named.Value)

                Dim thisDest As PdfArray = DirectCast(named.Value, PdfArray)

                Dim a As PdfIndirectReference = DirectCast(thisDest(0), PdfIndirectReference)

                Dim thisPage As PdfDictionary = PdfReader.GetPdfObject(a)

            End If
        Next

this code i have copied from other thread, i need to catch up the page number. Or else do we have any other method to validate dead links and bookmarks..

arivu
  • 15
  • 5
  • I assume that you copied some code without having a clue what it's about. As a result the people reading your question don't have a clue what you are trying to achieve. We can read your question, but the code snippet doesn't seem to be related to the question. – Bruno Lowagie May 16 '14 at 14:36
  • http://stackoverflow.com/questions/10315797/how-do-i-get-section-target-page-number-in-pdf-file-using-itextsharp, i read this forum to find target page from annotations, the same i applied to suite my program..., there is no clue how to reach page number from thisPage.., thats my question.. – arivu May 17 '14 at 04:18
  • `For k As Integer = 1 To reader.NumberOfPages If thisPage.Equals(reader.GetPageN(k)) Then msgbox k Exit For End If Next`, if I use this code i can catch the page number, but do we have any other straight forward method to fetch page number.. – arivu May 17 '14 at 08:14

1 Answers1

1

To rephrase your question: you want to get all the named destinations from a PDF document, but instead of the page references, you want to get the page numbers.

However, you are using reader.GetNamedDestinationFromStrings() which returns page references.

Instead, you should use:

Dictionary<string,string> map = SimpleNamedDestination.GetNamedDestination(reader, false);

which gives you destinations in the form of a ´string´ (the values of the Dictionary).

Such a string looks like this: 3 XYZ 36 802 0 where the first element (3) is the page number.

Bruno Lowagie
  • 75,994
  • 9
  • 109
  • 165
  • do we have any methods to get as string from page annotations like this? – arivu May 19 '14 at 06:30
  • You'll have to be more specific. (References to) Named destinations are stored in the root object of a PDF. (References to) Annotations are stored in the /Annots array of a page. Named destinations can be used in Link annotations. Link annotations are only one type of many possible types of annotations. It is not clear what you mean when you ask to *get as string from page annotations* because some annotations are hard to capture in a string. – Bruno Lowagie May 19 '14 at 06:50