Wednesday, 16 October 2013

Converting HTML text to image using C#

Hi,
This post talks about converting HTML text to image. That is, saving as an image, the HTML that is rendered in the browser. (basically taking an image of the browser)
The code uses an external dll (HtmlRenderer) that needs to be added in out project. HtmlRenderer namespace provides a class “HtmlRender” that provides an overloaded method “Render“. This method saves renders the html text and saves the outcome as an image.
The following code shows the usage of the method.

namespace HtmlToBmpImageDemo
{
     class Program
     {
         static void Main(string[] args)
         {
               Bitmap m_Bitmap = new Bitmap(400, 600);
               PointF point = new PointF(0, 0);
               SizeF maxSize = new System.Drawing.SizeF(500, 500);
               HtmlRenderer.HtmlRender.Render(Graphics.FromImage(m_Bitmap), 
                                              "<html><body><p>This is a sample html code</p>"
                                              + "<p>This is another html line</p></body>", 
                                               point, maxSize);
               
               m_Bitmap.Save(@"C:\Test.bmp");
         }
     }
}

The problem with this method is that if we include images in the HTML mark up text, the corresponding image doesn’t show the image in the created image (hope you understand the previous line!). There is yet another method of taking a screenshot of rendered html by opening a browser process in the background and then taking a screen shot of that. But I wanted a more lighter and simpler process and found this.
Hope this helps and please do let me know if there is any method of displaying images and then taking a screen shot of that rendered HTML.

Tuesday, 15 October 2013

[RESOLVED] SQL Server 2008 R2 installation missing “Integration Services” Shared feature in features selection step

Hi, [Resolution included below]
[SCENARIO]
I was installing SQL Server 2008 R2 Enterprise Edition in my system. The installation process worked perfectly except that in one of the steps where we are supposed to select the features, I observed that "Integration Services" shared feature was MISSING in the features list.
Please check the screenshots below. The first screenshot is what I was getting DURING INSTALLATION. Second screenshot is what I was SUPPOSED TO GET BUT NOT GETTING.
This is what I was getting in my machine while installation
This is what I was actually supposed to get but NOT GETTING

[RESOLUTION TO THIS]
First thing to note here is that what I was trying to install was NOT Enterprise Edition, but it was Workgroup Edition. Check the screen shot below. This is the same screen shot that I have uploaded above thinking that I was installing Enterprise Edition when in fact, it was Workgroup edition.

So all I had to do was to enter the Enterprise Edition KEY while installation and re-run the installation again. This time I got the Integration Services Shared Feature in the list.

Hope this helps!!

.NET Framework tutorial for absolute beginners Part#3


This video is THIRD in the series of video that I will be posting here. In this video, I mainly
talk about C# programming language, the features that it provides and also I show the first Hello World Console Application using Visual Studio.

.NET Framework tutorial for absolute beginners Part#2


This video is SECOND in the series of videos that I will be posting that explain the .NET Framework, it’s architecture and different types of applications that can be developed on .NET Framework, from the very beginning. This series of videos is mainly targeted to developers who are completely new to .NET Framework.

.NET Framework tutorial for absolute beginners Part#1


This video is FIRST in the series of videos that I will be posting that explain the .NET Framework, it’s architecture and different types of applications that can be developed on .NET Framework, from the very beginning. This series of videos is mainly targeted to developers who are completely new to .NET Framework.