Quantcast
Channel: HTML Renderer
Viewing all articles
Browse latest Browse all 693

New Post: the image is just black

$
0
0
I changed your code a little and the result is almost perfect, I think there is a bug where the height of the body is not respected, will check it in a few days.
Note, I have added "margin: 0px; height: 461px;" to body style and used "HtmlRender.RenderToImage" method.
Size maxSize = new Size(755, 461);
string path = " D://OriginalImage.png";
string newPath = "D://NewImage.png";

var sertifikaMesaji = "<html><body style=\"margin: 0px; height: 461px; background-image:url(" + path + ");background-repeat:no-repeat;\"><h1 style=\" margin-top:40px;margin-left:150px;\">"
+ "<span style=\"font-family:Monotype Corsiva;\"><em>Test HTML</em></span></h1><div style=\"width:560px;height:200px;margin-top:120px;margin-right:55px;margin-left:150px;\"><em>"
+ "<span style=\"font-family:Monotype Corsiva;\"><span style=\"font-size:22px;\">Some Text Here</span></span></em></div></body></html>";

var img = HtmlRenderer.HtmlRender.RenderToImage(sertifikaMesaji, maxSize);
img.Save(newPath, ImageFormat.Png);
Result:
Image

Viewing all articles
Browse latest Browse all 693

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>