Let me clarify, if you want some image to be the background of the rendered html you can do it like so:
![Image]()
Note:
- save the attached html to 'c:\html.txt'
- save this image to 'c:\b.jpg'
-
run the attached code
var img = HtmlRender.RenderToImage(File.ReadAllText(@"c:\html.txt"), 600);
HTML to render:<style>
body{
margin: 0px;
padding: 0px 15px;
font-family:Arial,san-serif;
font-size: 20px;
background-image:url('c:\b.jpg');
}
.green{
background-color:rgba(0,255,0,60)
}
</style>
<html>
<body>
<p class="green">This is a <strong>nice</strong> html code</p>
<p>Hopefully this wraps around without any issues. We must make sure that this can wrap properly without issues.</p>
<p>Hopefully this wraps around without any issues. We must make sure that this can wrap properly without issues.</p>
<p>Hopefully this wraps around without any issues. We must make sure that this can wrap properly without issues.</p>
</body>
</html>Result:
Note:
- The background image is repeated by default but this can be changed using css
- I set the green background to be partially transparent to show it is possible
-
you can extract the embedded css inside <style> element outside using 'CssData.Parse' and pass it to 'HtmlRender.RenderToImage'