---
title: "OFBiz PDF 中文乱码问题"
author: "孔已己"
date: "2015-08-26T16:52:51Z"
tags: []
categories: ["开源软件"]
slug: "ofbiz-pdf"
draft: false
lastmod: "2015-08-26T16:55:14Z"
id: 2238197
url: "https://5ven.iteye.com/blog/2238197"
---

原因是没有字体文件的支持，这里修复的方式是把字体文件放到ofbiz中，并且在显示的时候使用这个字体。

**我使用的是宋体，Simsun，其他字体我没有测试过，不知道是否有问题**

1. 添加字体文件，放到 /framework/webapp/config/ 目录 simsun.ttc simsun.xml
2. 修改/framework/webapp/config/fop.xconf ，在&lt; fonts &gt;标签中增加   
   &lt;font metrics-url="simsun.xml" kerning="yes" embed-url="simsun.ttc"&gt;&lt;font-triplet name="Simsun" style="normal" weight="normal"/&gt; &lt;/font&gt;
3. 在使用的时候指定字体，一般在 **fo:root** 标签中，比如
   
   `<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" font-family="Simsun"">`