0

I am creating a PDF using iTextSharp that copies the pages from another PDF which works fine. The next requirement was that I make sure that I copy across any internal links as well which I got working with the answer on here: Itextsharp: Is There Any Way To Copy Links When Import Pages?

The problem I have now is that I need to move the position of the link up a bit as the new PDF has a different page height to the original and the links don't line up in the new PDF.

Is there a way of changing the position of a link? I can see the 'urx' property within it but there doesn't seem to be a way of changing it. The only potential option I can find is the TransformRect method but I can't find any documentation on how it works.

Community
  • 1
  • 1
Nick Reeve
  • 1,658
  • 2
  • 22
  • 32
  • 1
    Check out [this post](http://stackoverflow.com/a/6599734/231316) and [this post](http://stackoverflow.com/a/8141831/231316) which shows how to walk and update links. In those cases we were updating locations but the same ideas should apply. – Chris Haas Apr 29 '16 at 18:33
  • Thanks Chris but I don't see how this helps with moving the position of the links within the page? – Nick Reeve Apr 30 '16 at 11:24
  • 1
    Those posts show you how to walk the annotations (which links are a type of), "find" the ones you are looking for and modify their properties via the `Put` method. In your case you'll want to change the `PdfName.RECT` entry (or possibly the PdfName.QUADPOINTS) to what you want. If I had more time I'd whip up a demo but unfortunately I don't. – Chris Haas Apr 30 '16 at 16:35
  • Can't use the Put method on PdfName.RECT annotations as that seems to be a PdfArray not PdfDictionary. Tried just assigning a new Rectangle to by doing this: `PdfArray AnnotationRect = (PdfArray)AnnotationDictionary.Get(PdfName.RECT); AnnotationRect = new PdfArray(new float[] {100f, 100f, 100f, 100f});` but it didn't change them at all in outputted file – Nick Reeve May 05 '16 at 11:41

0 Answers0