The PDF file converted from iTextSharp with Chinese characters is garbled,

Source: Internet
Author: User

The PDF file converted from iTextSharp with Chinese characters is garbled,

Just now, I wrote a small exercise "Saving Html code as a PDF file" http://www.cnblogs.com/insus/p/4323224.html. Some netizens immediately said that when the intercepted block contains Chinese characters, the saved PDF file will be garbled. Remember the previous article "Upload Text Document and convert to PDF" http://www.cnblogs.com/insus/p/4313092.html #2 floor netizens also feedback the same problem.

 
Insus. NET decided to test and solve this problem. First, let's take a look at the test html, Which is garbled or not displayed.

 
Open the controller and create two operations, mark A and mark B:



Create a view in the order marked below.


To solve the character problem, we need to create a directory under the project. For example, Fonts is used to store Fonts. In the windows directorySIMSUN. TTCCopy the font.



Go back to the Controller, expand the TestChineseCharacter () Action, and write the handler:


Demo:


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.