Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6981507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:09:58+00:00 2026-05-27T18:09:58+00:00

is there a way to render ViewResult or PartialViewResult as an image? I have

  • 0

is there a way to render ViewResult or PartialViewResult as an image?

I have tried to get ViewResult as string and I got a string containing html as it should be, but I need to render that html to image. If it is possible – with styles and images.

I have an idea to get some browser output for this html on server and capture result to an image, but how it can be done in practice I don’t know at this time.
If you have any ideas, please, help.

Please do not suggest any third party components. Just tell if it is impossible to do by standart .NET classes.

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T18:09:59+00:00Added an answer on May 27, 2026 at 6:09 pm

    See How to render an image using the WebBrowser control

    public class HtmlToBitmapConverter 
    { 
        private const int SleepTimeMiliseconds = 5000; 
    
        public Bitmap Render(string html, Size size) 
        { 
            var browser = CreateBrowser(size); 
    
            browser.Navigate("about:blank"); 
            browser.Document.Write(html); 
    
            return GetBitmapFromControl(browser, size); 
        } 
    
        public Bitmap Render(Uri uri, Size size) 
        { 
            var browser = CreateBrowser(size); 
    
            NavigateAndWaitForLoad(browser, uri, 0); 
    
            return GetBitmapFromControl(browser, size); 
        } 
    
        public void NavigateAndWaitForLoad(WebBrowser browser, Uri uri, int waitTime) 
        { 
            browser.Navigate(uri); 
            var count = 0; 
    
            while (browser.ReadyState != WebBrowserReadyState.Complete) 
            { 
                Thread.Sleep(SleepTimeMiliseconds); 
    
                Application.DoEvents(); 
                count++; 
    
                if (count > waitTime / SleepTimeMiliseconds) 
                { 
                    break; 
                } 
            } 
        } 
    
        private WebBrowser CreateBrowser(Size size) 
        { 
            return 
                new WebBrowser 
                { 
                    ScrollBarsEnabled = false, 
                    ScriptErrorsSuppressed = true, 
                    Size = size 
                }; 
        } 
    
        private Bitmap GetBitmapFromControl(WebBrowser browser, Size size) 
        { 
            var bitmap = new Bitmap(size.Width, size.Height); 
    
            NativeMethods.GetImage(browser.Document.DomDocument, bitmap, Color.White); 
            return bitmap; 
        } 
    }
    

    Then it’s as easy as

    var image = new HtmlToBitmapConverter()
                    .Render(new Uri(urlTextBox.Text), pictureBox.Size);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There has GOT to be a simple way to programmatically render HTML into a
Is there any way to render a default image in an HTML <img> tag,
Is there a way to render a html page without having a view model
Is there a way to render HTML pages within flash?
Writing @Url.Content(~/Something/Something.html) in razor renders /AppFolder/Something/Something.html Is there a way to render the full
Is there a way to render a html.erb partial as a one line of
is there a way to render a string resource (from strings.xml ) in an
Is there an easy way to render an SVG-image resulting in an image-object or
Is there another way to render graphics in C# beyond GDI+ and XNA ?
Is there any way to render a Silverlight text to a path or graphics

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.