使用HtmlRenderer将HTML转换为图像 [英] Converting HTML to image using HtmlRenderer
问题描述
您好,
我正在尝试使用HtmlRenderer将HTML转换为图片,其中包含2张图片,其中一张图片位于另一张图片的顶部,我尝试使用以下代码
位图m_Bitmap =新位图(700,900);
PointF point = new PointF(0,0);
SizeF maxSize = new System .Drawing.SizeF(800,1000);
string html =< html>< head>< / head>< body> Test< img style = \position:absolute ;左:199px;顶部:293px; \src = \file:/// C:/Users/crakhuc/Desktop/Small.jpg \>
< / body>< / html>;
HtmlRenderer.HtmlRender.Render(Graphics.FromImage(m_Bitmap),html,point,maxSize);
m_Bitmap.Save(@C :\ Test.png,ImageFormat.Png);
问题是第二张图片不是第一张图片它出现在第一张图片的底部
Hello,
I am trying to convert HTML to image using HtmlRenderer which contain 2 image in which one image is on the top of another I tried following code
Bitmap m_Bitmap = new Bitmap(700, 900);
PointF point = new PointF(0, 0);
SizeF maxSize = new System.Drawing.SizeF(800, 1000);
string html = "<html><head></head><body> Test<img style=\"position: absolute; left: 199px; top: 293px;\" src=\"file:///C:/Users/crakhuc/Desktop/Small.jpg\">
</body></html>";
HtmlRenderer.HtmlRender.Render(Graphics.FromImage(m_Bitmap),html,point, maxSize);
m_Bitmap.Save(@"C:\Test.png", ImageFormat.Png);
Problem with this is that second image dont come on top of first it comes at bottom of first image
推荐答案
看这里
http://stackoverflow.com/questions/17832304/convert-html-string-to-image [< a href =http://stackoverflow.com/questions/17832304/convert-html-string-to-imagetarget =_ blanktitle =New Window> ^ ]
http://stackoverflow.com/questions/968201/ convert-web-page-to-image [ ^ ]
See here
http://stackoverflow.com/questions/17832304/convert-html-string-to-image[^]
http://stackoverflow.com/questions/968201/convert-web-page-to-image[^]
这篇关于使用HtmlRenderer将HTML转换为图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!