第十三节 导出pdf

1

package com.yinghui.soft.utils;

import com.lowagie.text.*;
import com.lowagie.text.Font;
import com.lowagie.text.pdf.BaseFont;
import com.lowagie.text.pdf.PdfPCell;
import com.lowagie.text.pdf.PdfPTable;
import com.lowagie.text.pdf.PdfWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.List;

public class DownLoadPDF {

    public static void main3(String[] args) {
        String fileName = "test.pdf";
        String path = "D:\\测试附件\\zt\\";

        try {
            //创建文档,设置页面大小、左右上下边距
            Document document = new Document();

            //处理中文显示问题,使用资源字体
            BaseFont bfChinese = BaseFont.createFont("C:\\Windows\\Fonts\\simkai.ttf",BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);

            Font dateTitle = new Font(bfChinese,7,Font.NORMAL);
            Font title = new Font(bfChinese,12,Font.BOLD);//文字加粗
            Font textFont = new Font(bfChinese,7,Font.NORMAL);//文字正常

            //给出输出路径
            PdfWriter.getInstance(document, new FileOutputStream(path+fileName));

            //打开文档
            document.open();

            //标题
            PdfPTable tableTitle = new PdfPTable(3);

            PdfPTable codeTitle = new PdfPTable(1);
            //生成一个7列的表格
            PdfPTable table = new PdfPTable(7);

            //定义每个单元格的宽度
            float[] widthsHeaderTitle = {1f,1f,1f};
            float[] widthsCodeTitle = {1f};
            float[] widthsHeader = {1f,1f,1f,1f,1f,1f,2f};

            float lineHeight = (float)20.0;

            //设置表格每一格的宽度
            tableTitle.setWidths(widthsHeaderTitle);
            codeTitle.setWidths(widthsCodeTitle);
            table.setWidths(widthsHeader);

            //设置表格总体宽度
            tableTitle.setWidthPercentage(100);
            codeTitle.setWidthPercentage(100);
            table.setWidthPercentage(100);

            int colSpan = 1;

            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Date date = new Date(System.currentTimeMillis());
            //添加标题
            createTableCellLeft("导出人:行如火", textFont, tableTitle, lineHeight, colSpan);
            createTableCellCenter("确认出差记录表", title, tableTitle, lineHeight, colSpan);
            createTableCellRight(formatter.format(date), dateTitle, tableTitle, lineHeight, colSpan);

            document.add(tableTitle);
            createTableCellRight("功能码: XXXXXXXXX",textFont, codeTitle, lineHeight, colSpan);
            document.add(codeTitle);
            document.add(new Paragraph("\n"));

            String[] array = {"报表生成日期 ","状态 ", "经办人员 ", "提交时间 ","复核人员 ", "复核时间 ", "情况补充 "};
            for (String s : array) {
                createTableCell(s, textFont, table, lineHeight, colSpan);
            }
            List<Map<String, Object>> dataResult = getResult();

            for (Map<String, Object> map : dataResult) {
                String dataTime = map.get("dateTime") != null?map.get("dateTime").toString():"0";
                String status = "0";
                if (null != map.get("status")) {
                    if ("0".equals(map.get("status"))) {
                        status = "待确认";
                    }
                    if ("1".equals(map.get("status"))) {
                        status = "待复核";
                    }
                    if ("2".equals(map.get("status"))) {
                        status = "已复核";
                    }
                }
                String creator = map.get("creator") != null?map.get("creator").toString():"0";
                String createTime = map.get("createTime") != null?map.get("createTime").toString():"0";
                String updator = map.get("updator") != null?map.get("updator").toString():"0";
                String updateTime = map.get("updateTime") != null?map.get("updateTime").toString():"0";
                String description = map.get("description") != null?map.get("description").toString():"0";

                createTableCell(dataTime, textFont, table, lineHeight, colSpan);
                createTableCell(status, textFont, table, lineHeight, colSpan);
                createTableCell(creator, textFont, table, lineHeight, colSpan);
                createTableCell(createTime, textFont, table, lineHeight, colSpan);
                createTableCell(updator, textFont, table, lineHeight, colSpan);
                createTableCell(updateTime, textFont, table, lineHeight, colSpan);
                createTableCell(description, textFont, table, lineHeight, colSpan);
            }
            document.add(table);


            document.close();
        } catch (DocumentException e) {
            e.printStackTrace();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

        File file = new File(fileName);
        System.out.println(file);
    }

    public static void main(String[] args) {
        String fileName = "人员简历.pdf";
        String path = "D:/5tool/1tomact9/webapps/hangjingsoft/ryjl/";

        try {
            //创建文档,设置页面大小、左右上下边距
            Document document = new Document();

            //处理中文显示问题,使用资源字体
            BaseFont bfChinese = BaseFont.createFont("C:\\Windows\\Fonts\\simkai.ttf",BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);

            Font dateTitle = new Font(bfChinese,7,Font.NORMAL);
            Font title = new Font(bfChinese,12,Font.BOLD);//文字加粗
            Font titleFont = new Font(bfChinese,10,Font.BOLD);//文字正常
            Font textFont = new Font(bfChinese,10,Font.NORMAL);//文字正常

            //给出输出路径
            PdfWriter.getInstance(document, new FileOutputStream(path+fileName));

            //打开文档
            document.open();

            //标题
            PdfPTable tableTitle = new PdfPTable(3);

            PdfPTable codeTitle = new PdfPTable(1);
            //生成一个7列的表格
            PdfPTable table = new PdfPTable(6);

            //定义每个单元格的宽度
            float[] widthsHeaderTitle = {1f,1f,1f};
            float[] widthsCodeTitle = {1f};
            float[] widthsHeader = {1f,1f,1f,1f,1f,1f};

            float lineHeight = (float)20.0;

            //设置表格每一格的宽度
            tableTitle.setWidths(widthsHeaderTitle);
            codeTitle.setWidths(widthsCodeTitle);
            table.setWidths(widthsHeader);

            //设置表格总体宽度
            tableTitle.setWidthPercentage(100);
            codeTitle.setWidthPercentage(100);
            table.setWidthPercentage(100);

            int colSpan = 1;

            //添加标题
            createTableCellLeft("", textFont, tableTitle, lineHeight, colSpan);
            createTableCellCenter("人员简历", title, tableTitle, lineHeight, colSpan);
            createTableCellRight("", dateTitle, tableTitle, lineHeight, colSpan);

            document.add(tableTitle);
            document.add(codeTitle);
            document.add(new Paragraph("\n"));

            createTableCell("姓名 ", titleFont, table, lineHeight, colSpan);
            createTableCell("", textFont, table, lineHeight, colSpan);
            createTableCell("性别 ", titleFont, table, lineHeight, colSpan);
            createTableCell("", textFont, table, lineHeight, colSpan);
            createTableCell("年龄 ", titleFont, table, lineHeight, colSpan);
            createTableCell("", textFont, table, lineHeight, colSpan);

            createTableCell("出生年月 ", titleFont, table, lineHeight, colSpan);
            createTableCell("", textFont, table, lineHeight, colSpan);
            createTableCell("民族 ", titleFont, table, lineHeight, colSpan);
            createTableCell("", textFont, table, lineHeight, colSpan);
            createTableCell("籍贯 ", titleFont, table, lineHeight, colSpan);
            createTableCell("", textFont, table, lineHeight, colSpan);

            createTableCell("政治面貌 ", titleFont, table, lineHeight, colSpan);
            createTableCell("", textFont, table, lineHeight, colSpan);
            createTableCell("婚姻状况 ", titleFont, table, lineHeight, colSpan);
            createTableCell("", textFont, table, lineHeight, colSpan);
            createTableCell("户口性质 ", titleFont, table, lineHeight, colSpan);
            createTableCell("", textFont, table, lineHeight, colSpan);

            createTableCell("工作状态 ", titleFont, table, lineHeight, colSpan);
            createTableCell("", textFont, table, lineHeight, colSpan);
            createTableCell("现居住地址 ", titleFont, table, lineHeight, colSpan);
            createTableCell("", textFont, table, lineHeight, 3);


            createTableCell("所属工种 ", titleFont, table, lineHeight, colSpan);
            createTableCell("", textFont, table, lineHeight, colSpan);
            createTableCell("是否是应届毕业生 ", titleFont, table, lineHeight, colSpan);
            createTableCell("", textFont, table, lineHeight, colSpan);
            createTableCell("学历 ", titleFont, table, lineHeight, colSpan);
            createTableCell("", textFont, table, lineHeight, colSpan);

            createTableCell("专业 ", titleFont, table, lineHeight, colSpan);
            createTableCell("", textFont, table, lineHeight, 2);
            createTableCell("毕业院校 ", titleFont, table, lineHeight, colSpan);
            createTableCell("", textFont, table, lineHeight, 2);

            createTableCell("毕业时间 ", titleFont, table, lineHeight, colSpan);
            createTableCell("", textFont, table, lineHeight, 2);
            createTableCell("护照号码 ", titleFont, table, lineHeight, colSpan);
            createTableCell("", textFont, table, lineHeight, 2);

            createTableCell("手机号 ", titleFont, table, lineHeight, colSpan);
            createTableCell("", textFont, table, lineHeight, 2);
            createTableCell("邮箱 ", titleFont, table, lineHeight, colSpan);
            createTableCell("", textFont, table, lineHeight, 2);

            createTableCell("劳务模式 ", titleFont, table, lineHeight, colSpan);
            createTableCell("", textFont, table, lineHeight, 2);
            createTableCell("期望薪资 ", titleFont, table, lineHeight, colSpan);
            createTableCell("", textFont, table, lineHeight, 2);

            createTableCell("所属外包单位 ", titleFont, table, lineHeight, colSpan);
            createTableCell("", textFont, table, lineHeight, 5);

            createTableCell("紧急联系人1 ", titleFont, table, lineHeight, colSpan);
            createTableCell("", textFont, table, lineHeight, colSpan);
            createTableCell("紧急联系人电话1 ", titleFont, table, lineHeight, colSpan);
            createTableCell("", textFont, table, lineHeight, colSpan);
            createTableCell("与乙方关系1 ", titleFont, table, lineHeight, colSpan);
            createTableCell("", textFont, table, lineHeight, colSpan);

            createTableCell("紧急联系人2 ", titleFont, table, lineHeight, colSpan);
            createTableCell("", textFont, table, lineHeight, colSpan);
            createTableCell("紧急联系人电话2 ", titleFont, table, lineHeight, colSpan);
            createTableCell("", textFont, table, lineHeight, colSpan);
            createTableCell("与乙方关系2 ", titleFont, table, lineHeight, colSpan);
            createTableCell("", textFont, table, lineHeight, colSpan);

            createTableCell("工作单位1 ", titleFont, table, lineHeight, colSpan);
            createTableCell("", textFont, table, lineHeight, 5);
            createTableCell("时间段1 ", titleFont, table, lineHeight, colSpan);
            createTableCell("", textFont, table, lineHeight, 2);
            createTableCell("工作岗位1 ", titleFont, table, lineHeight, colSpan);
            createTableCell("", textFont, table, lineHeight, 2);
            createTableCell("描述1 ", textFont, table, lineHeight, colSpan);
            createTableCell("", textFont, table, 60, 5);

            createTableCell("工作单位2 ", titleFont, table, lineHeight, colSpan);
            createTableCell("", textFont, table, lineHeight, 5);
            createTableCell("时间段2 ", titleFont, table, lineHeight, colSpan);
            createTableCell("", textFont, table, lineHeight, 2);
            createTableCell("工作岗位2 ", titleFont, table, lineHeight, colSpan);
            createTableCell("", textFont, table, lineHeight, 2);
            createTableCell("描述2 ", titleFont, table, lineHeight, colSpan);
            createTableCell("", textFont, table, 60, 5);

            createTableCell("工作单位3 ", titleFont, table, lineHeight, colSpan);
            createTableCell("", textFont, table, lineHeight, 5);
            createTableCell("时间段3 ", titleFont, table, lineHeight, colSpan);
            createTableCell("", textFont, table, lineHeight, 2);
            createTableCell("工作岗位3 ", titleFont, table, lineHeight, colSpan);
            createTableCell("", textFont, table, lineHeight, 2);
            createTableCell("描述3 ", titleFont, table, lineHeight, colSpan);
            createTableCell("", textFont, table, 60, 5);

            createTableCell("工作单位4 ", titleFont, table, lineHeight, colSpan);
            createTableCell("", textFont, table, lineHeight, 5);
            createTableCell("时间段4 ", titleFont, table, lineHeight, colSpan);
            createTableCell("", textFont, table, lineHeight, 2);
            createTableCell("工作岗位4 ", titleFont, table, lineHeight, colSpan);
            createTableCell("", textFont, table, lineHeight, 2);
            createTableCell("描述4 ", titleFont, table, lineHeight, colSpan);
            createTableCell("", textFont, table, 60, 5);

            createTableCell("工作单位5 ", titleFont, table, lineHeight, colSpan);
            createTableCell("", textFont, table, lineHeight, 5);
            createTableCell("时间段5 ", titleFont, table, lineHeight, colSpan);
            createTableCell("", textFont, table, lineHeight, 2);
            createTableCell("工作岗位5 ", titleFont, table, lineHeight, colSpan);
            createTableCell("", textFont, table, lineHeight, 2);
            createTableCell("描述5 ", titleFont, table, lineHeight, colSpan);
            createTableCell("", textFont, table, 60, 5);

            createTableCell("简介 ", titleFont, table, lineHeight, colSpan);
            createTableCell("", textFont, table, 100, 5);

            document.add(table);


            document.close();
        } catch (DocumentException e) {
            e.printStackTrace();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

        File file = new File(fileName);
        System.out.println(file);
    }


    public static void createTableCell(String text, Font font, PdfPTable table, float lineHeight, int colSapn) {
        PdfPCell cell;
        cell = new PdfPCell(new Paragraph(text,font));
        //合并单元格列
        cell.setColspan(colSapn);
        //设置水平居中
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        //设置垂直居中
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell.setFixedHeight(lineHeight);
        //将单元格内容添加到表格中
        table.addCell(cell);
    }

    public static void createTableCellLeft(String text, Font font, PdfPTable table, float lineHeight ,int colSapn) {
        PdfPCell cell;
        cell = new PdfPCell(new Paragraph(text,font));
        //合并单元格列
        cell.setColspan(colSapn);
        //设置水平
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //设置垂直
        cell.setVerticalAlignment(Element.ALIGN_BOTTOM);
        cell.setFixedHeight(lineHeight);
        cell.setBorderWidthRight(0);
        cell.setBorderWidthBottom(0);
        cell.setBorderWidthLeft(0);
        cell.setBorderWidthTop(0);
        //将单元格内容添加到表格中
        table.addCell(cell);
    }

    public static void createTableCellCenter(String text, Font font, PdfPTable table, float lineHeight ,int colSapn) {
        PdfPCell cell;
        cell = new PdfPCell(new Paragraph(text,font));
        //合并单元格列
        cell.setColspan(colSapn);
        //设置水平居中
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        //设置垂直居中
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell.setFixedHeight(lineHeight);
        cell.setBorderWidthLeft(0);
        cell.setBorderWidthRight(0);
        cell.setBorderWidthBottom(0);
        cell.setBorderWidthTop(0);

        //将单元格内容添加到表格中
        table.addCell(cell);

    }

    public static void createTableCellRight(String text, Font font, PdfPTable table, float lineHeight , int colSapn) {
        PdfPCell cell;
        cell = new PdfPCell(new Paragraph(text,font));
        //合并单元格列
        cell.setColspan(colSapn);
        //设置水平
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        //设置垂直
        cell.setVerticalAlignment(Element.ALIGN_TOP);
        cell.setFixedHeight(lineHeight);
        //将单元格内容添加到表格中
        //去除边框
        cell.setBorderWidthLeft(0);
        cell.setBorderWidthBottom(0);
        cell.setBorderWidthRight(0);
        cell.setBorderWidthTop(0);
        table.addCell(cell);
    }

    public static List<Map<String, Object>> getResult() {
        List<Map<String, Object>> result = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            Map<String, Object> map = new HashMap<>();
            map.put("dateTime", "2022/10/11");
            map.put("creator", "行如火");
            map.put("createTime", "2022/10/10");
            map.put("updator", "疾如风");
            map.put("updateTime", "2022/10/11");
            if(i == 0) {
                map.put("status", "0");
                map.put("description", "测试导出PDF");
            } else if (i < 4){
                map.put("status", "1");
                map.put("description", "测试导出PDF"+i);
            } else {
                map.put("status", "2");
                map.put("description", "测试导出PDF"+i);
            }
            result.add(map);
        }
        System.out.println(result);
        return result;
    }

}

2

package com.yinghui.soft.web;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Font;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.BaseFont;
import com.lowagie.text.pdf.PdfPTable;
import com.lowagie.text.pdf.PdfWriter;
import com.yinghui.soft.model.*;
import com.yinghui.soft.service.TOutsourcingUnitService;
import com.yinghui.soft.service.TTalentPoolService;
import com.yinghui.soft.service.TTypeWorkService;
import com.yinghui.soft.utils.*;
import freemarker.template.utility.DateUtil;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.*;


/**
 *人才库管理
 */
@RequestMapping("/TTalentPoolController")
@RestController
public class TTalentPoolController extends BaseController{

