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);
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.
Instead of an Anchor
use a Chunk
and call the SetAnchor()
method:
var c = new Chunk("Google");
c.SetAnchor("https://www.google.com");
memberCell.AddElement(c);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With