Bladeren bron

3.2.1-签到表字体大小

xiaof 2 jaren geleden
bovenliggende
commit
dbc7dcdf6d

+ 17 - 13
distributed-print-business/src/main/java/com/qmth/distributed/print/business/util/CreatePrintPdfUtil.java

@@ -32,7 +32,7 @@ public class CreatePrintPdfUtil {
     public File createSignPdf(PdfSignDto pdfFillDto, String destFileName) throws Exception {
 
         // 1:建立Document对象实例
-        Document document = new Document(PageSize.A4, 36.0F, 36.0F, 40F, 36.0F);
+        Document document = new Document(PageSize.A4, 20F, 20F, 40F, 36F);
 //        ByteArrayOutputStream baos = new ByteArrayOutputStream();
         File file = createFolder(destFileName);
         FileOutputStream fos = null;
@@ -118,7 +118,7 @@ public class CreatePrintPdfUtil {
         // 标题table
         PdfPTable titleTable = PdfFillUtils.createTable(new float[]{33, 34, 33});
         titleTable.addCell(PdfFillUtils.createCell("", null, null, 50f, Element.ALIGN_CENTER, 15, 3, 1));
-        titleTable.addCell(PdfFillUtils.createCell(pdfFillDto.getTitle(), PdfFillUtils.textFont18, null, 50f, Element.ALIGN_CENTER, 15, 3, 1));
+        titleTable.addCell(PdfFillUtils.createCell(pdfFillDto.getTitle(), PdfFillUtils.textFont14, null, 50f, Element.ALIGN_CENTER, 15, 3, 1));
         // 条码
         Image code128Image = PdfFillUtils.createBarcode(pdfWriter, pdfFillDto.getPackageNumber(), false, null, null);
         code128Image.scalePercent(100);
@@ -130,10 +130,10 @@ public class CreatePrintPdfUtil {
         PdfPTable basicTable = PdfFillUtils.createTable(6);
         List<Map<String, String>> basicPlate = pdfFillDto.getBasicPlate();
         for (Map<String, String> stringMap : basicPlate) {
-            basicTable.addCell(PdfFillUtils.createCell(stringMap.get("name") + ":" + stringMap.get("value"), PdfFillUtils.textFont12, null, 0f, Element.ALIGN_LEFT, 0, 1, 3));
+            basicTable.addCell(PdfFillUtils.createCell(stringMap.get("name") + ":" + stringMap.get("value"), PdfFillUtils.textFont9, null, 0f, Element.ALIGN_LEFT, 0, 1, 3));
         }
         if (basicPlate.size() % 2 > 0) {
-            basicTable.addCell(PdfFillUtils.createCell(" ", PdfFillUtils.textFont12, null, 16f, Element.ALIGN_LEFT, 0, 1, 3));
+            basicTable.addCell(PdfFillUtils.createCell(" ", PdfFillUtils.textFont9, null, 16f, Element.ALIGN_LEFT, 0, 1, 3));
         }
         document.add(basicTable);
 
@@ -152,7 +152,11 @@ public class CreatePrintPdfUtil {
             int j = 0;
             for (Map.Entry<String, String> entry : studentHeadPlate.entrySet()) {
                 headKeys[columnCount * i + j] = entry.getKey();
-                studentTable.addCell(PdfFillUtils.createCell(entry.getValue(), PdfFillUtils.textFont12, BaseColor.LIGHT_GRAY, 16f, Element.ALIGN_CENTER, 0, 1, 1));
+                String value = entry.getValue();
+                if("座位号".equals(value)){
+                    value = "座号";
+                }
+                studentTable.addCell(PdfFillUtils.createCell(value, PdfFillUtils.textFont9, BaseColor.LIGHT_GRAY, 16f, Element.ALIGN_CENTER, 0, 1, 1));
                 j++;
             }
         }
@@ -171,7 +175,7 @@ public class CreatePrintPdfUtil {
 
             if (studentPlateCount % 2 > 0 && 2 * i + 1 == studentPlate.size()) {
                 for (int i1 = 0; i1 < columnCount; i1++) {
-                    studentTable.addCell(PdfFillUtils.createCell("", PdfFillUtils.textFont12, null, 0, Element.ALIGN_CENTER, 0, 1, 1));
+                    studentTable.addCell(PdfFillUtils.createCell("", PdfFillUtils.textFont8, null, 0, Element.ALIGN_CENTER, 0, 1, 1));
                 }
                 continue;
             }
@@ -185,7 +189,7 @@ public class CreatePrintPdfUtil {
 
         document.add(blank);
 
-        Paragraph pDate = new Paragraph(" 年        月        日", PdfFillUtils.textFont12);
+        Paragraph pDate = new Paragraph(" 年        月        日", PdfFillUtils.textFont9);
         pDate.setAlignment(Element.ALIGN_RIGHT);
         pDate.setIndentationRight(20);
 
@@ -195,7 +199,7 @@ public class CreatePrintPdfUtil {
         PdfPCell cell34 = new PdfPCell();
         cell34.setBorderWidth(0.5F);
         cell34.setMinimumHeight(20);
-        cell34.setPhrase(new Paragraph("监考老师签名处", PdfFillUtils.textFont12));
+        cell34.setPhrase(new Paragraph("监考老师签名处", PdfFillUtils.textFont9));
         cell34.setVerticalAlignment(Element.ALIGN_MIDDLE);
         cell34.setHorizontalAlignment(Element.ALIGN_CENTER);
         signTable.addCell(cell34);
@@ -313,9 +317,9 @@ public class CreatePrintPdfUtil {
         } else if (size == 3) {
             columnWidth = new float[]{15, 20, 15, 15, 20, 15};
         } else if (size == 4) {
-            columnWidth = new float[]{12, 13, 13, 12, 12, 13, 13, 12};
+            columnWidth = new float[]{6, 14, 15, 15, 6, 14, 15, 15};
         } else if (size == 5) {
-            columnWidth = new float[]{10, 10, 10, 10, 10, 10, 10, 10, 10, 10};
+            columnWidth = new float[]{4, 8, 10, 20, 8, 4, 8, 10, 20, 8};
         } else if (size == 6) {
             columnWidth = new float[]{6, 9, 9, 9, 9, 8, 6, 9, 9, 9, 9, 8};
         } else {
@@ -331,7 +335,7 @@ public class CreatePrintPdfUtil {
      * @param percent 宽度
      */
     private Font chooseFont(String value, float percent) {
-        if (StringUtils.isNotBlank(value)) {
+        /*if (StringUtils.isNotBlank(value)) {
             if (value.length() < percent) {
                 return PdfFillUtils.textFont12;
             } else if (value.length() >= percent && value.length() < 1.5 * percent) {
@@ -339,8 +343,8 @@ public class CreatePrintPdfUtil {
             } else if (value.length() >= 1.5 * percent && value.length() < 2 * percent) {
                 return PdfFillUtils.textFont9;
             }
-        }
-        return PdfFillUtils.textFont12;
+        }*/
+        return PdfFillUtils.textFont9;
     }
 
     /**