iTextSharp international text

前端 未结 4 511
一个人的身影
一个人的身影 2020-12-03 15:11

I have a table in asp.net page,and trying to export it as a PDF file,I have couple of international characters that are not shown in generated PDF file,any suggestions,

4条回答
  •  悲哀的现实
    2020-12-03 15:16

    It caused by default iTextSharp font - Helvetica - that does not support other than base characters (or not support all other characters.

    There are actually 2 options:

    1. One is to rewrite the table content by hand into the code. This approach might look faster to you, but it requires any modification to the original table to be repeated in the code as well (breaking DRY principle). In this case, you can easily set-up font as you wish.
    2. The other is to extract PDF from HTML extracted from HtmlEngine. This might sound a bit more complicated and complex (and it is), however, working solution is much more flexible and universal. I suffered the struggle with special characters myself just a while ago and decided to post a somewhat complete solution under other similar solution here on stackoverflow: https://stackoverflow.com/a/24587745/1138663

提交回复
热议问题