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

推荐订阅源

美团技术团队
D
DataBreaches.Net
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
D
Docker
N
Netflix TechBlog - Medium
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
C
Check Point Blog
腾讯CDC
Stack Overflow Blog
Stack Overflow Blog
V
Visual Studio Blog
IT之家
IT之家
月光博客
月光博客
U
Unit 42
K
Kaspersky official blog
T
Threatpost
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
GbyAI
GbyAI
P
Proofpoint News Feed
Last Week in AI
Last Week in AI
云风的 BLOG
云风的 BLOG
酷 壳 – CoolShell
酷 壳 – CoolShell
I
InfoQ
Engineering at Meta
Engineering at Meta
Recorded Future
Recorded Future
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
Security @ Cisco Blogs
MyScale Blog
MyScale Blog
大猫的无限游戏
大猫的无限游戏
Security Archives - TechRepublic
Security Archives - TechRepublic
Webroot Blog
Webroot Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Hacker News - Newest:
Hacker News - Newest: "LLM"
S
Schneier on Security
S
Secure Thoughts
The Register - Security
The Register - Security
B
Blog RSS Feed
The Last Watchdog
The Last Watchdog
P
Palo Alto Networks Blog
爱范儿
爱范儿
B
Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
N
News and Events Feed by Topic
阮一峰的网络日志
阮一峰的网络日志
L
LINUX DO - 热门话题
C
Cisco Blogs
Spread Privacy
Spread Privacy
F
Full Disclosure
博客园 - 聂微东
T
The Blog of Author Tim Ferriss

博客园 - 尚書

类似于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();