问题描述:

在开发中我们经常需要类似于打印的功能,如何将html显示的效果转化成Image图片呢

 

解决方案:(c#)

从Nuget中安装HtmlRenderer.WinForms (这个包就有 HtmlRenderer dll)

 

private void ConvertHtmlContentToImage()
{
   string html = "<h1>Welcome </h1><div><img src='https://www.google.com.sg/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png'/></div>";
   var image = HtmlRender.RenderToImage(html);

   image.Save("E:\\UserGoogle1.jpg");
}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-25
  • 2022-12-23
  • 2021-11-24
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-04-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-19
相关资源
相似解决方案