Pregunta

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..

¿Fue útil?

Solución

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top