0

I am trying to convert html string from my view to image. I am able to get my view as string but not able to convert it in image(base64string or byte array) to return it back. This is my code

/* Getting label design info */
LabelDesigner ObjModel = GetLabelDesignObject("Drug_Label");

/* Taking view's HTML */
string HTML = RenderRazorViewToString("~/Views/Folder/DrugLabel.cshtml", ObjModel);

.............
.............
.............
.............

public string RenderRazorViewToString(string ViewName, object Model)
    {
        string ReturnVal = string.Empty;

        try
        {
            ViewData.Model = Model;
            using (var sw = new System.IO.StringWriter())
            {
                var viewResult = ViewEngines.Engines.FindPartialView(ControllerContext, ViewName);
                var viewContext = new ViewContext(ControllerContext, viewResult.View, ViewData, TempData, sw);
                viewResult.View.Render(viewContext, sw);
                viewResult.ViewEngine.ReleaseView(ControllerContext, viewResult.View);
                return sw.GetStringBuilder().ToString();
            }
        }
        catch (Exception ex)
        {
            /* Catch Exception Here */
            log.Error("Error in Controller.cs, RenderRazorViewToString function: " + ex.Message);
        }

        return ReturnVal;
    }

Here I am able to get HTML of view but how to convert that HTML string to jpg image?

CodeWarrior
  • 763
  • 3
  • 14
  • 33
  • http://stackoverflow.com/search?q=render+html+to+image – bmm6o Jan 28 '15 at 17:12
  • possible duplicate of [How to render a string containing HTML into an image in C#?](http://stackoverflow.com/questions/6754697/how-to-render-a-string-containing-html-into-an-image-in-c) – bmm6o Feb 03 '15 at 22:35

0 Answers0