Browse Source

fix: refine pdf exam and grading layout

yemeishu 3 weeks ago
parent
commit
6927584122

+ 39 - 11
resources/views/pdf/exam-grading.blade.php

@@ -53,7 +53,7 @@
             --question-gap: 6px;
         }
         body {
-            font-family: "SimSun", "Songti SC", serif;
+            font-family: "Noto Serif", "Noto Serif CJK SC", "Noto Sans CJK SC", "Noto Sans", "STSongti-SC", "PingFang SC", "Songti SC", serif;
             line-height: 1.65;
             color: #000;
             background: #fff;
@@ -97,8 +97,8 @@
             align-items: flex-start;
             font-weight: 600;
             font-size: 14px;
-            line-height: 1.6;
-            margin-top: 2px;
+            line-height: 1.65;
+            margin-top: 1px;
         }
         .question-lead.spacer { visibility: hidden; }
         .question-number { white-space: nowrap; margin-right: 2px; }
@@ -226,9 +226,10 @@
         }
         /* 优化SVG中文字标签的显示 */
         svg text {
-            font-family: "SimSun", "Times New Roman", serif !important;
-            font-size: 12px;
+            font-family: "Noto Serif", "Noto Serif CJK SC", "Noto Sans CJK SC", "Noto Sans", "STSongti-SC", "PingFang SC", "Songti SC", serif !important;
+            font-size: 13px !important;
             font-weight: bold;
+            font-style: normal;
             dominant-baseline: middle;
             text-anchor: middle;
             alignment-baseline: central;
@@ -261,26 +262,42 @@
             display: block;
             /* 确保图片不会在页面底部被截断 */
             min-height: 30px;
-            /* 限制单张图片最大高度,防止过大图片跨页 */
-            max-height: 180mm;
+            /* 限制独立图块尺寸,避免图片压过文字 */
+            max-height: 82mm;
         }
         .pdf-figure img {
-            max-width: 100%;
+            max-width: min(84%, 420px);
+            max-height: 82mm;
+            width: auto;
             height: auto;
             display: block;
             margin: 0 auto;
             object-fit: contain;
             box-sizing: border-box;
+            -webkit-print-color-adjust: exact;
+            print-color-adjust: exact;
+            image-rendering: -webkit-optimize-contrast;
         }
         /* 题干中的图片样式(向后兼容) */
         .question-stem img,
         .question-main img,
-        .question-content img {
+        .question-content img,
+        .answer-meta img,
+        .answer-line img,
+        .solution-content img,
+        .solution-section img,
+        .solution-parsed img {
             display: block;
-            max-width: 100%;
+            max-width: 220px;
+            max-height: 60mm;
+            width: auto;
             height: auto;
-            margin: 12px auto;
+            margin: 6px auto;
             box-sizing: border-box;
+            object-fit: contain;
+            -webkit-print-color-adjust: exact;
+            print-color-adjust: exact;
+            image-rendering: -webkit-optimize-contrast;
         }
         /* 选项中的图片样式 - 防止超出容器 */
         .option img {
@@ -288,6 +305,17 @@
             height: auto;
             vertical-align: middle;
         }
+        .question-stem .katex,
+        .question-main .katex,
+        .question-content .katex {
+            font-size: 1em !important;
+            vertical-align: -0.04em;
+        }
+        .question-stem .katex-display,
+        .question-main .katex-display,
+        .question-content .katex-display {
+            margin: 0.35em 0 !important;
+        }
     </style>
 </head>
 <body style="page-break-before: always;">

+ 39 - 11
resources/views/pdf/exam-paper.blade.php

@@ -52,7 +52,7 @@
             --question-gap: 6px;
         }
         body {
-            font-family: "SimSun", "Songti SC", serif; /* 宋体,适合试卷 */
+            font-family: "Noto Serif", "Noto Serif CJK SC", "Noto Sans CJK SC", "Noto Sans", "STSongti-SC", "PingFang SC", "Songti SC", serif;
             line-height: 1.65;
             color: #000;
             background: #fff;
@@ -132,8 +132,8 @@
             align-items: flex-start;
             font-weight: 600;
             font-size: 14px;
-            line-height: 1.6;
-            margin-top: 2px;
+            line-height: 1.65;
+            margin-top: 1px;
         }
         .question-lead.spacer { visibility: hidden; }
         .question-number { white-space: nowrap; margin-right: 2px; }
@@ -301,9 +301,10 @@
         }
         /* 优化SVG中文字标签的显示 */
         svg text {
-            font-family: "SimSun", "Times New Roman", serif !important;
-            font-size: 12px;
+            font-family: "Noto Serif", "Noto Serif CJK SC", "Noto Sans CJK SC", "Noto Sans", "STSongti-SC", "PingFang SC", "Songti SC", serif !important;
+            font-size: 13px !important;
             font-weight: bold;
+            font-style: normal;
             dominant-baseline: middle;
             text-anchor: middle;
             alignment-baseline: central;
@@ -346,26 +347,42 @@
             display: block;
             /* 确保图片不会在页面底部被截断 */
             min-height: 30px;
-            /* 限制单张图片最大高度,防止过大图片跨页 */
-            max-height: 180mm;
+            /* 限制独立图块尺寸,避免图片压过题干 */
+            max-height: 82mm;
         }
         .pdf-figure img {
-            max-width: 100%;
+            max-width: min(84%, 420px);
+            max-height: 82mm;
+            width: auto;
             height: auto;
             display: block;
             margin: 0 auto;
             object-fit: contain;
             box-sizing: border-box;
+            -webkit-print-color-adjust: exact;
+            print-color-adjust: exact;
+            image-rendering: -webkit-optimize-contrast;
         }
         /* 题干中的图片样式(向后兼容) */
         .question-stem img,
         .question-main img,
