PdfStamper.ReplacePage and Links

View: New views
1 Messages — Rating Filter:   Alert me  

PdfStamper.ReplacePage and Links

by merco :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi.
I'm using iTextSharp and i'd like to replace a page (in a different PDF) with a new one preserving the links.
These links are external.

After having the page replaced by PdfStamper.ReplacePage(ReaderPg, Da, A)

I'm using this code to get my links

 Dim Ar As ArrayList
        Dim Annot As PdfAnnotation
        Ar = ReaderPg.GetLinks(Da)

        For Each lnk As PdfAnnotation.PdfImportedLink In Ar
            Dim azione As PdfObject
            Dim Uri As PdfDictionary
            Annot = lnk.CreateAnnotation(PdfStamper.Writer)
            azione = Annot.Get(PdfName.A)
            If Not IsNothing(azione) Then
                Dim Jdfy As PdfObject
                Dim PDfN As New PdfName("JDFY_MyLookupKey3Enc")
                Uri = PdfReader.GetPdfObjectRelease(azione)
                If Uri.Contains(PDfN) Then
                    Jdfy = Uri.Get(PDfN)
                End If
                If Uri.Contains(PdfName.S) Then
                    Jdfy = Uri.Get(PdfName.S)
                End If
            End If
            PdfStamper.AddAnnotation(Annot, A)
        Next


The problem is that the destination links (generated by AddAnnotation) are incorrect , as you can see in this picture:
Page11
The dictionary in Old Links is the old link present in the old replaced page (so ReplacePage can't remove links on destination page ? ).

New Links are different in dictionary : Why ? Is this the correct way to transfer my links ?

The page is visible at : TestPDF


Thank you