Html To Image Using NReco.ImageGenerator : C# -


introduction

i working functionality can convert "html" image.for image creation, use "image" function(of system.drawing).

functionality working fine(including html styles etc) except 1 thing describe later in problem.

problem

problem appears when using non-english language in html, although english works fine.obviously unicode problem, doing wrong due limited understanding.

string str ="<p> have day !!</p>"; //output : have day !! string str2 = "<p>قطعا</p>"; //output : non-sense symbols omega 

c# code

var html = string.format("<h1>فقط</h1><p>قطعا</p>");  var htmltoimageconv = new nreco.imagegenerator.htmltoimageconverter();  var jpegbytes = htmltoimageconv.generateimage(html,imageformat.png.tostring());  memorystream memstr = new memorystream(jpegbytes);  system.drawing.image img = system.drawing.image.fromstream(memstr,true,true);  img.save(server.mappath("~/app_images/my_converted11.png")); 

i been trying figure out how hold problem couldn't yet.if can regarding problem, please help.any kind of reference helpful , appreciated.thanks time.

you must set <head> <meta> tag inside html , define charset this:

string html =  @"<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8" /></head><body>hello world: 안녕하세요...</body></html>"; 

i hope you.


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -