Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/312.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/7/user-interface/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
C# 从html以pdf格式显示在一行中的图像_C#_Asp.net_.net_Asp.net Mvc_Itextsharp - Fatal编程技术网

C# 从html以pdf格式显示在一行中的图像

C# 从html以pdf格式显示在一行中的图像,c#,asp.net,.net,asp.net-mvc,itextsharp,C#,Asp.net,.net,Asp.net Mvc,Itextsharp,我使用iTextSharp从html生成pdf。图像显示不正确。图像的高度不是文本 我创建类来获取小图像 public class ImageHander : IImageProvider { public Image GetImage(string src, Hashtable h, ChainedProperties cprops, IDocListener doc) { var image = Image.GetInstance(src); image.Scal

我使用iTextSharp从html生成pdf。图像显示不正确。图像的高度不是文本

我创建类来获取小图像

public class ImageHander : IImageProvider
{    
  public Image GetImage(string src, Hashtable h, ChainedProperties cprops, IDocListener doc)
  {
   var image = Image.GetInstance(src);
   image.ScaleToFit(500f, 30f);
   return image;
   }    
}
并创建pdf:

PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(FilePath, FileMode.Create));
doc.Open();

Hashtable providers = new Hashtable();
var ih = new ImageHander();

providers.Add("img_provider", ih);

foreach (IElement element in HTMLWorker.ParseToList(
new StringReader(HTMLCode), null, providers))
{       
   doc.Add(element);    
}
doc.Close();

Html是否在浏览器中正确显示?一行是什么意思。是否要限制文本与图像重叠?是的,HTML在我的浏览器中正确显示。我不希望文本与图像重叠。新的测试HTML:test

test

我看到什么时候是图像这段代码添加了带有内容的段落[OBJ]我想OBJ就是图像