From 4605e2757bd7f54305b436da7e65af937bd22437 Mon Sep 17 00:00:00 2001 From: hexin Date: Fri, 3 Mar 2023 14:41:16 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=BA=A7=E5=93=81?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E6=8D=A2=E8=A1=8C=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GenReport/pdf.py | 13 ++++--------- GenReport/pdfmaker.py | 19 +------------------ 2 files changed, 5 insertions(+), 27 deletions(-) diff --git a/GenReport/pdf.py b/GenReport/pdf.py index 107925f..1f4892d 100755 --- a/GenReport/pdf.py +++ b/GenReport/pdf.py @@ -39,8 +39,7 @@ default_para_style.alignment = 1 # 居中对齐 # 首页样式 home_table_style = [ - ['ALIGN', (0, 0), (-1, -1), 'CENTER'], # 第一行水平居中 - ['VALIGN', (0, 0), (-1, -1), 'MIDDLE'], # 所有表格上下居中对齐 + ['VALIGN', (0, 0), (-1, -1), 'TOP'], # 所有表格上对齐 ['ALIGN', (0, 0), (0, -1), 'RIGHT'], ['ALIGN', (1, 0), (1, -1), 'CENTER'], ] @@ -49,6 +48,7 @@ home_para_style.fontName = 'SimSun' home_para_style.fontSize = 20 home_para_style.wordWrap = 'CJK' # 设置自动换行 home_para_style.alignment = 1 # 居中对齐 +home_para_style.leading = 24 def make_pdf_cover(content): @@ -141,7 +141,6 @@ def make_pdf_test_env(content): extra_style, data, totalWidth=total_width, - rowHeight=27, rates=[1, 1, 3])) @@ -163,12 +162,10 @@ def make_pdf_lib(content): # 添加表格 data = [ ['包名', '检测信息', '--', '--', '--'], - ['包名', '检测信息', '--', '--', '--'], ] with open(g_lib, 'r', encoding='utf8') as fp: json_data = json.load(fp) - row = 2 for r in json_data: require_version = json_data[r]["Required version"] @@ -215,9 +212,7 @@ def make_pdf_lib(content): lib_table_style = default_table_style + [ ['BACKGROUND', (0, 0), (-1, 0), table_background_color], # 设置第一行背景颜色 - ['BACKGROUND', (0, 1), (-1, 1), table_background_color], # 设置第二行背景颜色 - ['SPAN', (0, 0), (0, 1)], # 合并第一列一二行 - ['SPAN', (1, 0), (-1, 1)], # 合并第四列一二行 + ['SPAN', (1, 0), (-1, 0)], # 合并第一行后几列 ] is_merge = False @@ -257,7 +252,7 @@ def make_pdf_lib(content): default_para_style.fontSize = s content.append( - PdfMaker.draw_mul_table( + PdfMaker.draw_table( lib_table_style, data, totalWidth=total_width, diff --git a/GenReport/pdfmaker.py b/GenReport/pdfmaker.py index 74ecde6..71cd153 100644 --- a/GenReport/pdfmaker.py +++ b/GenReport/pdfmaker.py @@ -91,24 +91,7 @@ class PdfMaker: # 绘制表格 @staticmethod - def draw_table(style, tab_dict, totalWidth, rates, rowHeight=30): - total_rate = 0 - for rate in rates: - total_rate += rate - - col_rate = [] - for rate in rates: - col_rate.append((rate / total_rate) * totalWidth) - table = LongTable( - tab_dict, - colWidths=col_rate, - style=style, - rowHeights=rowHeight) - return table - - # 跨页合并需求 - @staticmethod - def draw_mul_table(style, tab_dict, totalWidth, rates): + def draw_table(style, tab_dict, totalWidth, rates): total_rate = 0 for rate in rates: total_rate += rate -- Gitee From 7fee0d25e71743423078c86d4ef9fa42955b5ba9 Mon Sep 17 00:00:00 2001 From: hexin Date: Fri, 3 Mar 2023 14:56:03 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E6=96=B0=E5=A2=9Ecmd=E8=B7=AF?= =?UTF-8?q?=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GenReport/pdf.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/GenReport/pdf.py b/GenReport/pdf.py index 1f4892d..44f0423 100755 --- a/GenReport/pdf.py +++ b/GenReport/pdf.py @@ -526,7 +526,13 @@ def make_pdf_cmd(content): else: result = "不符合" - table_content = [r["name"], "-", r["cmd_version"], check, result] + table_content = [ + r["name"], + r["cmd_path"], + r["cmd_version"], + check, + result] + data.append(table_content) i += 1 -- Gitee