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

New Post: HtmlRender.Render - Pixilated Images

$
0
0
Let me clarify, if you want some image to be the background of the rendered html you can do it like so:
  1. save the attached html to 'c:\html.txt'
  2. save this image to 'c:\b.jpg'
  3. run the attached code
Code to run:
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:
Image

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'
hope it helps.

Viewing all articles
Browse latest Browse all 693

Trending Articles



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