-        .question-content img {
+        .question-content img,
+        .answer-meta img,
+        .answer-line img,
+        .solution-content img,
+        .solution-section img,
+        .solution-parsed img {
             display: block;
-            max-width: 100%;
+            max-width: 220px;
+            max-height: 60mm;
+            width: auto;
             height: auto;
-            margin: 12px auto;
+            margin: 6px auto;
             box-sizing: border-box;
+            object-fit: contain;
+            -webkit-print-color-adjust: exact;
+            print-color-adjust: exact;
+            image-rendering: -webkit-optimize-contrast;
         }
         /* 选项中的图片样式 - 防止超出容器 */
         .option img {
@@ -381,6 +398,17 @@
                 -webkit-print-color-adjust: exact;
             }
         }
+        .question-stem .katex,
+        .question-main .katex,
+        .question-content .katex {
+            font-size: 1em !important;
+            vertical-align: -0.04em;
+        }
+        .question-stem .katex-display,
+        .question-main .katex-display,
+        .question-content .katex-display {
+            margin: 0.35em 0 !important;
+        }
     </style>
 </head>
 <body>

+ 29 - 11
resources/views/pdf/partials/common-styles.blade.php

@@ -73,8 +73,8 @@
         align-items: flex-start;
         font-weight: 600;
         font-size: 14px;
-        line-height: 1.6;
-        margin-top: 2px;
+        line-height: 1.65;
+        margin-top: 1px;
     }
     .question-lead.spacer { visibility: hidden; }
     .question-number { white-space: nowrap; margin-right: 2px; }
@@ -265,9 +265,10 @@
     
     /* 优化SVG中文字标签的显示 */
     svg text {
-        font-family: "SimSun", "Times New Roman", serif !important;
-        font-size: 12px;
+        font-family: "Noto Serif", "Noto Serif CJK SC", "Noto Sans CJK SC", "Noto Sans", "STSongti-SC", "PingFang SC", "Songti SC", serif !important;
+        font-size: 13px !important;
         font-weight: bold;
+        font-style: normal;
         dominant-baseline: middle;
         text-anchor: middle;
         alignment-baseline: central;
@@ -301,26 +302,42 @@
         margin: 8px 0;
         display: block;
         min-height: 30px;
-        max-height: 180mm;
+        max-height: 82mm;
     }
     .pdf-figure img {
-        max-width: 100%;
+        max-width: min(84%, 420px);
+        max-height: 82mm;
+        width: auto;
         height: auto;
         display: block;
         margin: 0 auto;
         object-fit: contain;
         box-sizing: border-box;
+        -webkit-print-color-adjust: exact;
+        print-color-adjust: exact;
+        image-rendering: -webkit-optimize-contrast;
     }
     
     /* 题干中的图片样式 */
     .question-stem img,
     .question-main img,
-    .question-content img {
+    .question-content img,
+    .answer-meta img,
+    .answer-line img,
+    .solution-content img,
+    .solution-section img,
+    .solution-parsed img {
         display: block;
-        max-width: 100%;
+        max-width: 220px;
+        max-height: 60mm;
+        width: auto;
         height: auto;
-        margin: 12px auto;
+        margin: 6px auto;
         box-sizing: border-box;
+        object-fit: contain;
+        -webkit-print-color-adjust: exact;
+        print-color-adjust: exact;
+        image-rendering: -webkit-optimize-contrast;
     }
     
     /* 选项中的图片样式 */
@@ -342,9 +359,10 @@
 
     /* ==================== KaTeX数学公式样式 ==================== */
     .katex {
-        font-size: 0.95em !important;
+        font-size: 1em !important;
+        vertical-align: -0.04em;
     }
     .katex-display {
-        margin: 0.5em 0 !important;
+        margin: 0.35em 0 !important;
     }
 </style>

+ 14 - 5
resources/views/pdf/partials/kp-explain-styles.blade.php

@@ -40,7 +40,7 @@
         body {
             background: #fff;
             padding: 0;
-            font-family: "SimSun", "Songti SC", serif;
+            font-family: "Noto Serif", "Noto Serif CJK SC", "Noto Sans CJK SC", "Noto Sans", "STSongti-SC", "PingFang SC", "Songti SC", serif;
             line-height: 1.65;
             color: #000;
             font-size: 14px;
@@ -92,7 +92,7 @@
         body {
             background: #fff;
             padding: 0;
-            font-family: "SimSun", "Songti SC", serif;
+            font-family: "Noto Serif", "Noto Serif CJK SC", "Noto Sans CJK SC", "Noto Sans", "STSongti-SC", "PingFang SC", "Songti SC", serif;
             line-height: 1.65;
             color: #000;
             font-size: 14px;
@@ -231,17 +231,26 @@
     .kp-markdown-content th { background: #f5f5f5; font-weight: bold; }
 
     /* ========== KaTeX数学公式样式 ========== */
-    .katex { font-size: 0.95em !important; }
-    .katex-display { margin: 0.5em 0 !important; }
+    .katex { font-size: 1em !important; vertical-align: -0.04em; }
+    .katex-display { margin: 0.35em 0 !important; }
 
     /* ========== 打印专用(不分页) ========== */
     @media print {
         .kp-block-content img,
         .kp-example-content img {
+            display: block;
             break-inside: avoid;
             page-break-inside: avoid;
             -webkit-column-break-inside: avoid;
-            max-width: 100%;
+            max-width: min(84%, 420px);
+            max-height: 82mm;
+            width: auto;
+            height: auto;
+            margin: 6px auto;
+            object-fit: contain;
+            -webkit-print-color-adjust: exact;
+            print-color-adjust: exact;
+            image-rendering: -webkit-optimize-contrast;
         }
     }
 </style>