public HttpResponseMessage GenerateImage([FromBody] Dictionary <string, string> data) { var content = data["Content"]; int width; if (!int.TryParse(data["Width"], out width)) { width = 1920; } ; var image = HtmlToImage.GenerateImage(UnicodeEncode(content), "png", width); var result = new HttpResponseMessage(HttpStatusCode.OK) { Content = new ByteArrayContent(image) }; result.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment") { FileName = "image.png" }; result.Content.Headers.ContentType = new MediaTypeHeaderValue("image/png"); return(result); }