Some days ago, Insus.net shared an article "upload text document and convert it to PDF" http://www.cnblogs.com/insus/p/4313092.html It is handled in the simplest and the default way.
It is in the processing of text files with Chinese, when converted to PDF, Chinese is not normal display, garbled.
This article is on that basis, to reconstruct, to solve the garbled problem.
To solve the character problem, we need to create a directory under the project, such as fonts, which is used to store fonts. Let's go to the Windows directory to put SimSun. TTC font copy over.
In the controller's Postfile () operation, also need to modify some code, such as the previous article is to upload the file into a temporary directory, now feel it a bit redundant, directly to read the HttpPostedFileBase InputStream can.
Demo, first folder to create a text file in Chinese:
If the program is normal, the converted PDF should be no different from the text file above:
Upload text document and convert to PDF (fix garbled)