Tushar Parmar
Tushar Parmar

Reputation: 21

WkHtmlToPDF - How to write Korean Characters in downloaded PDF file with C#?

I am trying to generate a PDF from HTML using wkhtmltopdf. It generates a PDF but it's not not showing korean language characters. How can I print korean or any other language characters in generated PDF?

I am using Response.write(PDFDataBytes) to download the PDF File as below:

Response.Clear();
Response.Cache.SetCacheability(HttpCacheability.Private);
Response.AddHeader("Content-Disposition", "attachment; filename=test.pdf");
Response.ContentType = "application/octet-stream;charset=utf-8";    
Response.BinaryWrite(Byte_dat_to_Generate_PDF);
Response.Flush();
Response.End();

Upvotes: 1

Views: 2166

Answers (4)

Alexander Shagin
Alexander Shagin

Reputation: 505

I've resolved this issue on Ubuntu 11.10(server) by copying the /usr/share/fonts from Ubuntu 14.04 LS (desktop) and then running a command:

sudo fc-cache -f -v

Upvotes: 0

Tushar Parmar
Tushar Parmar

Reputation: 21

There was just lake of following tag in HTML page:

<meta http-equiv="content-type" content="text/html; charset=utf-8" />

now working......

Upvotes: 1

Joel Peltonen
Joel Peltonen

Reputation: 13432

One thing to notice other than making everything everywhere UTF-8 is that if you are generating the PDF in a server, the server must also have the correct fonts installed. The server renders the page using available fonts, so if it can't display Hangeul characters, it can't render the PDF correctly.

PDF doesn't use the fonts in the client like HTML does, the fonts are often embedded inside the PDF file.

I have a setup like this where everything is UTF-8 and the fonts are installed and wkhtmltopdf behaves just nicely.

Upvotes: 4

CodeCaster
CodeCaster

Reputation: 151720

By outputting the HTML with the proper encoding headers. You can also specify the --encoding command line parameter.

Upvotes: 0

Related Questions