java导出pdf文件

项目中导出pdf文件,需要3个jar包iText-2.1.7.jar,iTextAsian.jar,ReportExprotPlug0.1.jar。

        ReportInfo info = new ReportInfo(ReportType.PDF,"pdf.pdf");//文件格式和文件名
        VelocityContext vc=new VelocityContext();//velocity模版
        vc.put("clientapply", clientapply);
        vc.put("sclist", sclist);
        vc.put("oplist", oplist);
        Configuration conf=new Configuration();//读配置文件工具类
        conf.addResources("config.xml", "xml");
        ReportTemplate tpl = new ReportTemplate("/clientapply/clientapplypdf.shtml",vc);
        Export exprot = new HttpExport(data.getResponse());
        //设置模板路径  如果不设置则模式在 当前程序根目录 /template/目录下面

        //D:/home/java/Operation/template
        exprot.setResloaderpath(conf.getString("app.template.path", ""));
        exprot.exportTo(info, tpl);

为了导出pdf文件格式好看,用table布局页面。

你可能感兴趣的:(java导出pdf文件)