Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 带超链接的itextsharp图像_C#_Itextsharp - Fatal编程技术网

C# 带超链接的itextsharp图像

C# 带超链接的itextsharp图像,c#,itextsharp,C#,Itextsharp,我使用itextsharp库和c#创建了一个pdf,其中包含一个图像。现在,我需要有一个超链接的形象,这样当点击它,它去一个特定的网站。我该怎么做? 我试图找到链接到图像对象的属性,但找不到。您必须使用 对于iText7 var url = "micorosft.com"; var fbImageData = ImageDataFactory.Create("c:/temp/fb.png"); var fbImage = new Image(fbImage

我使用itextsharp库和c#创建了一个pdf,其中包含一个图像。现在,我需要有一个超链接的形象,这样当点击它,它去一个特定的网站。我该怎么做? 我试图找到链接到图像对象的属性,但找不到。

您必须使用


对于iText7

var url = "micorosft.com";
var fbImageData = ImageDataFactory.Create("c:/temp/fb.png");
var fbImage = new Image(fbImageData);
var twImageData = ImageDataFactory.Create("c:/temp/tw.png");
var twImage = new Image(twImageData);

fbImage.SetMaxWidth(16);
fbImage.SetMaxHeight(16);
fbImage.SetAction(PdfAction.CreateURI($"https://www.facebook.com/sharer/sharer.php?u={url}&quote={"quotegoeshere"}"));

twImage.SetMaxWidth(16);
twImage.SetMaxHeight(16);
twImage.SetAction(PdfAction.CreateURI($"https://twitter.com/intent/tweet?text={"randomtextgoeshere"}" + $" {url}"));
我将“http://”部分添加到anchor.Reference中。我在正确渲染图像时遇到问题。不确定这是否消除了潜在的bug。
var url = "micorosft.com";
var fbImageData = ImageDataFactory.Create("c:/temp/fb.png");
var fbImage = new Image(fbImageData);
var twImageData = ImageDataFactory.Create("c:/temp/tw.png");
var twImage = new Image(twImageData);

fbImage.SetMaxWidth(16);
fbImage.SetMaxHeight(16);
fbImage.SetAction(PdfAction.CreateURI($"https://www.facebook.com/sharer/sharer.php?u={url}&quote={"quotegoeshere"}"));

twImage.SetMaxWidth(16);
twImage.SetMaxHeight(16);
twImage.SetAction(PdfAction.CreateURI($"https://twitter.com/intent/tweet?text={"randomtextgoeshere"}" + $" {url}"));