From 28d777a96bfb92f86267797c5e2e6bc6ba0b7ae7 Mon Sep 17 00:00:00 2001 From: binary-husky Date: Sun, 10 Sep 2023 16:52:35 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crazy_functions/crazy_utils.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/crazy_functions/crazy_utils.py b/crazy_functions/crazy_utils.py index 5a314b379..156717256 100644 --- a/crazy_functions/crazy_utils.py +++ b/crazy_functions/crazy_utils.py @@ -469,14 +469,16 @@ def ffsize_same(a,b): '- ', '') for t in text_areas['blocks'] if 'lines' in t] ############################## <第 2 步,获取正文主字体> ################################## - fsize_statiscs = {} - for span in meta_span: - if span[1] not in fsize_statiscs: fsize_statiscs[span[1]] = 0 - fsize_statiscs[span[1]] += span[2] - main_fsize = max(fsize_statiscs, key=fsize_statiscs.get) - if REMOVE_FOOT_NOTE: - give_up_fize_threshold = main_fsize * REMOVE_FOOT_FFSIZE_PERCENT - + try: + fsize_statiscs = {} + for span in meta_span: + if span[1] not in fsize_statiscs: fsize_statiscs[span[1]] = 0 + fsize_statiscs[span[1]] += span[2] + main_fsize = max(fsize_statiscs, key=fsize_statiscs.get) + if REMOVE_FOOT_NOTE: + give_up_fize_threshold = main_fsize * REMOVE_FOOT_FFSIZE_PERCENT + except: + raise RuntimeError(f'抱歉, 我们暂时无法解析此PDF文档: {fp}。') ############################## <第 3 步,切分和重新整合> ################################## mega_sec = [] sec = [] From 34784333dc29f9c8e8261d1a607c90ac1c3e7ed9 Mon Sep 17 00:00:00 2001 From: binary-husky Date: Sun, 10 Sep 2023 17:22:35 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=9E=8D=E5=90=88PDF=E5=B7=A6=E5=8F=B3?= =?UTF-8?q?=E6=AF=94=E4=BE=8B=E8=B0=83=E6=95=B4=E5=88=B095%?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crazy_functions/latex_fns/latex_toolbox.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crazy_functions/latex_fns/latex_toolbox.py b/crazy_functions/latex_fns/latex_toolbox.py index 5adc7ea80..e39ac2db9 100644 --- a/crazy_functions/latex_fns/latex_toolbox.py +++ b/crazy_functions/latex_fns/latex_toolbox.py @@ -423,7 +423,7 @@ def compile_latex_with_timeout(command, cwd, timeout=60): def merge_pdfs(pdf1_path, pdf2_path, output_path): import PyPDF2 - Percent = 0.8 + Percent = 0.95 # Open the first PDF file with open(pdf1_path, 'rb') as pdf1_file: pdf1_reader = PyPDF2.PdfFileReader(pdf1_file)