iTextSharp Use Link Inside PdfPCell

Posted by Baxter on Stack Overflow See other posts from Stack Overflow or by Baxter
Published on 2013-11-06T21:14:45Z Indexed on 2013/11/06 21:53 UTC
Read the original article Hit count: 785

Filed under:
|
|
|
|

I am able to successfully put a link in the pdf with a friendly name:

            Anchor anchor = new Anchor("Google", linkFont);
            anchor.Reference = "https://www.google.com";
            doc.Add(anchor);

enter image description here

However, I cannot get get the anchor to work within a PdfPCell.
Here is what I have tried so far:

            var memberCell = new PdfPCell();
            Anchor anchor = new Anchor("Google", linkFont);
            anchor.Reference = "https://www.google.com";
            memberCell.AddElement(new Anchor(anchor));

That displays the exception: System.ArgumentException: Element not allowed.

I also tried:

            var memberCell = new PdfPCell();
            Anchor anchor = new Anchor("Google", linkFont);
            anchor.Reference = "https://www.google.com";
            memberCell.AddElement(new Phrase(anchor));

This does not throw an exception but it isn't a link it is just the word "Google".

I am using the newest version of iTextSharp at this time v.(5.4.4.0)
Any help on this would be greatly appreciated.

© Stack Overflow or respective owner

Related posts about pdf

Related posts about hyperlink