java导出PDF详细教程+各种踩坑

07-17 1621阅读

直接上代码了

java导出PDF详细教程+各种踩坑
(图片来源网络,侵删)

所需依赖:

    com.itextpdf
    itextpdf
    5.4.3


    com.itextpdf
    itext-asian
    5.2.0

控制层代码:

@RequestMapping("/downloadLogPDF")
public void downloadLogPDF(HttpServletRequest request, HttpServletResponse response) {
    tLogService.downloadLogPDF(request, response);
}

实现类代码:

 @Override
    public void downloadLogPDF(HttpServletRequest request, HttpServletResponse response) {
        //解析request中的请求参数
        String interfaceType = request.getParameter("interfaceType");
        String startDate = request.getParameter("startDate");
        String endDate = request.getParameter("endDate");
        List dataResult = getLogListByType(interfaceType, startDate, endDate);
        String fileName = "日志报表_" + startDate.split(" ")[0].toString() + "~" + endDate.split(" ")[0].toString() + ".pdf";
        String path = System.getProperty("user.dir") + "/downLoad/";
        //设置基础中文字体
        BaseFont bfChinese = null;
        try 
VPS购买请点击我

文章版权声明:除非注明,否则均为主机测评原创文章,转载或复制请以超链接形式并注明出处。

目录[+]