lxd 1 ماه پیش
والد
کامیت
87c3926cb6
2فایلهای تغییر یافته به همراه32 افزوده شده و 14 حذف شده
  1. 32 6
      OperationUIFrame/OperationUIFrameV2/Scripts/UI/PC_OperatePanel/ScoreInfo.cs
  2. 0 8
      StreamingAssets.meta

+ 32 - 6
OperationUIFrame/OperationUIFrameV2/Scripts/UI/PC_OperatePanel/ScoreInfo.cs

@@ -112,13 +112,13 @@ namespace QFramework
 
             PdfContentByte cb = writer.DirectContent;
 
-            // ===== 横线 =====
+            //===== 横线 =====
             float lineY = doc.Top - 20f;
             cb.MoveTo(doc.Left, lineY);
             cb.LineTo(doc.Right, lineY);
             cb.Stroke();
 
-            // ===== 页眉在横线之上 =====
+            //===== 页眉在横线之上 =====
             string headerText = "虚拟仿真实验中心";
             ColumnText.ShowTextAligned(
                 cb,
@@ -307,18 +307,44 @@ namespace QFramework
 
             private void AddHeader(PdfWriter writer, Document document)
             {
-                PdfPTable headerTable = new PdfPTable(1);
+                PdfPTable headerTable = new PdfPTable(2);
                 headerTable.TotalWidth = document.PageSize.Width - document.LeftMargin - document.RightMargin;
-
-                PdfPCell cell = new PdfPCell(new Phrase("这是页眉内容", pdfFont));
+                headerTable.SetWidths(new float[] { 1, 4 });
+             
+                // 图片单元格
+                string logoPath = Path.Combine(Application.streamingAssetsPath, "Logos", "成绩logo.png");
+                iTextSharp.text.Image logo = iTextSharp.text.Image.GetInstance(logoPath);
+                
+
+                float targetHeight = 2f;
+                //设定统一显示宽度                                          
+                float scaleFactor = targetHeight / logo.Height; // 缩放比例                                           
+                //logo.ScalePercent(scaleFactor); // iTextSharp 用百分比
+                logo.ScaleToFit(2, 1);
+
+                PdfPCell imageCell = new PdfPCell(logo, true);
+                imageCell.Border = Rectangle.NO_BORDER;
+                imageCell.HorizontalAlignment = Element.ALIGN_LEFT;
+
+                // 文本单元格
+                PdfPCell cell = new PdfPCell(new Phrase("虚拟仿真实验中心", pdfFont));
                 cell.Border = Rectangle.BOTTOM_BORDER;
                 cell.BorderColor = BaseColor.GRAY;
                 cell.BorderWidth = 1f;
                 cell.PaddingBottom = 5f;
                 cell.HorizontalAlignment = Element.ALIGN_CENTER;
 
+                PdfPCell cell1 = new PdfPCell(new Phrase("", pdfFont));
+                cell1.Border = Rectangle.BOTTOM_BORDER;
+                cell1.BorderColor = BaseColor.GRAY;
+                cell1.BorderWidth = 1f;
+                cell1.PaddingBottom = 5f;
+                cell1.HorizontalAlignment = Element.ALIGN_RIGHT;
+
+                headerTable.AddCell(imageCell);
                 headerTable.AddCell(cell);
-                headerTable.WriteSelectedRows(0, -1, document.LeftMargin, document.PageSize.Height - document.TopMargin + 10,
+                headerTable.AddCell(cell1);
+                headerTable.WriteSelectedRows(0, -1, document.LeftMargin, document.PageSize.Height - document.TopMargin + 2,
                                              writer.DirectContent);
             }
 

+ 0 - 8
StreamingAssets.meta

@@ -1,8 +0,0 @@
-fileFormatVersion: 2
-guid: 7c1271fd5c2c03745940fa7bb4ff60a5
-folderAsset: yes
-DefaultImporter:
-  externalObjects: {}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: