• java利用iTextWorker生成pdf



     使用itext生成pdf,在linux环境下,中文全部失踪,因为itext要在linux下支持中文字体需要引入itext-asian, 并添加一个字体类。

     public static class PdfFont extends XMLWorkerFontProvider{
            public PdfFont(){
                super(null,null);
            }
            @Override
            public Font getFont(final String fontname, String encoding, float size, final int style) {
    
                Font FontChinese = null;
                try {
                    BaseFont bfChinese = BaseFont.createFont("STSong-Light",
                            "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
                    FontChinese = new Font(bfChinese, 12, Font.NORMAL);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if(FontChinese==null)
                    FontChinese = super.getFont(fontname, encoding, size, style);
                return FontChinese;
            }}
  • 相关阅读:
    自定义checkbox样式
    自定义select样式
    jsonp
    I/O复用 poll简介
    DOS和DDOS攻击
    TCP状态转换图解析
    Makefile入门
    I/O复用select 使用简介
    替换文本内容
    share memory
  • 原文地址:https://www.cnblogs.com/zhengshiqiang47/p/7684734.html
Copyright © 2020-2023  润新知