|
@@ -58,14 +58,13 @@ public class ITextPdfUtil {
|
|
|
try (PdfWriter writer = new PdfWriter("src\\main\\resources\\" + yyyyMMdd + "report" + id + ".pdf");
|
|
|
//FileOutputStream out = new FileOutputStream(new File("src\\main\\resources\\outpdf\\report.pdf"))
|
|
|
PdfDocument pdf = new PdfDocument(writer);
|
|
|
- Document document = new Document(pdf, PageSize.A6);
|
|
|
+ Document document = new Document(pdf, PageSize.A4);
|
|
|
) {
|
|
|
DeviceRgb red = new DeviceRgb(255, 59, 48);
|
|
|
DeviceRgb black = new DeviceRgb(34, 34, 34);
|
|
|
//设置文档属性
|
|
|
pdf.getDocumentInfo().setAuthor("bmmx");
|
|
|
pdf.getDocumentInfo().setTitle("诊断报告");
|
|
|
- pdf.getDocumentInfo().setSubject("XXX公司");
|
|
|
|
|
|
//设置字体
|
|
|
document.setFont(ITextPdfUtil.getPdfFont());
|
|
@@ -77,10 +76,12 @@ public class ITextPdfUtil {
|
|
|
document.add(new Div()
|
|
|
.add(new Paragraph("诊断报告")
|
|
|
.addStyle(new Style()
|
|
|
+ .setFontSize(20)
|
|
|
.setBold()))
|
|
|
.add(new Paragraph("— " + LocalDateTime.now()
|
|
|
.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) + " —"))
|
|
|
.addStyle(new Style()
|
|
|
+ .setFontSize(18)
|
|
|
.setFontColor(new DeviceRgb(54, 85, 153)))
|
|
|
.setBackgroundColor(new DeviceRgb(235, 241, 250))
|
|
|
.setTextAlignment(TextAlignment.CENTER));
|
|
@@ -89,11 +90,12 @@ public class ITextPdfUtil {
|
|
|
Table baseTable = new Table(2);
|
|
|
mapToTable(baseMap, baseTable, c1, c2);
|
|
|
|
|
|
- ImageData imageData = ImageDataFactory.create("src\\main\\resources\\img_1.png");
|
|
|
+ ImageData imageData = ImageDataFactory.create("src\\main\\resources\\template\\static\\img.png");
|
|
|
Image update = new Image(imageData);
|
|
|
update.setWidth(20);
|
|
|
update.setHeight(20);
|
|
|
- update.setMarginLeft(250);
|
|
|
+ update.setMarginTop(10);
|
|
|
+ update.setMarginLeft(540);
|
|
|
|
|
|
|
|
|
// 车辆信息
|
|
@@ -110,6 +112,7 @@ public class ITextPdfUtil {
|
|
|
.setWidth(100)
|
|
|
.setHorizontalAlignment(HorizontalAlignment.CENTER)
|
|
|
.add(new Paragraph("车辆信息")
|
|
|
+ .setFontSize(18)
|
|
|
.setTextAlignment(TextAlignment.CENTER)
|
|
|
.addStyle(new Style()
|
|
|
.setFontColor(new DeviceRgb(255, 255, 255))
|
|
@@ -148,6 +151,7 @@ public class ITextPdfUtil {
|
|
|
.setWidth(100)
|
|
|
.setHorizontalAlignment(HorizontalAlignment.CENTER)
|
|
|
.add(new Paragraph("诊断详情")
|
|
|
+ .setFontSize(18)
|
|
|
.setTextAlignment(TextAlignment.CENTER)
|
|
|
.addStyle(new Style()
|
|
|
.setFontColor(new DeviceRgb(255, 255, 255))
|
|
@@ -157,18 +161,17 @@ public class ITextPdfUtil {
|
|
|
.setBackgroundColor(new DeviceRgb(64, 109, 183))
|
|
|
.setMarginTop(20)
|
|
|
.setBorderTopRightRadius(new BorderRadius(5))
|
|
|
- .setMaxWidth(150)
|
|
|
- .setMaxHeight(30)
|
|
|
+ .setMaxWidth(300)
|
|
|
.add(new Paragraph(name)
|
|
|
+ .setFontSize(16)
|
|
|
.setFontColor(new DeviceRgb(255, 255, 255))
|
|
|
- .setFontSize(10)
|
|
|
.setTextAlignment(TextAlignment.CENTER)
|
|
|
)
|
|
|
)
|
|
|
.add(new LineSeparator(solidLine).setMarginRight(10))
|
|
|
.add(new Paragraph("故障码(" + faultCodeMap.size() + ")")
|
|
|
.setFontColor(new DeviceRgb(153, 153, 153))
|
|
|
- .setFontSize(10)
|
|
|
+ .setFontSize(16)
|
|
|
.setMarginLeft(10)
|
|
|
.setMarginTop(10)
|
|
|
)
|
|
@@ -176,11 +179,11 @@ public class ITextPdfUtil {
|
|
|
|
|
|
.add(new Paragraph("版本信息(" + versionMap.size() + ")")
|
|
|
.setFontColor(new DeviceRgb(153, 153, 153))
|
|
|
- .setFontSize(10)
|
|
|
+ .setFontSize(16)
|
|
|
.setMarginLeft(10)
|
|
|
.setMarginTop(10)
|
|
|
)
|
|
|
- .add(versionTable).setFontSize(10));
|
|
|
+ .add(versionTable).setFontSize(16));
|
|
|
}
|
|
|
|
|
|
|
|
@@ -190,7 +193,7 @@ public class ITextPdfUtil {
|
|
|
|
|
|
Text firstCh = new Text("*").setFontColor(red).setFontSize(8);
|
|
|
Text rest = new Text("该车辆检测报告仅对本次检查结果负责")
|
|
|
- .setFontSize(8)
|
|
|
+ .setFontSize(14)
|
|
|
.setFontColor(grey);
|
|
|
|
|
|
document.add(new Div()
|
|
@@ -218,9 +221,9 @@ public class ITextPdfUtil {
|
|
|
|
|
|
|
|
|
private static void mapToTable(Map<String, String> map, Table table, Color one, Color two) {
|
|
|
- table.setMargin(5);
|
|
|
- table.setWidth(270);
|
|
|
- table.setFontSize(10);
|
|
|
+ table.setMargin(10);
|
|
|
+ table.setWidth(570);
|
|
|
+ table.setFontSize(16);
|
|
|
table.setFontColor(new DeviceRgb(136, 136, 136));
|
|
|
for (Map.Entry<String, String> entry : map.entrySet()) {
|
|
|
table.addCell(entry.getKey() + ": ")
|