Html生成图片

       var converter = new HtmlConverter();
            string html = string.Format("<html><meta http-equiv='content-type' content='text/html; charset=utf-8'><div style='background-color:#d0e4fe;height:734px'><h1 style='color:orange;text-align:center;'>xxx有限公司</h1><p style='font-size:20px;'> 产品属性</p><img style='width:734px' src='{0}' ></div></html>", "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fhkyuncms.oss-cn-beijing.aliyuncs.com%2F%2Fwebpic%2FW0202106%2FW020210630%2FW020210630586148218826.png&refer=http%3A%2F%2Fhkyuncms.oss-cn-beijing.aliyuncs.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1657174511&t=1a8af874e1c15f313028f1e60145bc3f");
            var bytes = converter.FromHtmlString(html, 750);
            File.WriteAllBytes("image.jpg", bytes);

 

posted @ 2022-08-16 10:11  极客船长  阅读(302)  评论(0编辑  收藏  举报