1
- import uuid
2
1
from functools import wraps
3
2
4
3
from depdf .base import Base
@@ -13,18 +12,22 @@ class Config(Base):
13
12
# pdf
14
13
logo_flag = DEFAULT_LOGO_FLAG
15
14
header_footer_flag = DEFAULT_HEADER_FOOTER_FLAG
15
+ temp_dir_prefix = DEFAULT_TEMP_DIR_PREFIX
16
+ unique_prefix = None # 该参数会根据 pdf 的文件名自动更新
16
17
17
18
# page
18
19
table_flag = DEFAULT_TABLE_FLAG
19
20
paragraph_flag = DEFAULT_PARAGRAPH_FLAG
20
- img_flag = DEFAULT_IMG_FLAG
21
+ image_flag = DEFAULT_IMAGE_FLAG
21
22
resolution = DEFAULT_RESOLUTION
22
- main_frame_tolerance = DEFAULT_MAIN_FRAME_TOLERANCE
23
+ main_frame_tolerance = None # 该参数可通过页面内容自动分析
23
24
x_tolerance = None # 该参数可通过页面内容自动分析
24
25
y_tolerance = None # 该参数可通过页面内容自动分析
25
26
page_num_top_fraction = DEFAULT_PAGE_NUM_TOP_FRACTION
26
27
page_num_left_fraction = DEFAULT_PAGE_NUM_LEFT_FRACTION
27
28
page_num_right_fraction = DEFAULT_PAGE_NUM_RIGHT_FRACTION
29
+ dotted_line_flag = True
30
+ curved_line_flag = False
28
31
29
32
# chars
30
33
char_overlap_size = DEFAULT_CHAR_OVERLAP_SIZE
@@ -35,10 +38,15 @@ class Config(Base):
35
38
# table
36
39
snap_flag = DEFAULT_SNAP_FLAG
37
40
add_line_flag = DEFAULT_ADD_LINE_FLAG
38
- double_line_tolerance = DEFAULT_DOUBLE_LINE_TOLERANCE
41
+ min_double_line_tolerance = DEFAULT_MIN_DOUBLE_LINE_TOLERANCE # used in page class
42
+ max_double_line_tolerance = DEFAULT_MAX_DOUBLE_LINE_TOLERANCE # used in page class
43
+ vertical_double_line_tolerance = DEFAULT_VERTICAL_DOUBLE_LINE_TOLERANCE # used in page class
39
44
table_cell_merge_tolerance = DEFAULT_TABLE_CELL_MERGE_TOLERANCE
40
45
skip_empty_table = DEFAULT_SKIP_EMPTY_TABLE
41
46
47
+ # image
48
+ min_image_size = DEFAULT_MIN_IMAGE_SIZE
49
+
42
50
# head & tail
43
51
default_head_tail_page_offset_percent = DEFAULT_HEAD_TAIL_PAGE_OFFSET_PERCENT
44
52
@@ -52,13 +60,14 @@ class Config(Base):
52
60
paragraph_class = DEFAULT_PARAGRAPH_CLASS
53
61
table_class = DEFAULT_TABLE_CLASS
54
62
pdf_class = DEFAULT_PDF_CLASS
63
+ image_class = DEFAULT_IMAGE_CLASS
55
64
56
65
def __init__ (self , ** kwargs ):
57
- # add unique prefix to dePDF instance
58
- self .unique_prefix = uuid .uuid4 ()
59
-
66
+ # set log level automatically if debug mode enabled
60
67
if kwargs .get ('debug_flag' ):
61
68
self .log_level = logging .DEBUG
69
+ if kwargs .get ('verbose_flag' ):
70
+ self .log_level = logging .INFO
62
71
63
72
# add configuration parameters
64
73
self .update (** kwargs )
0 commit comments