문제

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

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top