可实现导出复杂样式的PDF文件
pom 导入依赖
<dependency>
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
<version>2.1.7</version>
</dependency>
<dependency>
<groupId>com.lowagie</groupId>
<artifactId>itext-rtf</artifactId>
<version>2.1.7</version>
</dependency>
code
package com.ly.education.cultivationprocess.server.utils;
import com.lowagie.text.*;
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 org.apache.commons.lang.StringUtils;
import java.io.*;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
public class PdfView {
public final static int endTableMaxRowPdf = 4;
public final static int fontSize7 = 7;
public final static String path = "D:\\opt\\";
public static void main(String[] args) {
previewAction5();
}
public static synchronized void previewAction3() {
Document document = new Document(PageSize.A3.rotate(), 1, 1, 1, 1);
PdfWriter writer;
OutputStream outputStream = null;
File pdfFile = null;
String destPath = "";
try {
File rootFile = new File(path);
if (!rootFile.exists()) {
boolean isCreate = rootFile.mkdirs();
}
Long xtsjmz = System.currentTimeMillis();
String timeStr = xtsjmz.toString();
destPath = path + timeStr;
pdfFile = new File(destPath + "3.pdf");
outputStream = new FileOutputStream(pdfFile);
writer = PdfWriter.getInstance(document, outputStream);
writer.setViewerPreferences(PdfWriter.FitWindow);
document.open();
for (int i = 0; i < 2; i++) {
getPdfTable3(document);
document.newPage();
}
document.close();
writer.close();
outputStream.flush();
} catch (DocumentException | IOException ignored) {
} finally {
try {
document.close();
if (outputStream != null) {
outputStream.close();
}
} catch (IOException ignored) {
}
}
}
public static synchronized void previewAction5() {
Document document = new Document(PageSize.A3.rotate(), 2, 2, 2, 2);
PdfWriter writer;
OutputStream outputStream = null;
File pdfFile = null;
String destPath = "";
try {
File rootFile = new File(path);
if (!rootFile.exists()) {
boolean isCreate = rootFile.mkdirs();
}
Long xtsjmz = System.currentTimeMillis();
String timeStr = xtsjmz.toString();
destPath = path + timeStr;
pdfFile = new File(destPath + "5.pdf");
outputStream = new FileOutputStream(pdfFile);
writer = PdfWriter.getInstance(document, outputStream);
writer.setViewerPreferences(PdfWriter.FitWindow);
document.open();
for (int i = 0; i < 10; i++) {
getPdfTable5(document);
document.newPage();
}
document.close();
writer.close();
outputStream.flush();
} catch (Exception ignored) {
} finally {
try {
document.close();
if (outputStream != null) {
outputStream.close();
}
} catch (IOException ignored) {
}
}
}
private static void getPdfTable5(Document document) throws DocumentException {
BaseFont baseFont = baseFontKt();
com.lowagie.text.Font font8 =
new com.lowagie.text.Font(baseFont, 8, com.lowagie.text.Font.NORMAL);
com.lowagie.text.Font font10 =
new com.lowagie.text.Font(baseFont, 10, com.lowagie.text.Font.BOLD);
Paragraph blankRow = new Paragraph(12f, " ", font10);
PdfPTable headTable = new PdfPTable(2);
headTable.setWidths(new float[]{500, 100});
headTable.addCell(baseInfoTable(baseFont));
headTable.addCell(pictureTable(baseFont));
PdfPTable schoolYearTable = new PdfPTable(1);
schoolYearTable.setWidths(new float[]{500});
schoolYearTable.addCell(schoolYearTable5(baseFont));
PdfPTable courseTitleTable = new PdfPTable(1);
courseTitleTable.setWidths(new float[]{500});
courseTitleTable.addCell(courseTitleTable5(baseFont));
List<List<Row>> groupList = new LinkedList<>();
int groupListCnt = 5;
PdfPTable courseTable = new PdfPTable(groupListCnt);
courseTable.setWidths(new float[]{683, 683, 683, 683, 683});
for (int i = 0; i < groupListCnt; i++) {
courseTable.addCell(courseScoreTable(null, baseFont));
}
Map<String, String> sum5Map = new HashMap<>();
PdfPTable sumSemesterTable = new PdfPTable(1);
sumSemesterTable.setWidths(new float[]{500});
sumSemesterTable.addCell(sumSemesterTable5(sum5Map, baseFont));
PdfPTable nullTable = new PdfPTable(1);
nullTable.setWidths(new float[]{500});
nullTable.addCell(baseInfoTableSixRow(baseFont));
PdfPTable endTitleTable = new PdfPTable(1);
endTitleTable.setWidths(new float[]{500});
endTitleTable.addCell(endTitleTable(baseFont));
PdfPTable endTable = new PdfPTable(4);
endTable.setWidths(new float[]{1416, 977, 1231, 476});
Map<String, String[]> change = new HashMap<>();
endTable.addCell(changeTable(change, baseFont));
endTable.addCell(byInfoTable(baseFont));
endTable.addCell(notPassTable(getNotpassInfo(groupList), baseFont));
endTable.addCell(byxfTable(sum5Map, baseFont));
document.add(blankRow);
document.add(blankRow);
document.add(headTable);
document.add(schoolYearTable);
document.add(courseTitleTable);
document.add(courseTable);
document.add(sumSemesterTable);
document.add(nullTable);
document.add(endTitleTable);
document.add(endTable);
Phrase par =
new Phrase(" " +
"注:“_”表示该成绩由补考获得,“[]”表示该成绩由重修获得", font8);
document.add(par);
}
private static void getPdfTable3(Document document) throws DocumentException {
BaseFont baseFont = baseFontKt();
com.lowagie.text.Font font8 =
new com.lowagie.text.Font(baseFont, 8, com.lowagie.text.Font.NORMAL);
com.lowagie.text.Font font10 =
new com.lowagie.text.Font(baseFont, 10, com.lowagie.text.Font.BOLD);
Paragraph blankRow = new Paragraph(12f, " ", font10);
PdfPTable headTable = new PdfPTable(2);
headTable.setWidths(new float[]{500, 100});
headTable.addCell(baseInfoTable(baseFont));
headTable.addCell(pictureTable(baseFont));
PdfPTable schoolYearTable = new PdfPTable(1);
schoolYearTable.setWidths(new float[]{500});
schoolYearTable.addCell(schoolYearTable(baseFont));
PdfPTable semesterTable = new PdfPTable(1);
semesterTable.setWidths(new float[]{500});
semesterTable.addCell(semesterTable(baseFont));
PdfPTable courseTitleTable = new PdfPTable(1);
courseTitleTable.setWidths(new float[]{500});
courseTitleTable.addCell(courseTitleTable(baseFont));
List<List<Row>> groupList = null;
int groupListCnt = 6;
PdfPTable courseTable = new PdfPTable(groupListCnt);
courseTable.setWidths(new float[]{683, 683, 683, 683, 683, 683});
for (int i = 0; i < groupListCnt; i++) {
courseTable.addCell(courseScoreTable(null, baseFont));
}
Map<String, String> sum3Map = new HashMap<>();
sum3Map.put("第一学期", "tiger");
sum3Map.put("第二学期", "rabbit");
PdfPTable sumSemesterTable = new PdfPTable(1);
sumSemesterTable.setWidths(new float[]{500});
sumSemesterTable.addCell(sumSemesterTable(sum3Map, baseFont));
PdfPTable nullTable = new PdfPTable(1);
nullTable.setWidths(new float[]{500});
nullTable.addCell(baseInfoTableSixRow(baseFont));
PdfPTable endTitleTable = new PdfPTable(1);
endTitleTable.setWidths(new float[]{500});
endTitleTable.addCell(endTitleTable(baseFont));
PdfPTable endTable = new PdfPTable(4);
endTable.setWidths(new float[]{1416, 977, 1231, 476});
Map<String, String[]> change = new HashMap<>();
change.put("专业", new String[]{"xixi", "hehe", "haha"});
endTable.addCell(changeTable(change, baseFont));
endTable.addCell(byInfoTable(baseFont));
endTable.addCell(notPassTable(getNotpassInfo(groupList), baseFont));
endTable.addCell(byxfTable(sum3Map, baseFont));
document.add(blankRow);
document.add(blankRow);
document.add(headTable);
document.add(schoolYearTable);
document.add(semesterTable);
document.add(courseTitleTable);
document.add(courseTable);
document.add(sumSemesterTable);
document.add(nullTable);
document.add(endTitleTable);
document.add(endTable);
Phrase par =
new Phrase(" " +
"注:“_”表示该成绩由补考获得,“[]”表示该成绩由重修获得", font8);
document.add(par);
}
private static PdfPCell schoolYearTable(BaseFont baseFont) throws DocumentException {
com.lowagie.text.Font font1 =
new com.lowagie.text.Font(baseFont, 8, com.lowagie.text.Font.NORMAL);
PdfPTable table = new PdfPTable(3);
table.setWidths(new float[]{500, 500, 500});
PdfPCell one = new PdfPCell(new Phrase("第一学年 ", font1));
one.setHorizontalAlignment(Element.ALIGN_CENTER);
one.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell two = new PdfPCell(new Phrase("第二学年 ", font1));
two.setHorizontalAlignment(Element.ALIGN_CENTER);
two.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell three = new PdfPCell(new Phrase("第三学年 ", font1));
three.setHorizontalAlignment(Element.ALIGN_CENTER);
three.setVerticalAlignment(Element.ALIGN_MIDDLE);
table.addCell(one);
table.addCell(two);
table.addCell(three);
PdfPCell cell = new PdfPCell(table);
cell.setBorder(PdfPCell.NO_BORDER);
return cell;
}
private static PdfPCell schoolYearTable5(BaseFont baseFont) throws DocumentException {
com.lowagie.text.Font font1 =
new com.lowagie.text.Font(baseFont, 8, com.lowagie.text.Font.NORMAL);
PdfPTable table = new PdfPTable(5);
table.setWidths(new float[]{819, 819, 819, 819, 819});
PdfPCell one = new PdfPCell(new Phrase("第一学年 ", font1));
one.setHorizontalAlignment(Element.ALIGN_CENTER);
one.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell two = new PdfPCell(new Phrase("第二学年 ", font1));
two.setHorizontalAlignment(Element.ALIGN_CENTER);
two.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell three = new PdfPCell(new Phrase("第三学年 ", font1));
three.setHorizontalAlignment(Element.ALIGN_CENTER);
three.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell four = new PdfPCell(new Phrase("第四学年 ", font1));
four.setHorizontalAlignment(Element.ALIGN_CENTER);
four.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell five = new PdfPCell(new Phrase("第五学年 ", font1));
five.setHorizontalAlignment(Element.ALIGN_CENTER);
five.setVerticalAlignment(Element.ALIGN_MIDDLE);
table.addCell(one);
table.addCell(two);
table.addCell(three);
table.addCell(four);
table.addCell(five);
PdfPCell cell = new PdfPCell(table);
cell.setBorder(PdfPCell.NO_BORDER);
return cell;
}
private static PdfPCell scoreTitleTable(BaseFont baseFont) throws DocumentException {
com.lowagie.text.Font font1 =
new com.lowagie.text.Font(baseFont, 8, com.lowagie.text.Font.NORMAL);
PdfPTable table = new PdfPTable(1);
table.setWidths(new float[]{192});
PdfPCell one21 = new PdfPCell(new Phrase("成绩 ", font1));
one21.setHorizontalAlignment(Element.ALIGN_CENTER);
one21.setVerticalAlignment(Element.ALIGN_MIDDLE);
table.addCell(one21);
PdfPCell cell = new PdfPCell(table);
cell.setBorder(PdfPCell.NO_BORDER);
return cell;
}
private static PdfPCell semesterTable5(BaseFont baseFont) throws DocumentException {
com.lowagie.text.Font font1 =
new com.lowagie.text.Font(baseFont, 4, com.lowagie.text.Font.NORMAL);
PdfPTable table = new PdfPTable(2);
table.setWidths(new float[]{96, 96});
PdfPCell one21 = new PdfPCell(new Phrase("一学期 ", font1));
one21.setHorizontalAlignment(Element.ALIGN_CENTER);
one21.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one22 = new PdfPCell(new Phrase("二学期 ", font1));
one22.setHorizontalAlignment(Element.ALIGN_CENTER);
one22.setVerticalAlignment(Element.ALIGN_MIDDLE);
table.addCell(one21);
table.addCell(one22);
PdfPCell cell = new PdfPCell(table);
cell.setBorder(PdfPCell.NO_BORDER);
return cell;
}
private static PdfPCell semesterTable(BaseFont baseFont) throws DocumentException {
com.lowagie.text.Font font1 =
new com.lowagie.text.Font(baseFont, 8, com.lowagie.text.Font.NORMAL);
PdfPTable table = new PdfPTable(6);
table.setWidths(new float[]{683, 683, 683, 683, 683, 683});
PdfPCell one21 = new PdfPCell(new Phrase("第一学期 ", font1));
one21.setHorizontalAlignment(Element.ALIGN_CENTER);
one21.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one22 = new PdfPCell(new Phrase("第二学期 ", font1));
one22.setHorizontalAlignment(Element.ALIGN_CENTER);
one22.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one23 = new PdfPCell(new Phrase("第一学期 ", font1));
one23.setHorizontalAlignment(Element.ALIGN_CENTER);
one23.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one24 = new PdfPCell(new Phrase("第二学期 ", font1));
one24.setHorizontalAlignment(Element.ALIGN_CENTER);
one24.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one25 = new PdfPCell(new Phrase("第一学期 ", font1));
one25.setHorizontalAlignment(Element.ALIGN_CENTER);
one25.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one26 = new PdfPCell(new Phrase("第二学期 ", font1));
one26.setHorizontalAlignment(Element.ALIGN_CENTER);
one26.setVerticalAlignment(Element.ALIGN_MIDDLE);
table.addCell(one21);
table.addCell(one22);
table.addCell(one23);
table.addCell(one24);
table.addCell(one25);
table.addCell(one26);
PdfPCell cell = new PdfPCell(table);
cell.setBorder(PdfPCell.NO_BORDER);
return cell;
}
private static PdfPCell courseTitleTable5(BaseFont baseFont) throws DocumentException {
com.lowagie.text.Font font1 =
new com.lowagie.text.Font(baseFont, fontSize7,
com.lowagie.text.Font.NORMAL);
com.lowagie.text.Font font8 =
new com.lowagie.text.Font(baseFont, 10, com.lowagie.text.Font.NORMAL);
PdfPTable table = new PdfPTable(25);
table.setWidths(new float[]{361, 136, 192, 65, 65, 361, 136, 192, 65,
65, 361, 136, 192, 65, 65, 361, 136, 192,
65, 65, 361, 136, 192, 65, 65});
for (int i = 0; i < 5; i++) {
PdfPCell one21 = new PdfPCell(new Phrase("课程", font8));
one21.setHorizontalAlignment(Element.ALIGN_CENTER);
one21.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one22 = new PdfPCell(new Phrase("课程类型 ", font8));
one22.setHorizontalAlignment(Element.ALIGN_CENTER);
one22.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one24 = new PdfPCell(new Phrase("学分", font1));
one24.setHorizontalAlignment(Element.ALIGN_CENTER);
one24.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one25 = new PdfPCell(new Phrase("绩点", font1));
one25.setHorizontalAlignment(Element.ALIGN_CENTER);
one25.setVerticalAlignment(Element.ALIGN_MIDDLE);
table.addCell(one21);
table.addCell(one22);
table.addCell(scoreTable5(baseFont));
table.addCell(one24);
table.addCell(one25);
}
PdfPCell cell = new PdfPCell(table);
cell.setBorder(PdfPCell.NO_BORDER);
return cell;
}
private static PdfPCell scoreTable5(BaseFont baseFont) throws DocumentException {
PdfPTable table = new PdfPTable(1);
table.setWidths(new float[]{500});
table.addCell(scoreTitleTable(baseFont));
table.addCell(semesterTable5(baseFont));
PdfPCell cell = new PdfPCell(table);
cell.setBorder(PdfPCell.NO_BORDER);
return cell;
}
private static PdfPCell courseTitleTable(BaseFont baseFont) throws DocumentException {
com.lowagie.text.Font font1 =
new com.lowagie.text.Font(baseFont, fontSize7,
com.lowagie.text.Font.NORMAL);
PdfPTable table = new PdfPTable(30);
table.setWidths(new float[]{343, 100, 80, 80, 80, 343, 100, 80, 80,
80, 343, 100, 80, 80, 80, 343, 100, 80,
80, 80, 343, 100, 80, 80, 80, 343, 100,
80, 80, 80});
for (int i = 0; i < 6; i++) {
PdfPCell one21 = new PdfPCell(new Phrase("课程", font1));
one21.setHorizontalAlignment(Element.ALIGN_CENTER);
one21.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one22 = new PdfPCell(new Phrase("课程类型 ", font1));
one22.setHorizontalAlignment(Element.ALIGN_CENTER);
one22.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one23 = new PdfPCell(new Phrase("成绩", font1));
one23.setHorizontalAlignment(Element.ALIGN_CENTER);
one23.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one24 = new PdfPCell(new Phrase("学分", font1));
one24.setHorizontalAlignment(Element.ALIGN_CENTER);
one24.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one25 = new PdfPCell(new Phrase("绩点", font1));
one25.setHorizontalAlignment(Element.ALIGN_CENTER);
one25.setVerticalAlignment(Element.ALIGN_MIDDLE);
table.addCell(one21);
table.addCell(one22);
table.addCell(one23);
table.addCell(one24);
table.addCell(one25);
}
PdfPCell cell = new PdfPCell(table);
cell.setBorder(PdfPCell.NO_BORDER);
return cell;
}
private static PdfPCell sfhgTable(BaseFont baseFont) throws DocumentException {
com.lowagie.text.Font font1 =
new com.lowagie.text.Font(baseFont, 15, com.lowagie.text.Font.BOLD);
String Sfhg = "合格";
PdfPTable table = new PdfPTable(1);
table.setWidths(new float[]{256 + 220});
PdfPCell one1 = new PdfPCell(new Phrase(Sfhg, font1));
one1.setHorizontalAlignment(Element.ALIGN_CENTER);
one1.setVerticalAlignment(Element.ALIGN_MIDDLE);
table.addCell(one1);
PdfPCell cell = new PdfPCell(table);
cell.setBorder(PdfPCell.NO_BORDER);
return cell;
}
private static PdfPCell byxfTable(Map<String, String> map,
BaseFont baseFont) throws DocumentException {
PdfPTable table0 = new PdfPTable(1);
table0.setWidths(new float[]{500});
table0.addCell(byxfTable1(map, baseFont));
table0.addCell(byxfTable2(baseFont));
PdfPCell cell = new PdfPCell(table0);
cell.setBorder(PdfPCell.NO_BORDER);
return cell;
}
private static PdfPCell byxfTable1(Map<String, String> map,
BaseFont baseFont) throws DocumentException {
com.lowagie.text.Font font1 =
new com.lowagie.text.Font(baseFont, fontSize7,
com.lowagie.text.Font.NORMAL);
PdfPTable table = new PdfPTable(2);
table.setWidths(new float[]{256, 220});
PdfPCell one1 = new PdfPCell(new Phrase("总学分", font1));
one1.setHorizontalAlignment(Element.ALIGN_CENTER);
one1.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one2 = new PdfPCell(new Phrase(map.get("总学分"), font1));
one2.setHorizontalAlignment(Element.ALIGN_CENTER);
one2.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one3 = new PdfPCell(new Phrase("实际获得学分", font1));
one3.setHorizontalAlignment(Element.ALIGN_CENTER);
one3.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one4 = new PdfPCell(new Phrase(map.get("取得学分"), font1));
one4.setHorizontalAlignment(Element.ALIGN_CENTER);
one4.setVerticalAlignment(Element.ALIGN_MIDDLE);
table.addCell(one1);
table.addCell(one2);
table.addCell(one3);
table.addCell(one4);
PdfPCell cell = new PdfPCell(table);
cell.setBorder(PdfPCell.NO_BORDER);
return cell;
}
private static PdfPCell byxfTable2(BaseFont baseFont) throws DocumentException {
PdfPTable table1 = new PdfPTable(1);
table1.setWidths(new float[]{500});
table1.addCell(sfhgTable(baseFont));
PdfPCell cell = new PdfPCell(table1);
cell.setBorder(PdfPCell.NO_BORDER);
return cell;
}
private static PdfPCell notPassTable(Map<String, String> map,
BaseFont baseFont) throws DocumentException {
com.lowagie.text.Font font1 =
new com.lowagie.text.Font(baseFont, fontSize7,
com.lowagie.text.Font.NORMAL);
PdfPTable table = new PdfPTable(1);
table.setWidths(new float[]{500});
for (Map.Entry<String, String> a : map.entrySet()) {
PdfPCell one2 =
new PdfPCell(new Phrase((String) a.getValue(), font1));
one2.setHorizontalAlignment(Element.ALIGN_CENTER);
one2.setVerticalAlignment(Element.ALIGN_MIDDLE);
table.addCell(one2);
}
if (map.size() != endTableMaxRowPdf + 1) {
PdfPCell emptyCell = new PdfPCell(new Phrase(" ", font1));
for (int i = 0; i < endTableMaxRowPdf + 1 - map.size(); i++) {
table.addCell(emptyCell);
}
}
PdfPCell cell = new PdfPCell(table);
cell.setBorder(PdfPCell.NO_BORDER);
return cell;
}
private static PdfPCell sumSemesterTable5(Map map,
BaseFont baseFont) throws DocumentException {
com.lowagie.text.Font font1 =
new com.lowagie.text.Font(baseFont, 7, com.lowagie.text.Font.NORMAL);
PdfPTable table = new PdfPTable(20);
table.setWidths(new float[]{361, 136, 192, 130, 361, 136, 192, 130,
361, 136, 192, 130, 361, 136, 192, 130,
361, 136, 192, 130});
for (int i = 0; i < 6; i++) {
PdfPCell one21 = new PdfPCell(new Phrase("学期总学分 ", font1));
one21.setHorizontalAlignment(Element.ALIGN_CENTER);
one21.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one22 =
new PdfPCell(new Phrase((String) map.get("总学分" + i), font1));
one22.setHorizontalAlignment(Element.ALIGN_CENTER);
one22.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one23 = new PdfPCell(new Phrase("取得学分 ", font1));
one23.setHorizontalAlignment(Element.ALIGN_CENTER);
one23.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one24 =
new PdfPCell(new Phrase((String) map.get("取得学分" + i), font1));
one24.setHorizontalAlignment(Element.ALIGN_CENTER);
one24.setVerticalAlignment(Element.ALIGN_MIDDLE);
table.addCell(one21);
table.addCell(one22);
table.addCell(one23);
table.addCell(one24);
}
PdfPCell cell = new PdfPCell(table);
cell.setBorder(PdfPCell.NO_BORDER);
return cell;
}
private static PdfPCell sumSemesterTable(Map map,
BaseFont baseFont) throws DocumentException {
com.lowagie.text.Font font1 =
new com.lowagie.text.Font(baseFont, 7, com.lowagie.text.Font.NORMAL);
PdfPTable table = new PdfPTable(24);
table.setWidths(new float[]{188, 155, 180, 160, 188, 155, 180, 160,
188, 155, 180, 160, 188, 155, 180, 160,
188, 155, 180, 160, 188, 155, 180,
160});
for (int i = 0; i < 6; i++) {
PdfPCell one21 = new PdfPCell(new Phrase("学期总学分 ", font1));
one21.setHorizontalAlignment(Element.ALIGN_CENTER);
one21.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one22 =
new PdfPCell(new Phrase((String) map.get("总学分" + i), font1));
one22.setHorizontalAlignment(Element.ALIGN_CENTER);
one22.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one23 = new PdfPCell(new Phrase("取得学分 ", font1));
one23.setHorizontalAlignment(Element.ALIGN_CENTER);
one23.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one24 =
new PdfPCell(new Phrase((String) map.get("取得学分" + i), font1));
one24.setHorizontalAlignment(Element.ALIGN_CENTER);
one24.setVerticalAlignment(Element.ALIGN_MIDDLE);
table.addCell(one21);
table.addCell(one22);
table.addCell(one23);
table.addCell(one24);
}
PdfPCell cell = new PdfPCell(table);
cell.setBorder(PdfPCell.NO_BORDER);
return cell;
}
private static PdfPCell byInfoTable(BaseFont baseFont) throws DocumentException {
com.lowagie.text.Font font1 =
new com.lowagie.text.Font(baseFont, fontSize7,
com.lowagie.text.Font.NORMAL);
PdfPTable table = new PdfPTable(2);
table.setWidths(new float[]{291, 686});
String Byrq = "20230901";
String Byzh = "N0.1688888888";
PdfPCell one21 = new PdfPCell(new Phrase("毕业日期 ", font1));
one21.setHorizontalAlignment(Element.ALIGN_CENTER);
one21.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one22 = new PdfPCell(new Phrase("毕业证号", font1));
one22.setHorizontalAlignment(Element.ALIGN_CENTER);
one22.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one23 = new PdfPCell(new Phrase(Byrq, font1));
one23.setHorizontalAlignment(Element.ALIGN_CENTER);
one23.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one24 = new PdfPCell(new Phrase(Byzh, font1));
one24.setHorizontalAlignment(Element.ALIGN_CENTER);
one24.setVerticalAlignment(Element.ALIGN_MIDDLE);
table.addCell(one21);
table.addCell(one22);
table.addCell(one23);
table.addCell(one24);
PdfPCell emptyCell = new PdfPCell(new Phrase(" ", font1));
for (int i = 0; i < endTableMaxRowPdf - 1; i++) {
table.addCell(emptyCell);
table.addCell(emptyCell);
}
PdfPCell cel21 = new PdfPCell(table);
cel21.setBorder(PdfPCell.NO_BORDER);
return cel21;
}
private static PdfPCell changeTable(Map<String, String[]> change,
BaseFont baseFont) throws DocumentException {
com.lowagie.text.Font font1 =
new com.lowagie.text.Font(baseFont, fontSize7,
com.lowagie.text.Font.NORMAL);
PdfPTable table = new PdfPTable(3);
table.setWidths(new float[]{354, 327, 735});
PdfPCell one1 = new PdfPCell(new Phrase("类别", font1));
one1.setHorizontalAlignment(Element.ALIGN_CENTER);
one1.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one2 = new PdfPCell(new Phrase("时间", font1));
one2.setHorizontalAlignment(Element.ALIGN_CENTER);
one2.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one3 = new PdfPCell(new Phrase("原因", font1));
one3.setHorizontalAlignment(Element.ALIGN_CENTER);
one3.setVerticalAlignment(Element.ALIGN_MIDDLE);
table.addCell(one1);
table.addCell(one2);
table.addCell(one3);
for (Map.Entry<String, String[]> a : change.entrySet()) {
String[] value = a.getValue();
PdfPCell one11 = new PdfPCell(new Phrase(value[0], font1));
one11.setHorizontalAlignment(Element.ALIGN_CENTER);
one11.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one12 = new PdfPCell(new Phrase(value[1], font1));
one12.setHorizontalAlignment(Element.ALIGN_CENTER);
one12.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one13 = new PdfPCell(new Phrase(value[2], font1));
one13.setHorizontalAlignment(Element.ALIGN_CENTER);
one13.setVerticalAlignment(Element.ALIGN_MIDDLE);
table.addCell(one11);
table.addCell(one12);
table.addCell(one13);
}
if (change.size() != endTableMaxRowPdf) {
PdfPCell emptyCell = new PdfPCell(new Phrase(" ", font1));
for (int i = 0; i < endTableMaxRowPdf - change.size(); i++) {
table.addCell(emptyCell);
table.addCell(emptyCell);
table.addCell(emptyCell);
}
}
PdfPCell cell = new PdfPCell(table);
cell.setBorder(PdfPCell.NO_BORDER);
return cell;
}
private static PdfPCell courseScoreTable5(List<Row> rowList,
BaseFont baseFont) throws DocumentException {
com.lowagie.text.Font font81 =
new com.lowagie.text.Font(baseFont, 6, com.lowagie.text.Font.UNDERLINE);
com.lowagie.text.Font font8 =
new com.lowagie.text.Font(baseFont, 8, com.lowagie.text.Font.NORMAL);
com.lowagie.text.Font font7 =
new com.lowagie.text.Font(baseFont, 7, com.lowagie.text.Font.NORMAL);
com.lowagie.text.Font font6 =
new com.lowagie.text.Font(baseFont, 6, com.lowagie.text.Font.NORMAL);
com.lowagie.text.Font font5 =
new com.lowagie.text.Font(baseFont, 5, com.lowagie.text.Font.NORMAL);
com.lowagie.text.Font font4 =
new com.lowagie.text.Font(baseFont, 4, com.lowagie.text.Font.NORMAL);
com.lowagie.text.Font font3 =
new com.lowagie.text.Font(baseFont, 3, com.lowagie.text.Font.NORMAL);
com.lowagie.text.Font font2 =
new com.lowagie.text.Font(baseFont, 2, com.lowagie.text.Font.NORMAL);
PdfPTable table = new PdfPTable(6);
table.setWidths(new float[]{361, 136, 96, 96, 65, 65});
int semesterGradeRowMaxLength = 28;
PdfPCell emptyCell = new PdfPCell(new Phrase(" ", font7));
if (rowList != null && !rowList.isEmpty()) {
int cnt = rowList.size();
for (int j = 0; j < cnt; j++) {
Row dataRow = rowList.get(j);
String kcStr = "解剖学";
String lbStr = "必修";
Object xfObj = "4";
String xfStr = "";
if (xfObj == null) {
xfStr = "";
} else {
xfStr = String.valueOf(xfObj);
}
Object jdObj = "4";
String jdStr = "";
if (jdObj == null) {
jdStr = "";
} else {
jdStr = String.valueOf(jdObj);
}
String cjStr = "98";
String bkStr = "0";
String cxStr = "0";
String displayScore = cjStr;
com.lowagie.text.Font cjFont8 = font7;
if (!StringUtils.isEmpty(cxStr)) {
displayScore = "[" + cxStr + "]";
} else if (!StringUtils.isEmpty(bkStr)) {
displayScore = bkStr;
cjFont8 = font81;
} else if (!StringUtils.isEmpty(cjStr)) {
displayScore = cjStr;
}
com.lowagie.text.Font fontKclx = font5;
if (lbStr != null) {
if (lbStr.length() <= 6) {
fontKclx = font4;
}
}
com.lowagie.text.Font fontKc = font8;
if (kcStr != null) {
if (kcStr.length() <= 12) {
fontKc = font6;
} else if (kcStr.length() <= 14) {
fontKc = font6;
} else if (kcStr.length() <= 17) {
fontKc = font5;
} else if (kcStr.length() <= 22) {
fontKc = font3;
} else if (kcStr.length() <= 26) {
fontKc = font3;
} else {
fontKc = font2;
}
}
PdfPCell one21 = new PdfPCell(new Phrase(kcStr, fontKc));
one21.setHorizontalAlignment(Element.ALIGN_CENTER);
one21.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one22 = new PdfPCell(new Phrase(lbStr, fontKclx));
one22.setHorizontalAlignment(Element.ALIGN_CENTER);
one22.setVerticalAlignment(Element.ALIGN_MIDDLE);
table.addCell(one21);
table.addCell(one22);
if ("1".equals("1")) {
PdfPCell one23 =
new PdfPCell(new Phrase(displayScore, cjFont8));
one23.setHorizontalAlignment(Element.ALIGN_CENTER);
one23.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one24 = new PdfPCell(new Phrase(xfStr, font7));
one24.setHorizontalAlignment(Element.ALIGN_CENTER);
one24.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one25 = new PdfPCell(new Phrase(jdStr, font7));
one25.setHorizontalAlignment(Element.ALIGN_CENTER);
one25.setVerticalAlignment(Element.ALIGN_MIDDLE);
table.addCell(one23);
table.addCell(emptyCell);
table.addCell(one24);
table.addCell(one25);
} else if ("2".equals("2")) {
PdfPCell one23 =
new PdfPCell(new Phrase(displayScore, cjFont8));
one23.setHorizontalAlignment(Element.ALIGN_CENTER);
one23.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one24 = new PdfPCell(new Phrase(xfStr, font7));
one24.setHorizontalAlignment(Element.ALIGN_CENTER);
one24.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one25 = new PdfPCell(new Phrase(jdStr, font7));
one25.setHorizontalAlignment(Element.ALIGN_CENTER);
one25.setVerticalAlignment(Element.ALIGN_MIDDLE);
table.addCell(emptyCell);
table.addCell(one23);
table.addCell(one24);
table.addCell(one25);
}
}
if (semesterGradeRowMaxLength != cnt) {
for (int j = 0; j < semesterGradeRowMaxLength - cnt; j++) {
table.addCell(emptyCell);
table.addCell(emptyCell);
table.addCell(emptyCell);
table.addCell(emptyCell);
table.addCell(emptyCell);
table.addCell(emptyCell);
}
}
} else {
for (int i = 0; i < semesterGradeRowMaxLength; i++) {
table.addCell(emptyCell);
table.addCell(emptyCell);
table.addCell(emptyCell);
table.addCell(emptyCell);
table.addCell(emptyCell);
table.addCell(emptyCell);
}
}
PdfPCell cell = new PdfPCell(table);
cell.setBorder(PdfPCell.NO_BORDER);
return cell;
}
private static PdfPCell courseScoreTable(List<Row> rowList,
BaseFont baseFont) throws DocumentException {
com.lowagie.text.Font font81 =
new com.lowagie.text.Font(baseFont, 6, com.lowagie.text.Font.UNDERLINE);
com.lowagie.text.Font font8 =
new com.lowagie.text.Font(baseFont, 8, com.lowagie.text.Font.NORMAL);
com.lowagie.text.Font font7 =
new com.lowagie.text.Font(baseFont, 7, com.lowagie.text.Font.NORMAL);
com.lowagie.text.Font font6 =
new com.lowagie.text.Font(baseFont, 6, com.lowagie.text.Font.NORMAL);
com.lowagie.text.Font font5 =
new com.lowagie.text.Font(baseFont, 5, com.lowagie.text.Font.NORMAL);
com.lowagie.text.Font font4 =
new com.lowagie.text.Font(baseFont, 4, com.lowagie.text.Font.NORMAL);
com.lowagie.text.Font font3 =
new com.lowagie.text.Font(baseFont, 3, com.lowagie.text.Font.NORMAL);
com.lowagie.text.Font font2 =
new com.lowagie.text.Font(baseFont, 2, com.lowagie.text.Font.NORMAL);
PdfPTable table = new PdfPTable(5);
table.setWidths(new float[]{343, 100, 80, 80, 80});
int semesterGradeRowMaxLength = 16;
PdfPCell emptyCell = new PdfPCell(new Phrase(" ", font7));
if (rowList != null && !rowList.isEmpty()) {
int cnt = rowList.size();
for (int j = 0; j < cnt; j++) {
Row dataRow = rowList.get(j);
String kcStr = "解剖学";
String lbStr = "必修";
Object xfObj = "4";
String xfStr = "";
if (xfObj == null) {
xfStr = "";
} else {
xfStr = String.valueOf(xfObj);
}
Object jdObj = "5";
String jdStr = "";
if (jdObj == null) {
jdStr = "";
} else {
jdStr = String.valueOf(jdObj);
}
String cjStr = "98";
String bkStr = "0";
String cxStr = "0";
String displayScore = cjStr;
com.lowagie.text.Font cjFont8 = font7;
if (!StringUtils.isEmpty(cxStr)) {
displayScore = "[" + cxStr + "]";
} else if (!StringUtils.isEmpty(bkStr)) {
displayScore = bkStr;
cjFont8 = font81;
} else if (!StringUtils.isEmpty(cjStr)) {
displayScore = cjStr;
}
com.lowagie.text.Font fontKclx = font5;
if (lbStr != null) {
if (lbStr.length() <= 6) {
fontKclx = font3;
}
}
com.lowagie.text.Font fontKc = font8;
if (kcStr != null) {
if (kcStr.length() <= 12) {
fontKc = font6;
} else if (kcStr.length() <= 14) {
fontKc = font6;
} else if (kcStr.length() <= 17) {
fontKc = font5;
} else if (kcStr.length() <= 22) {
fontKc = font3;
} else if (kcStr.length() <= 26) {
fontKc = font3;
} else {
fontKc = font2;
}
}
PdfPCell one21 = new PdfPCell(new Phrase(kcStr, fontKc));
one21.setHorizontalAlignment(Element.ALIGN_CENTER);
one21.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one22 = new PdfPCell(new Phrase(lbStr, fontKclx));
one22.setHorizontalAlignment(Element.ALIGN_CENTER);
one22.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one23 =
new PdfPCell(new Phrase(displayScore, cjFont8));
one23.setHorizontalAlignment(Element.ALIGN_CENTER);
one23.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one24 = new PdfPCell(new Phrase(xfStr, font7));
one24.setHorizontalAlignment(Element.ALIGN_CENTER);
one24.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one25 = new PdfPCell(new Phrase(jdStr, font7));
one25.setHorizontalAlignment(Element.ALIGN_CENTER);
one25.setVerticalAlignment(Element.ALIGN_MIDDLE);
table.addCell(one21);
table.addCell(one22);
table.addCell(one23);
table.addCell(one24);
table.addCell(one25);
}
if (semesterGradeRowMaxLength != cnt) {
for (int j = 0; j < semesterGradeRowMaxLength - cnt; j++) {
table.addCell(emptyCell);
table.addCell(emptyCell);
table.addCell(emptyCell);
table.addCell(emptyCell);
table.addCell(emptyCell);
}
}
} else {
for (int i = 0; i < semesterGradeRowMaxLength; i++) {
table.addCell(emptyCell);
table.addCell(emptyCell);
table.addCell(emptyCell);
table.addCell(emptyCell);
table.addCell(emptyCell);
}
}
PdfPCell cell = new PdfPCell(table);
cell.setBorder(PdfPCell.NO_BORDER);
return cell;
}
private static PdfPCell baseInfoTable(BaseFont baseFont) throws DocumentException {
PdfPTable table = new PdfPTable(1);
table.setWidths(new float[]{500});
table.addCell(baseInfoTableOneRow(baseFont));
table.addCell(baseInfoTableTwoRow(baseFont));
table.addCell(baseInfoTableThreeRow(baseFont));
table.addCell(baseInfoTableFourRow(baseFont));
table.addCell(baseInfoTableFiveRow(baseFont));
table.addCell(baseInfoTableSixRow(baseFont));
PdfPCell cell = new PdfPCell(table);
cell.setBorder(PdfPCell.NO_BORDER);
return cell;
}
private static PdfPCell baseInfoTableOneRow(BaseFont baseFont) throws DocumentException {
com.lowagie.text.Font font1 =
new com.lowagie.text.Font(baseFont, 16, com.lowagie.text.Font.BOLD);
PdfPTable table11 = new PdfPTable(1);
table11.setWidths(new float[]{500});
PdfPCell one = new PdfPCell(new Phrase("XX学院学学生籍表 ", font1));
one.setPaddingTop(10.0f);
one.setPaddingBottom(10.0f);
one.setHorizontalAlignment(Element.ALIGN_CENTER);
one.setVerticalAlignment(Element.ALIGN_MIDDLE);
table11.addCell(one);
PdfPCell cel21 = new PdfPCell(table11);
cel21.setBorder(PdfPCell.NO_BORDER);
return cel21;
}
private static PdfPCell baseInfoTableTwoRow(BaseFont baseFont) throws DocumentException {
com.lowagie.text.Font font1 =
new com.lowagie.text.Font(baseFont, 8, com.lowagie.text.Font.NORMAL);
PdfPTable table21 = new PdfPTable(18);
table21.setWidths(new float[]{127, 166, 116, 80, 191, 219, 193, 394,
110, 111, 205, 213, 120, 161, 120, 280,
125, 450});
String Xm = "佳佳";
String Xbmc = "女";
String Csrq = "20000101";
String Sfzjh = "440834200012091314";
String Mzmc = "汉族";
String Zzmmmc = "党员";
String Jg = "广东梅州";
String Yddh = "13631295485";
String Dzyx = "1165069099@qq.com";
PdfPCell one21 = new PdfPCell(new Phrase("姓名 ", font1));
one21.setHorizontalAlignment(Element.ALIGN_CENTER);
one21.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one22 = new PdfPCell(new Phrase(Xm, font1));
one22.setHorizontalAlignment(Element.ALIGN_CENTER);
one22.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one23 = new PdfPCell(new Phrase("性别", font1));
one23.setHorizontalAlignment(Element.ALIGN_CENTER);
one23.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one24 = new PdfPCell(new Phrase(Xbmc, font1));
one24.setHorizontalAlignment(Element.ALIGN_CENTER);
one24.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one25 = new PdfPCell(new Phrase("出生日期", font1));
one25.setHorizontalAlignment(Element.ALIGN_CENTER);
one25.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one26 = new PdfPCell(new Phrase(Csrq, font1));
one26.setHorizontalAlignment(Element.ALIGN_CENTER);
one26.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one27 = new PdfPCell(new Phrase("身份证号", font1));
one27.setHorizontalAlignment(Element.ALIGN_CENTER);
one27.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one28 = new PdfPCell(new Phrase(Sfzjh, font1));
one28.setHorizontalAlignment(Element.ALIGN_CENTER);
one28.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one29 = new PdfPCell(new Phrase("民族", font1));
one29.setHorizontalAlignment(Element.ALIGN_CENTER);
one29.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one210 = new PdfPCell(new Phrase(Mzmc, font1));
one210.setHorizontalAlignment(Element.ALIGN_CENTER);
one210.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one211 = new PdfPCell(new Phrase("政治面貌", font1));
one211.setHorizontalAlignment(Element.ALIGN_CENTER);
one211.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one212 = new PdfPCell(new Phrase(Zzmmmc, font1));
one212.setHorizontalAlignment(Element.ALIGN_CENTER);
one212.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one213 = new PdfPCell(new Phrase("籍贯", font1));
one213.setHorizontalAlignment(Element.ALIGN_CENTER);
one213.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one214 = new PdfPCell(new Phrase(Jg, font1));
one214.setHorizontalAlignment(Element.ALIGN_CENTER);
one214.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one215 = new PdfPCell(new Phrase("电话", font1));
one215.setHorizontalAlignment(Element.ALIGN_CENTER);
one215.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one216 = new PdfPCell(new Phrase(Yddh, font1));
one216.setHorizontalAlignment(Element.ALIGN_CENTER);
one216.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one217 = new PdfPCell(new Phrase("邮箱", font1));
one217.setHorizontalAlignment(Element.ALIGN_CENTER);
one217.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one218 = new PdfPCell(new Phrase(Dzyx, font1));
one218.setHorizontalAlignment(Element.ALIGN_CENTER);
one218.setVerticalAlignment(Element.ALIGN_MIDDLE);
table21.addCell(one21);
table21.addCell(one22);
table21.addCell(one23);
table21.addCell(one24);
table21.addCell(one25);
table21.addCell(one26);
table21.addCell(one27);
table21.addCell(one28);
table21.addCell(one29);
table21.addCell(one210);
table21.addCell(one211);
table21.addCell(one212);
table21.addCell(one213);
table21.addCell(one214);
table21.addCell(one215);
table21.addCell(one216);
table21.addCell(one217);
table21.addCell(one218);
PdfPCell cel21 = new PdfPCell(table21);
cel21.setBorder(PdfPCell.NO_BORDER);
return cel21;
}
private static PdfPCell baseInfoTableThreeRow(BaseFont baseFont) throws DocumentException {
com.lowagie.text.Font font1 =
new com.lowagie.text.Font(baseFont, 8, com.lowagie.text.Font.NORMAL);
PdfPTable table21 = new PdfPTable(4);
table21.setWidths(new float[]{188, 2618, 125, 450});
String Jtdz = "家庭地址";
String Yzbm = "523343";
PdfPCell one21 = new PdfPCell(new Phrase("家庭地址 ", font1));
one21.setHorizontalAlignment(Element.ALIGN_CENTER);
one21.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one22 = new PdfPCell(new Phrase(Jtdz, font1));
one22.setHorizontalAlignment(Element.ALIGN_CENTER);
one22.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one23 = new PdfPCell(new Phrase("邮编", font1));
one23.setHorizontalAlignment(Element.ALIGN_CENTER);
one23.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one24 = new PdfPCell(new Phrase(Yzbm, font1));
one24.setHorizontalAlignment(Element.ALIGN_CENTER);
one24.setVerticalAlignment(Element.ALIGN_MIDDLE);
table21.addCell(one21);
table21.addCell(one22);
table21.addCell(one23);
table21.addCell(one24);
PdfPCell cel21 = new PdfPCell(table21);
cel21.setBorder(PdfPCell.NO_BORDER);
return cel21;
}
private static PdfPCell baseInfoTableFourRow(BaseFont baseFont) throws DocumentException {
com.lowagie.text.Font font1 =
new com.lowagie.text.Font(baseFont, 8, com.lowagie.text.Font.NORMAL);
PdfPTable table21 = new PdfPTable(12);
table21.setWidths(new float[]{188, 222, 240, 250, 251, 267, 190, 390,
189, 618, 125, 450});
String Xh = "130403021032";
String Jzxm = "林先生";
String Ybrgx = "父亲";
String Jzlxfs = "13631295485";
String Jzyx = "1165069099@qq.com";
String Gzdw = "廣州天河";
PdfPCell one21 = new PdfPCell(new Phrase("家长姓名 ", font1));
one21.setHorizontalAlignment(Element.ALIGN_CENTER);
one21.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one22 = new PdfPCell(new Phrase(Jzxm, font1));
one22.setHorizontalAlignment(Element.ALIGN_CENTER);
one22.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one23 = new PdfPCell(new Phrase("与本人关系", font1));
one23.setHorizontalAlignment(Element.ALIGN_CENTER);
one23.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one24 = new PdfPCell(new Phrase(Ybrgx, font1));
one24.setHorizontalAlignment(Element.ALIGN_CENTER);
one24.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one25 = new PdfPCell(new Phrase("家长联系方式", font1));
one25.setHorizontalAlignment(Element.ALIGN_CENTER);
one25.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one26 = new PdfPCell(new Phrase(Jzlxfs, font1));
one26.setHorizontalAlignment(Element.ALIGN_CENTER);
one26.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one27 = new PdfPCell(new Phrase("家长邮箱", font1));
one27.setHorizontalAlignment(Element.ALIGN_CENTER);
one27.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one28 = new PdfPCell(new Phrase(Jzyx, font1));
one28.setHorizontalAlignment(Element.ALIGN_CENTER);
one28.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one29 = new PdfPCell(new Phrase("工作单位", font1));
one29.setHorizontalAlignment(Element.ALIGN_CENTER);
one29.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one210 = new PdfPCell(new Phrase(Gzdw, font1));
one210.setHorizontalAlignment(Element.ALIGN_CENTER);
one210.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one211 = new PdfPCell(new Phrase("学号", font1));
one211.setHorizontalAlignment(Element.ALIGN_CENTER);
one211.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one212 = new PdfPCell(new Phrase(Xh, font1));
one212.setHorizontalAlignment(Element.ALIGN_CENTER);
one212.setVerticalAlignment(Element.ALIGN_MIDDLE);
table21.addCell(one21);
table21.addCell(one22);
table21.addCell(one23);
table21.addCell(one24);
table21.addCell(one25);
table21.addCell(one26);
table21.addCell(one27);
table21.addCell(one28);
table21.addCell(one29);
table21.addCell(one210);
table21.addCell(one211);
table21.addCell(one212);
PdfPCell cel21 = new PdfPCell(table21);
cel21.setBorder(PdfPCell.NO_BORDER);
return cel21;
}
private static PdfPCell baseInfoTableFiveRow(BaseFont baseFont) throws DocumentException {
com.lowagie.text.Font font1 =
new com.lowagie.text.Font(baseFont, 8, com.lowagie.text.Font.NORMAL);
PdfPTable table21 = new PdfPTable(12);
table21.setWidths(new float[]{188, 222, 240, 250, 152, 434, 122, 434,
146, 618, 125, 450});
String Rxfsmc = "统招";
String Rxny = "202209";
String Dwmc = "基础医学院";
String Zyfxmc = "临床医学";
Object xzObj = "3";
String Xz = "3";
Xz = String.valueOf(xzObj);
String Bjmc = "解剖1班";
PdfPCell one21 = new PdfPCell(new Phrase("入学方式 ", font1));
one21.setHorizontalAlignment(Element.ALIGN_CENTER);
one21.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one22 = new PdfPCell(new Phrase(Rxfsmc, font1));
one22.setHorizontalAlignment(Element.ALIGN_CENTER);
one22.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one23 = new PdfPCell(new Phrase("入学年月", font1));
one23.setHorizontalAlignment(Element.ALIGN_CENTER);
one23.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one24 = new PdfPCell(new Phrase(Rxny, font1));
one24.setHorizontalAlignment(Element.ALIGN_CENTER);
one24.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one25 = new PdfPCell(new Phrase("系部", font1));
one25.setHorizontalAlignment(Element.ALIGN_CENTER);
one25.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one26 = new PdfPCell(new Phrase(Dwmc, font1));
one26.setHorizontalAlignment(Element.ALIGN_CENTER);
one26.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one27 = new PdfPCell(new Phrase("专业", font1));
one27.setHorizontalAlignment(Element.ALIGN_CENTER);
one27.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one28 = new PdfPCell(new Phrase(Zyfxmc, font1));
one28.setHorizontalAlignment(Element.ALIGN_CENTER);
one28.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one29 = new PdfPCell(new Phrase("行政班", font1));
one29.setHorizontalAlignment(Element.ALIGN_CENTER);
one29.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one210 = new PdfPCell(new Phrase(Bjmc, font1));
one210.setHorizontalAlignment(Element.ALIGN_CENTER);
one210.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one211 = new PdfPCell(new Phrase("学制", font1));
one211.setHorizontalAlignment(Element.ALIGN_CENTER);
one211.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one212 = new PdfPCell(new Phrase(Xz, font1));
one212.setHorizontalAlignment(Element.ALIGN_CENTER);
one212.setVerticalAlignment(Element.ALIGN_MIDDLE);
table21.addCell(one21);
table21.addCell(one22);
table21.addCell(one23);
table21.addCell(one24);
table21.addCell(one25);
table21.addCell(one26);
table21.addCell(one27);
table21.addCell(one28);
table21.addCell(one29);
table21.addCell(one210);
table21.addCell(one211);
table21.addCell(one212);
PdfPCell cel21 = new PdfPCell(table21);
cel21.setBorder(PdfPCell.NO_BORDER);
return cel21;
}
private static PdfPCell baseInfoTableSixRow(BaseFont baseFont) throws DocumentException {
com.lowagie.text.Font font1 =
new com.lowagie.text.Font(baseFont, 8, com.lowagie.text.Font.NORMAL);
PdfPTable table21 = new PdfPTable(1);
table21.setWidths(new float[]{180});
PdfPCell one21 = new PdfPCell(new Phrase(" ", font1));
one21.setHorizontalAlignment(Element.ALIGN_CENTER);
one21.setVerticalAlignment(Element.ALIGN_MIDDLE);
table21.addCell(one21);
PdfPCell cel21 = new PdfPCell(table21);
cel21.setBorder(PdfPCell.NO_BORDER);
return cel21;
}
private static PdfPCell pictureTable(BaseFont bf) throws DocumentException {
com.lowagie.text.Font font1 =
new com.lowagie.text.Font(bf, 8, com.lowagie.text.Font.NORMAL);
PdfPTable table = new PdfPTable(3);
table.setWidths(new float[]{100, 10, 100});
String imagePathLq = "D:\\opt\\第一套人名币.png";
String imagePathXl = "D:\\opt\\简况表.jpg";
FileInputStream fis = null;
try {
File file = new File(imagePathLq);
if (file.exists()) {
Image png = Image.getInstance(imagePathLq);
png.scalePercent(2.8f);
PdfPCell one = new PdfPCell(png, true);
one.setFixedHeight(80);
one.setHorizontalAlignment(Element.ALIGN_CENTER);
one.setVerticalAlignment(Element.ALIGN_MIDDLE);
table.addCell(one);
} else {
PdfPCell one = new PdfPCell(new Phrase("请上传录取照片", font1));
one.setFixedHeight(80);
one.setHorizontalAlignment(Element.ALIGN_CENTER);
one.setVerticalAlignment(Element.ALIGN_MIDDLE);
table.addCell(one);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (fis != null) {
fis.close();
fis = null;
}
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
PdfPCell two = new PdfPCell(new Phrase("", font1));
two.setHorizontalAlignment(Element.ALIGN_CENTER);
two.setVerticalAlignment(Element.ALIGN_MIDDLE);
table.addCell(two);
try {
File file = new File(imagePathXl);
if (file.exists()) {
Image png = Image.getInstance(imagePathXl);
png.scalePercent(2.8f);
PdfPCell three = new PdfPCell(png, true);
three.setFixedHeight(80);
three.setHorizontalAlignment(Element.ALIGN_CENTER);
three.setVerticalAlignment(Element.ALIGN_MIDDLE);
table.addCell(three);
} else {
PdfPCell three = new PdfPCell(new Phrase("请上传学历照片", font1));
three.setFixedHeight(80);
three.setHorizontalAlignment(Element.ALIGN_CENTER);
three.setVerticalAlignment(Element.ALIGN_MIDDLE);
table.addCell(three);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (fis != null) {
fis.close();
fis = null;
}
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
PdfPCell cell = new PdfPCell(table);
cell.setBorder(PdfPCell.NO_BORDER);
return cell;
}
private static PdfPCell endTitleTable(BaseFont baseFont) throws DocumentException {
com.lowagie.text.Font font1 =
new com.lowagie.text.Font(baseFont, 8, com.lowagie.text.Font.NORMAL);
PdfPTable table21 = new PdfPTable(4);
table21.setWidths(new float[]{1416, 977, 1231, 476});
PdfPCell one1 = new PdfPCell(new Phrase("学籍异动", font1));
one1.setHorizontalAlignment(Element.ALIGN_CENTER);
one1.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one2 = new PdfPCell(new Phrase("毕业情况", font1));
one2.setHorizontalAlignment(Element.ALIGN_CENTER);
one2.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one3 = new PdfPCell(new Phrase("结业后尚待补考科目", font1));
one3.setHorizontalAlignment(Element.ALIGN_CENTER);
one3.setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell one4 = new PdfPCell(new Phrase("毕业学分", font1));
one4.setHorizontalAlignment(Element.ALIGN_CENTER);
one4.setVerticalAlignment(Element.ALIGN_MIDDLE);
table21.addCell(one1);
table21.addCell(one2);
table21.addCell(one3);
table21.addCell(one4);
PdfPCell cel21 = new PdfPCell(table21);
cel21.setBorder(PdfPCell.NO_BORDER);
return cel21;
}
private static Map<String, String> getNotpassInfo(List<List<Row>> groupList) {
Map<String, String> map = new HashMap();
if (groupList == null || groupList.size() <= 0) {
return map;
}
return map;
}
private static boolean removeDir(File dir) {
if (dir.isDirectory()) {
String[] fileList = dir.list();
for (String file : fileList) {
boolean flag = removeDir(new File(dir, file));
if (!flag) {
return false;
}
}
}
return dir.delete();
}
public static BaseFont baseFontKt() {
try {
String font = "";
if (Common.isLinux()) {
font = "/usr/lib/jvm/java-1.8-openjdk/jre/lib/fonts/fallback/simkai.ttf";
} else {
font = "c:\\windows\\fonts\\simkai.ttf";
}
return BaseFont.createFont(font, com.itextpdf.text.pdf.BaseFont.IDENTITY_H, com.itextpdf.text.pdf.BaseFont.NOT_EMBEDDED);
} catch (DocumentException | IOException e) {
e.printStackTrace();
}
return null;
}
public static BaseFont baseFontLs() {
try {
String font = "";
if (Common.isLinux()) {
font = "/usr/lib/jvm/java-1.8-openjdk/jre/lib/fonts/fallback/STLITI.TTF";
} else {
font = "c:\\windows\\fonts\\STLITI.TTF";
}
return BaseFont.createFont(font, com.itextpdf.text.pdf.BaseFont.IDENTITY_H, com.itextpdf.text.pdf.BaseFont.NOT_EMBEDDED);
} catch (DocumentException | IOException e) {
e.printStackTrace();
}
return null;
}
}