利用Itext生成PDF实例详解编程语言
2023-06-13 09:20:30 时间
public class zhaoPinTest {
public static void main(String[] args) throws DocumentException,
IOException {
// 标题字体
BaseFont title1 = BaseFont.createFont("c://windows//fonts//simhei.ttf",
BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
Font titleFont = new Font(title1, 25, Font.NORMAL);
// 设置字体
Font mainFont = new Font(title1, 10, Font.NORMAL);
float f = 0.5f;
Document doc = null;
float lineHeight = 18f;
PdfPCell[][] cell = new PdfPCell[100][100];
int colNum = 1;
int rowNum = 1;
try {
doc = new Document();
PdfWriter.getInstance(doc, new FileOutputStream("test1.pdf"));
doc.open();
Paragraph p1 = new Paragraph("招聘员工登记表/n/n", titleFont);
p1.setAlignment(1);
doc.add(p1);
/**
* 插入表格
/**
* 第一行
PdfPTable table = new PdfPTable(7);
PdfPCell cell1 = new PdfPCell(new Phrase("姓名", mainFont));
cell1.setUseBorderPadding(true);
cell1.setBorderWidth(f);
cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
cell1.setVerticalAlignment(Element.ALIGN_MIDDLE);
cell1.setFixedHeight(lineHeight);
table.addCell(cell1);
PdfPCell cell2 = new PdfPCell(new Phrase(""));
cell2.setUseBorderPadding(true);
cell2.setBorderWidth(f);
cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
cell2.setVerticalAlignment(Element.ALIGN_MIDDLE);
cell2.setFixedHeight(lineHeight);
table.addCell(cell2);
PdfPCell cell3 = new PdfPCell(new Phrase("性别", mainFont));
cell3.setUseBorderPadding(true);
cell3.setBorderWidth(f);
cell3.setHorizontalAlignment(Element.ALIGN_CENTER);
cell3.setVerticalAlignment(Element.ALIGN_MIDDLE);
cell3.setFixedHeight(lineHeight);
table.addCell(cell3);
PdfPCell cell4 = new PdfPCell(new Phrase(""));
cell4.setUseBorderPadding(true);
cell4.setBorderWidth(f);
cell4.setHorizontalAlignment(Element.ALIGN_CENTER);
cell4.setVerticalAlignment(Element.ALIGN_MIDDLE);
cell4.setFixedHeight(lineHeight);
table.addCell(cell4);
PdfPCell cell5 = new PdfPCell(new Phrase("出生年月", mainFont));
cell5.setUseBorderPadding(true);
cell5.setBorderWidth(f);
cell5.setHorizontalAlignment(Element.ALIGN_CENTER);
cell5.setVerticalAlignment(Element.ALIGN_MIDDLE);
cell5.setFixedHeight(lineHeight);
table.addCell(cell5);
PdfPCell cell6 = new PdfPCell(new Phrase(""));
cell6.setUseBorderPadding(true);
cell6.setBorderWidth(f);
cell6.setHorizontalAlignment(Element.ALIGN_CENTER);
cell6.setVerticalAlignment(Element.ALIGN_MIDDLE);
table.addCell(cell6);
PdfPCell cell7 = new PdfPCell(new Phrase("照片", mainFont));
cell7.setUseBorderPadding(true);
cell7.setBorderWidth(f);
cell7.setHorizontalAlignment(Element.ALIGN_CENTER);
cell7.setVerticalAlignment(Element.ALIGN_MIDDLE);
cell7.setRowspan(4);
table.addCell(cell7);
/**
* 第二行
PdfPCell cell2_1 = new PdfPCell(new Phrase("学历", mainFont));
cell2_1.setUseBorderPadding(true);
cell2_1.setBorderWidth(f);
cell2_1.setHorizontalAlignment(1);
cell2_1.setHorizontalAlignment(Element.ALIGN_CENTER);
cell2_1.setVerticalAlignment(Element.ALIGN_MIDDLE);
cell2_1.setFixedHeight(lineHeight);
table.addCell(cell2_1);
PdfPCell cell2_2 = new PdfPCell(new Phrase(""));
cell2_2.setUseBorderPadding(true);
cell2_2.setBorderWidth(f);
cell2_2.setHorizontalAlignment(1);
cell2_2.setHorizontalAlignment(Element.ALIGN_CENTER);
cell2_2.setVerticalAlignment(Element.ALIGN_MIDDLE);
cell2_2.setFixedHeight(lineHeight);
table.addCell(cell2_2);
PdfPCell cell2_3 = new PdfPCell(new Phrase("婚否", mainFont));
cell2_3.setUseBorderPadding(true);
cell2_3.setBorderWidth(f);
cell2_3.setHorizontalAlignment(1);
cell2_3.setHorizontalAlignment(Element.ALIGN_CENTER);
cell2_3.setVerticalAlignment(Element.ALIGN_MIDDLE);
cell2_3.setFixedHeight(lineHeight);
table.addCell(cell2_3);
PdfPCell cell2_4 = new PdfPCell(new Phrase(""));
cell2_4.setUseBorderPadding(true);
cell2_4.setBorderWidth(f);
cell2_4.setHorizontalAlignment(1);
cell2_4.setHorizontalAlignment(Element.ALIGN_CENTER);
cell2_4.setVerticalAlignment(Element.ALIGN_MIDDLE);
cell2_4.setFixedHeight(lineHeight);
table.addCell(cell2_4);
PdfPCell cell2_5 = new PdfPCell(new Phrase("民族", mainFont));
cell2_5.setUseBorderPadding(true);
cell2_5.setBorderWidth(f);
cell2_5.setHorizontalAlignment(1);
cell2_5.setHorizontalAlignment(Element.ALIGN_CENTER);
cell2_5.setVerticalAlignment(Element.ALIGN_MIDDLE);
cell2_5.setFixedHeight(lineHeight);
table.addCell(cell2_5);
PdfPCell cell2_6 = new PdfPCell(new Phrase(""));
cell2_6.setUseBorderPadding(true);
cell2_6.setBorderWidth(f);
cell2_6.setHorizontalAlignment(Element.ALIGN_CENTER);
cell2_6.setVerticalAlignment(Element.ALIGN_MIDDLE);
cell2_6.setFixedHeight(lineHeight);
table.addCell(cell2_6);
/**
* 第三行
PdfPCell cell3_1 = new PdfPCell(new Phrase("专业", mainFont));
cell3_1.setUseBorderPadding(true);
cell3_1.setBorderWidth(f);
cell3_1.setHorizontalAlignment(Element.ALIGN_CENTER);
cell3_1.setVerticalAlignment(Element.ALIGN_MIDDLE);
cell3_1.setFixedHeight(lineHeight);
table.addCell(cell3_1);
PdfPCell cell3_2 = new PdfPCell(new Phrase(""));
cell3_2.setUseBorderPadding(true);
cell3_2.setBorderWidth(f);
cell3_2.setHorizontalAlignment(Element.ALIGN_CENTER);
cell3_2.setVerticalAlignment(Element.ALIGN_MIDDLE);
cell3_2.setFixedHeight(lineHeight);
cell3_2.setColspan(2);
table.addCell(cell3_2);
PdfPCell cell3_3 = new PdfPCell(new Phrase("别业学校", mainFont));
cell3_3.setUseBorderPadding(true);
cell3_3.setBorderWidth(f);
cell3_3.setHorizontalAlignment(Element.ALIGN_CENTER);
cell3_3.setVerticalAlignment(Element.ALIGN_MIDDLE);
cell3_3.setFixedHeight(lineHeight);
table.addCell(cell3_3);
PdfPCell cell3_4 = new PdfPCell(new Phrase(""));
cell3_4.setUseBorderPadding(true);
cell3_4.setBorderWidth(f);
cell3_4.setHorizontalAlignment(Element.ALIGN_CENTER);
cell3_4.setVerticalAlignment(Element.ALIGN_MIDDLE);
cell3_4.setFixedHeight(lineHeight);
cell3_4.setColspan(2);
table.addCell(cell3_4);
/**
* 第四行
PdfPCell cell4_1 = new PdfPCell(new Phrase("健康状况", mainFont));
cell4_1.setUseBorderPadding(true);
cell4_1.setBorderWidth(f);
cell4_1.setHorizontalAlignment(Element.ALIGN_CENTER);
cell4_1.setVerticalAlignment(Element.ALIGN_MIDDLE);
cell4_1.setFixedHeight(lineHeight);
table.addCell(cell4_1);
PdfPCell cell4_2 = new PdfPCell(new Phrase(""));
cell4_2.setUseBorderPadding(true);
cell4_2.setBorderWidth(f);
cell4_2.setHorizontalAlignment(Element.ALIGN_CENTER);
cell4_2.setVerticalAlignment(Element.ALIGN_MIDDLE);
cell4_2.setFixedHeight(lineHeight);
cell4_2.setColspan(2);
table.addCell(cell4_2);
PdfPCell cell4_3 = new PdfPCell(new Phrase("户籍所在地", mainFont));
cell4_3.setUseBorderPadding(true);
cell4_3.setBorderWidth(f);
cell4_3.setHorizontalAlignment(Element.ALIGN_CENTER);
cell4_3.setVerticalAlignment(Element.ALIGN_MIDDLE);
cell4_3.setFixedHeight(lineHeight);
table.addCell(cell4_3);
PdfPCell cell4_4 = new PdfPCell(new Phrase(""));
cell4_4.setUseBorderPadding(true);
cell4_4.setBorderWidth(f);
cell4_4.setHorizontalAlignment(Element.ALIGN_CENTER);
cell4_4.setVerticalAlignment(Element.ALIGN_MIDDLE);
cell4_4.setFixedHeight(lineHeight);
cell4_4.setColspan(2);
table.addCell(cell4_4);
/**
* 第五行
rowNum = 5;
colNum = 1;
cell[rowNum][colNum] = new PdfPCell(new Phrase("政治面貌", mainFont));
cell[rowNum][colNum].setUseBorderPadding(true);
cell[rowNum][colNum].setBorderWidth(f);
cell[rowNum][colNum].setHorizontalAlignment(Element.ALIGN_CENTER);
cell[rowNum][colNum].setVerticalAlignment(Element.ALIGN_MIDDLE);
cell[rowNum][colNum].setFixedHeight(lineHeight);
table.addCell(cell[rowNum][colNum]);
colNum = 2;
cell[rowNum][colNum] = new PdfPCell(new Phrase(""));
cell[rowNum][colNum].setUseBorderPadding(true);
cell[rowNum][colNum].setBorderWidth(f);
cell[rowNum][colNum].setHorizontalAlignment(Element.ALIGN_CENTER);
cell[rowNum][colNum].setVerticalAlignment(Element.ALIGN_MIDDLE);
cell[rowNum][colNum].setFixedHeight(lineHeight);
cell[rowNum][colNum].setColspan(2);
table.addCell(cell[rowNum][colNum]);
colNum = 3;
cell[rowNum][colNum] = new PdfPCell(new Phrase("身份证号码", mainFont));
cell[rowNum][colNum].setUseBorderPadding(true);
cell[rowNum][colNum].setBorderWidth(f);
cell[rowNum][colNum].setHorizontalAlignment(Element.ALIGN_CENTER);
cell[rowNum][colNum].setVerticalAlignment(Element.ALIGN_MIDDLE);
cell[rowNum][colNum].setFixedHeight(lineHeight);
table.addCell(cell[rowNum][colNum]);
colNum = 4;
cell[rowNum][colNum] = new PdfPCell(new Phrase(""));
cell[rowNum][colNum].setUseBorderPadding(true);
cell[rowNum][colNum].setBorderWidth(f);
cell[rowNum][colNum].setHorizontalAlignment(Element.ALIGN_CENTER);
cell[rowNum][colNum].setVerticalAlignment(Element.ALIGN_MIDDLE);
cell[rowNum][colNum].setFixedHeight(lineHeight);
cell[rowNum][colNum].setColspan(3);
table.addCell(cell[rowNum][colNum]);
/**
* 第六行
rowNum = 6;
colNum = 1;
cell[rowNum][colNum] = new PdfPCell(new Phrase("工作时间", mainFont));
cell[rowNum][colNum].setUseBorderPadding(true);
cell[rowNum][colNum].setBorderWidth(f);
cell[rowNum][colNum].setHorizontalAlignment(Element.ALIGN_CENTER);
cell[rowNum][colNum].setVerticalAlignment(Element.ALIGN_MIDDLE);
cell[rowNum][colNum].setFixedHeight(lineHeight);
table.addCell(cell[rowNum][colNum]);
colNum = 2;
cell[rowNum][colNum] = new PdfPCell(new Phrase(""));
cell[rowNum][colNum].setUseBorderPadding(true);
cell[rowNum][colNum].setBorderWidth(f);
cell[rowNum][colNum].setHorizontalAlignment(Element.ALIGN_CENTER);
cell[rowNum][colNum].setVerticalAlignment(Element.ALIGN_MIDDLE);
cell[rowNum][colNum].setFixedHeight(lineHeight);
cell[rowNum][colNum].setColspan(2);
table.addCell(cell[rowNum][colNum]);
colNum = 3;
cell[rowNum][colNum] = new PdfPCell(new Phrase("有无住房", mainFont));
cell[rowNum][colNum].setUseBorderPadding(true);
cell[rowNum][colNum].setBorderWidth(f);
cell[rowNum][colNum].setHorizontalAlignment(Element.ALIGN_CENTER);
cell[rowNum][colNum].setVerticalAlignment(Element.ALIGN_MIDDLE);
cell[rowNum][colNum].setFixedHeight(lineHeight);
table.addCell(cell[rowNum][colNum]);
colNum = 4;
cell[rowNum][colNum] = new PdfPCell(new Phrase(""));
cell[rowNum][colNum].setUseBorderPadding(true);
cell[rowNum][colNum].setBorderWidth(f);
cell[rowNum][colNum].setHorizontalAlignment(Element.ALIGN_CENTER);
cell[rowNum][colNum].setVerticalAlignment(Element.ALIGN_MIDDLE);
cell[rowNum][colNum].setFixedHeight(lineHeight);
table.addCell(cell[rowNum][colNum]);
colNum = 5;
cell[rowNum][colNum] = new PdfPCell(new Phrase("要求待遇", mainFont));
cell[rowNum][colNum].setUseBorderPadding(true);
cell[rowNum][colNum].setBorderWidth(f);
cell[rowNum][colNum].setHorizontalAlignment(Element.ALIGN_CENTER);
cell[rowNum][colNum].setVerticalAlignment(Element.ALIGN_MIDDLE);
cell[rowNum][colNum].setFixedHeight(lineHeight);
table.addCell(cell[rowNum][colNum]);
colNum = 6;
cell[rowNum][colNum] = new PdfPCell(new Phrase(""));
cell[rowNum][colNum].setUseBorderPadding(true);
cell[rowNum][colNum].setBorderWidth(f);
cell[rowNum][colNum].setHorizontalAlignment(Element.ALIGN_CENTER);
cell[rowNum][colNum].setVerticalAlignment(Element.ALIGN_MIDDLE);
cell[rowNum][colNum].setFixedHeight(lineHeight);
table.addCell(cell[rowNum][colNum]);
/**
* 第七行
rowNum = 7;
colNum = 1;
cell[rowNum][colNum] = new PdfPCell(new Phrase("联系电话", mainFont));
cell[rowNum][colNum].setUseBorderPadding(true);
cell[rowNum][colNum].setBorderWidth(f);
cell[rowNum][colNum].setHorizontalAlignment(Element.ALIGN_CENTER);
cell[rowNum][colNum].setVerticalAlignment(Element.ALIGN_MIDDLE);
cell[rowNum][colNum].setFixedHeight(lineHeight);
table.addCell(cell[rowNum][colNum]);
colNum = 2;
cell[rowNum][colNum] = new PdfPCell(new Phrase(""));
cell[rowNum][colNum].setUseBorderPadding(true);
cell[rowNum][colNum].setBorderWidth(f);
cell[rowNum][colNum].setHorizontalAlignment(Element.ALIGN_CENTER);
cell[rowNum][colNum].setVerticalAlignment(Element.ALIGN_MIDDLE);
cell[rowNum][colNum].setFixedHeight(lineHeight);
cell[rowNum][colNum].setColspan(2);
table.addCell(cell[rowNum][colNum]);
colNum = 3;
cell[rowNum][colNum] = new PdfPCell(new Phrase("电子邮件", mainFont));
cell[rowNum][colNum].setUseBorderPadding(true);
cell[rowNum][colNum].setBorderWidth(f);
cell[rowNum][colNum].setHorizontalAlignment(Element.ALIGN_CENTER);
cell[rowNum][colNum].setVerticalAlignment(Element.ALIGN_MIDDLE);
cell[rowNum][colNum].setFixedHeight(lineHeight);
table.addCell(cell[rowNum][colNum]);
colNum = 4;
cell[rowNum][colNum] = new PdfPCell(new Phrase(""));
cell[rowNum][colNum].setUseBorderPadding(true);
cell[rowNum][colNum].setBorderWidth(f);
cell[rowNum][colNum].setHorizontalAlignment(Element.ALIGN_CENTER);
cell[rowNum][colNum].setVerticalAlignment(Element.ALIGN_MIDDLE);
cell[rowNum][colNum].setFixedHeight(lineHeight);
table.addCell(cell[rowNum][colNum]);
colNum = 5;
cell[rowNum][colNum] = new PdfPCell(new Phrase("手机", mainFont));
cell[rowNum][colNum].setUseBorderPadding(true);
cell[rowNum][colNum].setBorderWidth(f);
cell[rowNum][colNum].setHorizontalAlignment(Element.ALIGN_CENTER);
cell[rowNum][colNum].setVerticalAlignment(Element.ALIGN_MIDDLE);
cell[rowNum][colNum].setFixedHeight(lineHeight);
table.addCell(cell[rowNum][colNum]);
colNum = 6;
cell[rowNum][colNum] = new PdfPCell(new Phrase(""));
cell[rowNum][colNum].setUseBorderPadding(true);
cell[rowNum][colNum].setBorderWidth(f);
cell[rowNum][colNum].setHorizontalAlignment(Element.ALIGN_CENTER);
cell[rowNum][colNum].setVerticalAlignment(Element.ALIGN_MIDDLE);
cell[rowNum][colNum].setFixedHeight(lineHeight);
table.addCell(cell[rowNum][colNum]);
/**
* 第八行
rowNum = 8;
colNum = 1;
cell[rowNum][colNum] = new PdfPCell(new Phrase("联系地址", mainFont));
cell[rowNum][colNum].setUseBorderPadding(true);
cell[rowNum][colNum].setBorderWidth(f);
cell[rowNum][colNum].setHorizontalAlignment(Element.ALIGN_CENTER);
cell[rowNum][colNum].setVerticalAlignment(Element.ALIGN_MIDDLE);
cell[rowNum][colNum].setFixedHeight(lineHeight);
table.addCell(cell[rowNum][colNum]);
colNum = 2;
cell[rowNum][colNum] = new PdfPCell(new Phrase(""));
cell[rowNum][colNum].setUseBorderPadding(true);
cell[rowNum][colNum].setBorderWidth(f);
cell[rowNum][colNum].setHorizontalAlignment(Element.ALIGN_CENTER);
cell[rowNum][colNum].setVerticalAlignment(Element.ALIGN_MIDDLE);
cell[rowNum][colNum].setFixedHeight(lineHeight);
cell[rowNum][colNum].setColspan(6);
table.addCell(cell[rowNum][colNum]);
/**
* 第九行
rowNum = 9;
colNum = 1;
cell[rowNum][colNum] = new PdfPCell(new Phrase("工作所在地", mainFont));
cell[rowNum][colNum].setUseBorderPadding(true);
cell[rowNum][colNum].setBorderWidth(f);
cell[rowNum][colNum].setHorizontalAlignment(Element.ALIGN_CENTER);
cell[rowNum][colNum].setVerticalAlignment(Element.ALIGN_MIDDLE);
cell[rowNum][colNum].setFixedHeight(lineHeight);
table.addCell(cell[rowNum][colNum]);
colNum = 2;
cell[rowNum][colNum] = new PdfPCell(new Phrase(""));
cell[rowNum][colNum].setUseBorderPadding(true);
cell[rowNum][colNum].setBorderWidth(f);
cell[rowNum][colNum].setHorizontalAlignment(Element.ALIGN_CENTER);
cell[rowNum][colNum].setVerticalAlignment(Element.ALIGN_MIDDLE);
cell[rowNum][colNum].setFixedHeight(lineHeight);
cell[rowNum][colNum].setColspan(6);
table.addCell(cell[rowNum][colNum]);
/**
* 第十行
rowNum = 10;
colNum = 1;
cell[rowNum][colNum] = new PdfPCell(new Phrase("离职原因", mainFont));
cell[rowNum][colNum].setUseBorderPadding(true);
cell[rowNum][colNum].setBorderWidth(f);
cell[rowNum][colNum].setHorizontalAlignment(Element.ALIGN_CENTER);
cell[rowNum][colNum].setVerticalAlignment(Element.ALIGN_MIDDLE);
cell[rowNum][colNum].setFixedHeight(lineHeight);
table.addCell(cell[rowNum][colNum]);
colNum = 2;
cell[rowNum][colNum] = new PdfPCell(new Phrase(""));
cell[rowNum][colNum].setUseBorderPadding(true);
cell[rowNum][colNum].setBorderWidth(f);
cell[rowNum][colNum].setHorizontalAlignment(Element.ALIGN_CENTER);
cell[rowNum][colNum].setVerticalAlignment(Element.ALIGN_MIDDLE);
cell[rowNum][colNum].setFixedHeight(lineHeight);
cell[rowNum][colNum].setColspan(6);
table.addCell(cell[rowNum][colNum]);
/**
* 第十一行
rowNum = 11;
colNum = 1;
cell[rowNum][colNum] = new PdfPCell(new Phrase("简历", mainFont));
cell[rowNum][colNum].setUseBorderPadding(true);
cell[rowNum][colNum].setBorderWidth(f);
cell[rowNum][colNum].setHorizontalAlignment(Element.ALIGN_CENTER);
cell[rowNum][colNum].setVerticalAlignment(Element.ALIGN_MIDDLE);
cell[rowNum][colNum].setFixedHeight(lineHeight);
table.addCell(cell[rowNum][colNum]);
colNum = 2;
cell[rowNum][colNum] = new PdfPCell(new Phrase(""));
cell[rowNum][colNum].setUseBorderPadding(true);
cell[rowNum][colNum].setBorderWidth(f);
cell[rowNum][colNum].setHorizontalAlignment(Element.ALIGN_CENTER);
cell[rowNum][colNum].setVerticalAlignment(Element.ALIGN_MIDDLE);
cell[rowNum][colNum].setFixedHeight(lineHeight);
cell[rowNum][colNum].setColspan(6);
table.addCell(cell[rowNum][colNum]);
/**
* 插入表格2
/**
* 第一行
float[] aa = new float[] { 0.06f, 0.31f, 0.31f, 0.32f };
PdfPTable table2 = new PdfPTable(4);
table2.setWidths(aa);
rowNum = 1;
colNum = 1;
cell[rowNum][colNum] = new PdfPCell(new Phrase("简历", mainFont));
cell[rowNum][colNum].setUseBorderPadding(true);
cell[rowNum][colNum].setBorderWidth(f);
cell[rowNum][colNum].setHorizontalAlignment(Element.ALIGN_CENTER);
cell[rowNum][colNum].setVerticalAlignment(Element.ALIGN_MIDDLE);
cell[rowNum][colNum].setFixedHeight(lineHeight);
cell[rowNum][colNum].setRowspan(8);
table2.addCell(cell[rowNum][colNum]);
colNum = 2;
cell[rowNum][colNum] = new PdfPCell(new Phrase("起止时间", mainFont));
cell[rowNum][colNum].setUseBorderPadding(true);
cell[rowNum][colNum].setBorderWidth(f);
cell[rowNum][colNum].setHorizontalAlignment(Element.ALIGN_CENTER);
cell[rowNum][colNum].setVerticalAlignment(Element.ALIGN_MIDDLE);
cell[rowNum][colNum].setFixedHeight(lineHeight);
table2.addCell(cell[rowNum][colNum]);
colNum = 3;
cell[rowNum][colNum] = new PdfPCell(new Phrase("学习/工作单位", mainFont));
cell[rowNum][colNum].setUseBorderPadding(true);
cell[rowNum][colNum].setBorderWidth(f);
cell[rowNum][colNum].setHorizontalAlignment(Element.ALIGN_CENTER);
cell[rowNum][colNum].setVerticalAlignment(Element.ALIGN_MIDDLE);
cell[rowNum][colNum].setFixedHeight(lineHeight);
table2.addCell(cell[rowNum][colNum]);
colNum = 4;
cell[rowNum][colNum] = new PdfPCell(new Phrase("专业/职位", mainFont));
cell[rowNum][colNum].setUseBorderPadding(true);
cell[rowNum][colNum].setBorderWidth(f);
cell[rowNum][colNum].setHorizontalAlignment(Element.ALIGN_CENTER);
cell[rowNum][colNum].setVerticalAlignment(Element.ALIGN_MIDDLE);
cell[rowNum][colNum].setFixedHeight(lineHeight);
table2.addCell(cell[rowNum][colNum]);
for (int i = 2; i i++) {
rowNum = 3;
colNum = 1;
cell[rowNum][colNum] = new PdfPCell(new Phrase("", mainFont));
cell[rowNum][colNum].setUseBorderPadding(true);
cell[rowNum][colNum].setBorderWidth(f);
cell[rowNum][colNum]
.setHorizontalAlignment(Element.ALIGN_CENTER);
cell[rowNum][colNum].setVerticalAlignment(Element.ALIGN_MIDDLE);
cell[rowNum][colNum].setFixedHeight(lineHeight);
table2.addCell(cell[rowNum][colNum]);
colNum = 2;
cell[rowNum][colNum] = new PdfPCell(new Phrase("", mainFont));
cell[rowNum][colNum].setUseBorderPadding(true);
cell[rowNum][colNum].setBorderWidth(f);
cell[rowNum][colNum]
.setHorizontalAlignment(Element.ALIGN_CENTER);
cell[rowNum][colNum].setVerticalAlignment(Element.ALIGN_MIDDLE);
cell[rowNum][colNum].setFixedHeight(lineHeight);
table2.addCell(cell[rowNum][colNum]);
colNum = 3;
cell[rowNum][colNum] = new PdfPCell(new Phrase("", mainFont));
cell[rowNum][colNum].setUseBorderPadding(true);
cell[rowNum][colNum].setBorderWidth(f);
cell[rowNum][colNum]
.setHorizontalAlignment(Element.ALIGN_CENTER);
cell[rowNum][colNum].setVerticalAlignment(Element.ALIGN_MIDDLE);
cell[rowNum][colNum].setFixedHeight(lineHeight);
table2.addCell(cell[rowNum][colNum]);
/**
* 插入表格3
/**
* 第一行
float[] aaa = new float[] { 0.06f, 0.31f, 0.1f, 0.1f, 0.1f, 0.33f };
PdfPTable table3 = new PdfPTable(6);
table3.setWidths(aaa);
rowNum = 1;
colNum = 1;
cell[rowNum][colNum] = new PdfPCell(new Phrase("家庭情况", mainFont));
cell[rowNum][colNum].setUseBorderPadding(true);
cell[rowNum][colNum].setBorderWidth(f);
cell[rowNum][colNum].setHorizontalAlignment(Element.ALIGN_CENTER);
cell[rowNum][colNum].setVerticalAlignment(Element.ALIGN_MIDDLE);
cell[rowNum][colNum].setFixedHeight(lineHeight);
cell[rowNum][colNum].setRowspan(6);
table3.addCell(cell[rowNum][colNum]);
colNum = 2;
cell[rowNum][colNum] = new PdfPCell(new Phrase("姓名", mainFont));
cell[rowNum][colNum].setUseBorderPadding(true);
cell[rowNum][colNum].setBorderWidth(f);
cell[rowNum][colNum].setHorizontalAlignment(Element.ALIGN_CENTER);
cell[rowNum][colNum].setVerticalAlignment(Element.ALIGN_MIDDLE);
cell[rowNum][colNum].setFixedHeight(lineHeight);
table3.addCell(cell[rowNum][colNum]);
colNum = 3;
cell[rowNum][colNum] = new PdfPCell(new Phrase("关系", mainFont));
cell[rowNum][colNum].setUseBorderPadding(true);
cell[rowNum][colNum].setBorderWidth(f);
cell[rowNum][colNum].setHorizontalAlignment(Element.ALIGN_CENTER);
cell[rowNum][colNum].setVerticalAlignment(Element.ALIGN_MIDDLE);
cell[rowNum][colNum].setFixedHeight(lineHeight);
table3.addCell(cell[rowNum][colNum]);
colNum = 4;
cell[rowNum][colNum] = new PdfPCell(new Phrase("年龄", mainFont));
cell[rowNum][colNum].setUseBorderPadding(true);
cell[rowNum][colNum].setBorderWidth(f);
cell[rowNum][colNum].setHorizontalAlignment(Element.ALIGN_CENTER);
cell[rowNum][colNum].setVerticalAlignment(Element.ALIGN_MIDDLE);
cell[rowNum][colNum].setFixedHeight(lineHeight);
table3.addCell(cell[rowNum][colNum]);
colNum = 5;
cell[rowNum][colNum] = new PdfPCell(new Phrase("文化程度", mainFont));
cell[rowNum][colNum].setUseBorderPadding(true);
cell[rowNum][colNum].setBorderWidth(f);
cell[rowNum][colNum].setHorizontalAlignment(Element.ALIGN_CENTER);
cell[rowNum][colNum].setVerticalAlignment(Element.ALIGN_MIDDLE);
cell[rowNum][colNum].setFixedHeight(lineHeight);
table3.addCell(cell[rowNum][colNum]);
colNum = 6;
cell[rowNum][colNum] = new PdfPCell(new Phrase("现工作单位", mainFont));
cell[rowNum][colNum].setUseBorderPadding(true);
cell[rowNum][colNum].setBorderWidth(f);
cell[rowNum][colNum].setHorizontalAlignment(Element.ALIGN_CENTER);
cell[rowNum][colNum].setVerticalAlignment(Element.ALIGN_MIDDLE);
cell[rowNum][colNum].setFixedHeight(lineHeight);
table3.addCell(cell[rowNum][colNum]);
for (int i = 2; i i++) {
rowNum = i;
colNum = 1;
cell[rowNum][colNum] = new PdfPCell(new Phrase("", mainFont));
cell[rowNum][colNum].setUseBorderPadding(true);
cell[rowNum][colNum].setBorderWidth(f);
cell[rowNum][colNum]
.setHorizontalAlignment(Element.ALIGN_CENTER);
cell[rowNum][colNum].setVerticalAlignment(Element.ALIGN_MIDDLE);
cell[rowNum][colNum].setFixedHeight(lineHeight);
table3.addCell(cell[rowNum][colNum]);
colNum = 2;
cell[rowNum][colNum] = new PdfPCell(new Phrase("", mainFont));
cell[rowNum][colNum].setUseBorderPadding(true);
cell[rowNum][colNum].setBorderWidth(f);
cell[rowNum][colNum]
.setHorizontalAlignment(Element.ALIGN_CENTER);
cell[rowNum][colNum].setVerticalAlignment(Element.ALIGN_MIDDLE);
cell[rowNum][colNum].setFixedHeight(lineHeight);
table3.addCell(cell[rowNum][colNum]);
colNum = 3;
cell[rowNum][colNum] = new PdfPCell(new Phrase("", mainFont));
cell[rowNum][colNum].setUseBorderPadding(true);
cell[rowNum][colNum].setBorderWidth(f);
cell[rowNum][colNum]
.setHorizontalAlignment(Element.ALIGN_CENTER);
cell[rowNum][colNum].setVerticalAlignment(Element.ALIGN_MIDDLE);
cell[rowNum][colNum].setFixedHeight(lineHeight);
table3.addCell(cell[rowNum][colNum]);
colNum = 4;
cell[rowNum][colNum] = new PdfPCell(new Phrase("", mainFont));
cell[rowNum][colNum].setUseBorderPadding(true);
cell[rowNum][colNum].setBorderWidth(f);
cell[rowNum][colNum]
.setHorizontalAlignment(Element.ALIGN_CENTER);
cell[rowNum][colNum].setVerticalAlignment(Element.ALIGN_MIDDLE);
cell[rowNum][colNum].setFixedHeight(lineHeight);
table3.addCell(cell[rowNum][colNum]);
colNum = 5;
cell[rowNum][colNum] = new PdfPCell(new Phrase("", mainFont));
cell[rowNum][colNum].setUseBorderPadding(true);
cell[rowNum][colNum].setBorderWidth(f);
cell[rowNum][colNum]
.setHorizontalAlignment(Element.ALIGN_CENTER);
cell[rowNum][colNum].setVerticalAlignment(Element.ALIGN_MIDDLE);
cell[rowNum][colNum].setFixedHeight(lineHeight);
table3.addCell(cell[rowNum][colNum]);
/**
* 插入表格4
/**
* 第一行
float[] aaaa = new float[] { 0.06f, 0.94f };
PdfPTable table4 = new PdfPTable(2);
table4.setWidths(aaaa);
rowNum = 1;
colNum = 1;
cell[rowNum][colNum] = new PdfPCell(new Phrase("特别提示", mainFont));
cell[rowNum][colNum].setUseBorderPadding(true);
cell[rowNum][colNum].setBorderWidth(f);
cell[rowNum][colNum].setHorizontalAlignment(Element.ALIGN_CENTER);
cell[rowNum][colNum].setVerticalAlignment(Element.ALIGN_MIDDLE);
cell[rowNum][colNum].setFixedHeight(50f);
table4.addCell(cell[rowNum][colNum]);
colNum = 2;
cell[rowNum][colNum] = new PdfPCell(
new Phrase(
" 1. 本人承诺保证所填写资料真实。/n 2. 保证遵守公司招聘有关规程和国家有关法规/n 3. 请填写好招聘登记表,带齐照片、学历、职称证书的有效证件及相关复印件。",
mainFont));
cell[rowNum][colNum].setUseBorderPadding(true);
cell[rowNum][colNum].setBorderWidth(f);
cell[rowNum][colNum].setHorizontalAlignment(Element.ALIGN_LEFT);
cell[rowNum][colNum].setVerticalAlignment(Element.ALIGN_MIDDLE);
cell[rowNum][colNum].setFixedHeight(100f);
table4.addCell(cell[rowNum][colNum]);
doc.add(table);
doc.add(table2);
doc.add(table3);
doc.add(table4);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
doc.close();
}
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/11018.html
cjavawindows相关文章
- java导出pdf模板_java模板导出PDF[通俗易懂]
- wxpython 教程 pdf_活学活用wxPython 完整版PDF
- java二维数组三种初始化方法(实例)[通俗易懂]
- shell中的while循环实例[通俗易懂]
- FFmpeg常用命令,php实例/golang实例【ffmpeg】
- VB读取线程、句柄及写入内存的API代码实例分享
- 【源码】PDF.js批注注释插件库(纯JS). 创建和保存PDF批注(PDF 高亮/签名/插图/截屏/文本框/画笔/多边形)-pdf.js
- SQL开发知识:Oracle merge语法合并更新函数实例
- JBPM工作流(八)——流程实例(PI)Process Instance详解编程语言
- Java经典实例:在文本中匹配换行符详解编程语言
- MySQL学习指南:一步一步掌握PDF格式教程(mysql学习pdf)
- Linux程序设计:第四版PDF版全文发布(linux程序设计第4版pdf)
- 从零开始:使用PHP MySQL创建Web应用程序(phpmysql实例)
- Linux源码精要:PDF详解(linux源码pdf)
- Linux编程之道:深入解析PDF(linux编程pdf)
- 在Linux中轻松打开PDF文件(linux打开pdf)
- Oracle入门:从零开始学习PDF版(oracle入门到精通pdf)
- Linux系统运维PDF全面深入的介绍了Linux系统的各种运维技巧!(linux系统运维pdf)
- Linux多线程PDF:深入了解多任务处理的利器(linux多线程pdf)
- 如何在Oracle中删除实例(oracle实例删除)
- asp.netcookie的读写实例
- asp.net中gridview的查询、分页、编辑更新、删除的实例代码
- JS动态添加option和删除option(附实例代码)
- .NET+JS对用户输入内容进行字数提示功能的实例代码
- C#Js时间格式化问题简单实例