    private Logger logger = LoggerFactory.getLogger(TTalentPoolController.class);

    @Autowired
    private TTalentPoolService TTalentPoolService;

    @Autowired
    private TOutsourcingUnitService TOutsourcingUnitService;

    @Autowired
    private TTypeWorkService tTypeWorkService;

    @Autowired
    private JdbcTemplate jdbcTemplate;

    @Value("${tomcatPath}")
    String tomcatPath;

    @Value("${ipPort}")
    String ipPort;

   
   

    @LogAnnotation(firstLevel = "人才库管理", secondLevel = "", noteLevel = "导出PDF")
    @RequestMapping(value = "/exportResume", method = RequestMethod.GET)
    public Map exportResume( HttpServletRequest request) {
        Map  paramMap = PJCommon.getRequestParamMap(request);

        Map map = new HashMap();

        if (!paramMap.containsKey("id")
                &&StringUtils.isEmpty(paramMap.get("id"))) {
            map.put("flag", false);
            map.put("msg", "参数为空");
            return map;
        }

        paramMap.put("id",Integer.parseInt(paramMap.get("id").toString()));
        TTalentPool obj = TTalentPoolService.getById(paramMap.get("id").toString());

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        String fileName = obj.getName()+"简历.pdf";
        String path = tomcatPath+"/hangjingsoft/ryjl/";

        try {
            //创建文档,设置页面大小、左右上下边距
            Document document = new Document();

            //处理中文显示问题,使用资源字体
            BaseFont bfChinese = BaseFont.createFont("C:\\Windows\\Fonts\\simkai.ttf",BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);

            Font dateTitle = new Font(bfChinese,7,Font.NORMAL);
            Font title = new Font(bfChinese,12,Font.BOLD);//文字加粗
            Font titleFont = new Font(bfChinese,10,Font.NORMAL);//文字正常
            Font textFont = new Font(bfChinese,10,Font.NORMAL);//文字正常

            //给出输出路径
            PdfWriter.getInstance(document, new FileOutputStream(path+fileName));

            //打开文档
            document.open();

            //标题
            PdfPTable tableTitle = new PdfPTable(3);

            PdfPTable codeTitle = new PdfPTable(1);
            //生成一个7列的表格
            PdfPTable table = new PdfPTable(6);

            //定义每个单元格的宽度
            float[] widthsHeaderTitle = {1f,1f,1f};
            float[] widthsCodeTitle = {1f};
            float[] widthsHeader = {1f,1f,1f,1f,1f,1f};

            float lineHeight = (float)20.0;

            //设置表格每一格的宽度
            tableTitle.setWidths(widthsHeaderTitle);
            codeTitle.setWidths(widthsCodeTitle);
            table.setWidths(widthsHeader);

            //设置表格总体宽度
            tableTitle.setWidthPercentage(100);
            codeTitle.setWidthPercentage(100);
            table.setWidthPercentage(100);

            int colSpan = 1;

            //添加标题

            DownLoadPDF.createTableCellLeft("", textFont, tableTitle, lineHeight, colSpan);
            DownLoadPDF.createTableCellCenter(obj.getName()+"简历", title, tableTitle, lineHeight, colSpan);
            DownLoadPDF.createTableCellRight("", dateTitle, tableTitle, lineHeight, colSpan);

            document.add(tableTitle);
            document.add(codeTitle);
            document.add(new Paragraph("\n"));

            String sex = "";
            if(obj.getGender()==1){
                sex="男";
            }else if(obj.getGender()==2){
                sex="女";
            }else{
                sex="其他";
            }
            DownLoadPDF.createTableCell("姓名 ", titleFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell(obj.getName(), textFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell("性别 ", titleFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell(sex, textFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell("年龄 ", titleFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell(obj.getAge(), textFont, table, lineHeight, colSpan);

            DownLoadPDF.createTableCell("出生年月 ", titleFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell(sdf.format(obj.getBirthday()), textFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell("民族 ", titleFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell(obj.getNation(), textFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell("籍贯 ", titleFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell(obj.getBirthplace(), textFont, table, lineHeight, colSpan);

            String maritalStatus="";
            if(null!=obj.getMaritalStatus()){
                if(obj.getMaritalStatus()==0){
                    maritalStatus="未婚";
                }else if(obj.getMaritalStatus()==1){
                    maritalStatus="已婚";
                }else if(obj.getMaritalStatus()==2){
                    maritalStatus="离异";
                }else{
                    maritalStatus="丧偶";
                }
            }
            String householdType="";
            if(null!=obj.getHouseholdType()){
                if(obj.getHouseholdType()==1){
                    householdType="城镇";
                }else if(obj.getHouseholdType()==2){
                    householdType="农村";
                }else{
                    householdType="其它";
                }
            }

            DownLoadPDF.createTableCell("政治面貌 ", titleFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell(obj.getPoliticsStatus(), textFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell("婚姻状况 ", titleFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell(maritalStatus, textFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell("户口性质 ", titleFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell(householdType, textFont, table, lineHeight, colSpan);

            String workStatus="";
            if(obj.getWorkStatus()==1){
                workStatus="合同中";
            }else if(obj.getWorkStatus()==2){
                workStatus="待岗";
            }else{
                workStatus="推荐中";
            }
            DownLoadPDF.createTableCell("工作状态 ", titleFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell(workStatus, textFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell("现居住地址 ", titleFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell(obj.getNowAddress(), textFont, table, lineHeight, 3);

            TTypeWork typeWork = tTypeWorkService.getById(obj.getBelongIndustry().toString());

            String freshGraduates="";
            if(null!=obj.getFreshGraduates() && obj.getFreshGraduates()==1){
                freshGraduates="是";
            }else if(null!=obj.getFreshGraduates() && obj.getFreshGraduates()==2){
                freshGraduates="否";
            }else{
                freshGraduates="";
            }

            String educationBackground="";
            if(null!=obj.getEducationBackground()){
                if(obj.getEducationBackground()==1){
                    educationBackground="初中";
                }else  if(obj.getEducationBackground()==2){
                    educationBackground="中专/中技";
                }else  if(obj.getEducationBackground()==3){
                    educationBackground="高中";
                }else  if(obj.getEducationBackground()==4){
                    educationBackground="大专";
                }else  if(obj.getEducationBackground()==5){
                    educationBackground="本科";
                }else  if(obj.getEducationBackground()==6){
                    educationBackground="硕士";
                }else  if(obj.getEducationBackground()==7){
                    educationBackground="博士";
                }else{
                    educationBackground="MBA/EMBA";
                }
            }

            DownLoadPDF.createTableCell("所属工种 ", titleFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell(typeWork.getName(), textFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell("是否是应届毕业生 ", titleFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell(freshGraduates, textFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell("学历 ", titleFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell(educationBackground, textFont, table, lineHeight, colSpan);

            DownLoadPDF.createTableCell("专业 ", titleFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell(obj.getMajor(), textFont, table, lineHeight, 2);
            DownLoadPDF.createTableCell("毕业院校 ", titleFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell(obj.getGraduateInstitutions(), textFont, table, lineHeight, 2);

            String graduateDate="";
            if(null!=obj.getGraduateDate()){
                graduateDate=sdf.format(obj.getGraduateDate());
            }

            DownLoadPDF.createTableCell("毕业时间 ", titleFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell(graduateDate, textFont, table, lineHeight, 2);
            DownLoadPDF.createTableCell("护照号码 ", titleFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell(obj.getPassportNumber(), textFont, table, lineHeight, 2);

            DownLoadPDF.createTableCell("手机号 ", titleFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell(obj.getPhone(), textFont, table, lineHeight, 2);
            DownLoadPDF.createTableCell("邮箱 ", titleFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell(obj.geteMail(), textFont, table, lineHeight, 2);

            String laborType="";
            if(null!=obj.getLaborType()){
                if(obj.getLaborType()==1){
                    laborType="派遣模式";
                }else{
                    laborType="中介模式";
                }
            }

            DownLoadPDF.createTableCell("劳务模式 ", titleFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell(laborType, textFont, table, lineHeight, 2);
            DownLoadPDF.createTableCell("期望薪资 ", titleFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell(obj.getSalary(), textFont, table, lineHeight, 2);

            TOutsourcingUnit outsourcingUnit = TOutsourcingUnitService.getById(obj.getOutsourcingId().toString());
            DownLoadPDF.createTableCell("所属外包单位 ", titleFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell(outsourcingUnit.getName(), textFont, table, lineHeight, 5);

            DownLoadPDF.createTableCell("紧急联系人1 ", titleFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell(obj.getEmergencyContact(), textFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell("紧急联系人电话1 ", titleFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell(obj.getContactPhone(), textFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell("与乙方关系1 ", titleFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell(obj.getRelationship(), textFont, table, lineHeight, colSpan);

            DownLoadPDF.createTableCell("紧急联系人2 ", titleFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell(obj.getEmergencyContact2(), textFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell("紧急联系人电话2 ", titleFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell(obj.getContactPhone2(), textFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell("与乙方关系2 ", titleFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell(obj.getRelationship2(), textFont, table, lineHeight, colSpan);

            DownLoadPDF.createTableCell("工作单位1 ", titleFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell(obj.getWork1(), textFont, table, lineHeight, 5);
            DownLoadPDF.createTableCell("时间段1 ", titleFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell(obj.getPeriod1(), textFont, table, lineHeight, 2);
            DownLoadPDF.createTableCell("工作岗位1 ", titleFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell(obj.getPost1(), textFont, table, lineHeight, 2);
            DownLoadPDF.createTableCell("描述1 ", titleFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell(obj.getDescribe1(), textFont, table, 60, 5);

            DownLoadPDF.createTableCell("工作单位2 ", titleFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell(obj.getWork2(), textFont, table, lineHeight, 5);
            DownLoadPDF.createTableCell("时间段2 ", titleFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell(obj.getPeriod2(), textFont, table, lineHeight, 2);
            DownLoadPDF.createTableCell("工作岗位2 ", titleFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell(obj.getPost2(), textFont, table, lineHeight, 2);
            DownLoadPDF.createTableCell("描述2 ", titleFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell(obj.getDescribe2(), textFont, table, 60, 5);

            DownLoadPDF.createTableCell("工作单位3 ", titleFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell(obj.getWork3(), textFont, table, lineHeight, 5);
            DownLoadPDF.createTableCell("时间段3 ", titleFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell(obj.getPeriod3(), textFont, table, lineHeight, 2);
            DownLoadPDF.createTableCell("工作岗位3 ", titleFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell(obj.getPost3(), textFont, table, lineHeight, 2);
            DownLoadPDF.createTableCell("描述3 ", titleFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell(obj.getDescribe3(), textFont, table, 60, 5);

            DownLoadPDF.createTableCell("工作单位4 ", titleFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell(obj.getWork4(), textFont, table, lineHeight, 5);
            DownLoadPDF.createTableCell("时间段4 ", titleFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell(obj.getPeriod4(), textFont, table, lineHeight, 2);
            DownLoadPDF.createTableCell("工作岗位4 ", titleFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell(obj.getPost4(), textFont, table, lineHeight, 2);
            DownLoadPDF.createTableCell("描述4 ", titleFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell(obj.getDescribe4(), textFont, table, 60, 5);

            DownLoadPDF.createTableCell("工作单位5 ", titleFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell(obj.getWork5(), textFont, table, lineHeight, 5);
            DownLoadPDF.createTableCell("时间段5 ", titleFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell(obj.getPeriod5(), textFont, table, lineHeight, 2);
            DownLoadPDF.createTableCell("工作岗位5 ", titleFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell(obj.getPost5(), textFont, table, lineHeight, 2);
            DownLoadPDF.createTableCell("描述5 ", titleFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell(obj.getDescribe5(), textFont, table, 60, 5);

            DownLoadPDF.createTableCell("简介 ", titleFont, table, lineHeight, colSpan);
            DownLoadPDF.createTableCell(obj.getRemark(), textFont, table, 100, 5);

            document.add(table);


            document.close();
        } catch (DocumentException e) {
            e.printStackTrace();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

        File file = new File(fileName);
        System.out.println(file);

        String url=ipPort+"/hangjingsoft/ryjl/"+fileName;

        map.put("url", url);
        map.put("flag", true);
        map.put("msg", "操作成功");
        return map;
    }

    
   
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

akglobe

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值