iTextSharp使用字体设置摘录

用iTextSharp做pdf转换的时候,需要添加水印。文字水印的时候,需要设置字体,查了下文档。摘录下解决方案。

iText中输出中文,有三种方式:

1、使用iTextAsian.jar中的字体
    BaseFont.createFont("STSong-Light", "UniGB-UCS2-H",BaseFont.NOT_EMBEDDED);
2、使用Windows系统字体(TrueType)
    BaseFont.createFont("C:/WINDOWS/Fonts/SIMYOU.TTF", BaseFont.IDENTITY_H,BaseFont.NOT_EMBEDDED);    
3、使用资源字体(ClassPath)
    BaseFont.createFont("/SIMYOU.TTF", BaseFont.IDENTITY_H,BaseFont.NOT_EMBEDDED);

给个原文链接:http://hintcnuie.iteye.com/blog/183690

另外有以为仁兄给出了字体和编码对应,没有写明使用,但我猜想应该是针对第一种方案的。摘录如下,供使用者参考:

  • Chinese Simplified:
    STSong-Light and STSongStd-Light with the encodings UniGB-UCS2-H and UniGB-UCS2-V
  • Chinese Traditional:
    MHei-Medium, MSung-Light and MSungStd-Light with the encodings UniCNS-UCS2-H and UniCNS-UCS2-V
  • Japanese:
    HeiseiMin-W3, HeiseiKakuGo-W5 and KozMinPro-Regular with the encodings UniJIS-UCS2-H, UniJIS-UCS2-V, UniJIS-UCS2-HW-H and UniJIS-UCS2-HW-V
  • Korean:
    HYGoThic-Medium, HYSMyeongJo-Medium and HYSMyeongJoStd with the encodings UniKS-UCS2-H and UniKS-UCS2-V

另有一仁兄研究比较深入些,给个链接吧:http://blog.csdn.net/aeolus1019/article/details/8198900

以上完全摘录,只做记录使用,非原创。大家有用到的参考。

原文地址:https://www.cnblogs.com/LL-723/p/3488773.html