0

I have service which converts HTML to image and sends back.

At present I am using WebBrowser control to do that. But it is far from perfect. During peak hours service crashes or gives Null reference exception. Also it is not lightweight on memory. I looking for lightweight managed option to this job.

Kindly let me know for any open source project or for any other managed control which will do this job.

Update: I have very simple HTML to render. It is only with table, paragraph and stylesheet for font and background-color. There is not Javascript, element float or other complex layout.

4
  • You do realize that you are asking for another Browser, right? With all the involved complexities and incompatibilities. Commented Oct 6, 2010 at 12:33
  • check question for update. Not sure if I am asking for another Browser, but another HTML render-er. Commented Oct 6, 2010 at 12:39
  • Yes, but HTML-renderer = 90% off a Browser, and 99.9% off the incompatibilities. Commented Oct 6, 2010 at 12:48
  • Anyway, you're not going to find anything simple or small. But you can probably do better than the IE-based WebControl. Commented Oct 6, 2010 at 12:52

3 Answers 3

2

You can try Awesomium

using System;
using AwesomiumSharp;
using System.Threading;
using System.Diagnostics;

namespace AwesomiumSharpBasic
{
    class Program
    {
        static void Main( string[] args )
        {
            // Display some informative message. Loading the page
            // may  take a while depending on your internet
            // connection speed.
            Console.WriteLine( "Getting a 1024x768 snapshot" +
                "of http://www.awesomium.com ..." );

            // Create a WebView.
            // WebView implements IDisposable. You can dispose and
            // destroy the view by calling WebView.Close().
            // Here we demonstrate wrapping it in a using statement.
            using ( WebView webView =
                    WebCore.CreateWebView( 1024, 768 ) )
            {
                // Variable used to announce
                // that the page has loaded.
                bool finishedLoading = false;

                // Load a page in the view.
                webView.LoadURL( "http://www.awesomium.com" );
                // Handle the LoadCompleted event to monitor
                // page loading.
                webView.LoadCompleted += ( sender, e ) =>
                {
                    finishedLoading = true;
                };

                // Wait for the page to load.
                while ( !finishedLoading )
                {
                    Thread.Sleep( 100 );
                    // WebCore provides an Auto-Update feature
                    // for UI applications. A console application
                    // has no UI and no synchronization context
                    // so we need to manually call Update here.
                    WebCore.Update();

                }
                // Render to a pixel buffer and save the buffer
                // to a .png image.
                webView.Render().SaveToPNG( "result.png", true );
            }

            // Start the application associated with .png files
            // and display the file.
            Process.Start( "result.png" );

            // Shut down Awesomium before exiting.
            WebCore.Shutdown();
        }
    }
}
Sign up to request clarification or add additional context in comments.

1 Comment

current Awesomium version have a different syntax.
1

Try WebKit .Net.

1 Comment

I believe you are pointing towards WebKitBrowser control. It looks similar to Webbrowser control with event. I was looking for something like object.GetImage(HTML). Let me know if you are talking about some other control.
0

I finally settled on WebBrowser control due to not so valid HTML available at my end.

I should mention following post which should solve problem for other guys who got valid HTML. It mentions few open source and paid controls.

http://www.codinghorror.com/blog/2004/10/managed-html-rendering.html

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.