贾斯珀向pdf显示中文单词

时间:2016-04-13 04:11:01

标签: jsp fonts jasper-reports

如何使用jsp将中文单词显示为pdf?

当我使用Jasper Studio查看pdf

中文单词没问题

但是当我使用JSP来显示pdf时

我收到错误消息

Font "kaiu" is not available to the JVM. See the Javadoc for more details.

如何解决?

1 个答案:

答案 0 :(得分:1)

您可以使用iReport创建一个Font扩展jar并将其导出并将其添加到类路径中,一切都应该没问题。有关示例,请参阅此博客文章:http://mdahlman.wordpress.com/2010/05/28/jaspersoft-v3-7-font-extensions/

第二个选项是报告相关文件夹和创建样式标记中的复制字体,然后将样式映射到组件。

public class Adapter extends ArrayAdapter {

Model[] modelItems = null;
Context context;

public Adapter(Context context, Model[] resource) {
    super(context, R.layout.row, resource);
    this.context = context;
    this.modelItems = resource;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
        LayoutInflater inflater = ((Activity) context).getLayoutInflater();
        if (convertView == null) {
            holder = new ViewHolder();

            convertView = vi.inflate(R.layout.list_layout, null);

            // Find the child views.
            holder.assignment= (TextView) convertView.findViewById(R.id.txt_name);
            holder.dueDate= (Button) convertView.findViewById(R.id.btn_invite);
            holder.cb= (Button) convertView.findViewById(R.id.btn_track);
            convertView.setTag(holder);

//....

        }
        // Reuse existing row view
        else {
            holder = (ViewHolder)convertView.getTag();

        }

        return convertView;
    }
 class ViewHolder {

        TextView assignment;
TextView dueDate;
CheckBox cb;

    }
}

PdfEncoding是必需属性。

<style name="yourHeader" fontName="Verdana" fontSize="9" isBold="true" pdfFontName="reports/fonts/fontname.ttf" pdfEncoding="Cp1252" isPdfEmbedded="true"/>

字体在您的计算机上可用,但它们未注册为字体扩展名,请参阅以下链接

http://www.cnblogs.com/keyliu/archive/2012/07/19/2600037.html