惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
月光博客
月光博客
MyScale Blog
MyScale Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
爱范儿
爱范儿
P
Proofpoint News Feed
人人都是产品经理
人人都是产品经理
Last Week in AI
Last Week in AI
罗磊的独立博客
G
Google Developers Blog
Y
Y Combinator Blog
博客园 - 【当耐特】
WordPress大学
WordPress大学
大猫的无限游戏
大猫的无限游戏
博客园 - 叶小钗
J
Java Code Geeks
酷 壳 – CoolShell
酷 壳 – CoolShell
V
Visual Studio Blog
美团技术团队
宝玉的分享
宝玉的分享
Jina AI
Jina AI
小众软件
小众软件
T
Tailwind CSS Blog
A
About on SuperTechFans

博客园 - 尚書

类似于GROUP BY SUM() 用于字符串连接的语句 UBUNTU 14.04 INSTALL nsenter UBUNTU 14.04 DOCKER 1.4.1 Redis On Windows Run Redis On Windows C#.NET 加密解密:AES/DES/Base64/RSA/MD5/SHA256 Random Mongo的主从同步,以及备份与恢复 Mongodb 更多操作 Mongodb的备份/还原 mongodump/mongorestore [C#]HttpWebRequest、HttpWebRespoonse、WebRequest and WebResponse、WebClient差异 [筆記] string.Format 格式整理 微软放出五大语种Windows 8消费者预览版ISO镜像 [MVC] 获取请求时缺少"+"的处理办法 How to fix the bug that missing plus in Request.QueryString/Form [SQL SERVER] 数字补0 [SQL SERVER] 用SQL语句读取Execl数据 [SQL SERVER] 跨库查询--分布式查询 CSharpJExcel Read/Write Excel Install MongoDB as a windows service
itextsharp多语言(中日韩等)填表解决
尚書 · 2012-03-26 · via 博客园 - 尚書

这几天在做套打的方案,最终决定用PDF做。用Acrobat做PDF表单文件,再使用itextsharp填表功能完成。

但是出现多语言(中日韩)填表的情况,查了很多方法,做了不少测试,最后解决。示例代码如下:

    

var reader = new PdfReader(/*Form File*/);
    var stamper = new PdfStamper(reader, new FileStream(result, FileMode.Create));

    var query = from property in type.GetProperties()
                join field in stamper.AcroFields.Fields
                    on property.Name equals field.Key
                select new
                {
                    field.Key,
                    Value = property.GetValue(model, nullas string
                };

    BaseFont font = BaseFont.CreateFont("c:\\windows\\fonts\\ARIALUNI.TTF", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
    foreach (var item in query)
    {
        stamper.AcroFields.AddSubstitutionFont(font);
        stamper.AcroFields.SetField(item.Key, item.Value);
    }

    stamper.FormFlattening = true;

    stamper.Close();