-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
101 lines (94 loc) · 3.31 KB
/
Copy pathconfig.py
File metadata and controls
101 lines (94 loc) · 3.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
"""
公文格式配置
严格遵循 GB/T 9704-2012《党政机关公文格式》
"""
# 页面设置(单位:毫米,转换为磅时乘以 28.35)
from docx.shared import Mm, Pt
PAGE_SETTINGS = {
'paper_width': Mm(210), # A4 纸宽 210mm
'paper_height': Mm(297), # A4 纸高 297mm
'top_margin': Mm(37), # 上白边(天头)37mm ±1mm
'bottom_margin': Mm(35), # 下白边(地脚)35mm
'left_margin': Mm(28), # 左白边(订口)28mm ±1mm
'right_margin': Mm(26), # 右白边(翻口)26mm
'header_distance': Mm(15), # 页眉距边界
'footer_distance': Mm(15), # 页脚距边界
}
# 版心设置
# 版心尺寸:156mm × 225mm
# 每页 22 行,每行 28 个字
LAYOUT_SETTINGS = {
'lines_per_page': 22,
'chars_per_line': 28,
'line_spacing': Pt(28.95), # 固定值 28-29 磅,确保每页22行
'first_line_indent': Pt(32), # 首行缩进 2 字符(约32磅)
}
# 段落格式
PARAGRAPH_SETTINGS = {
'line_spacing': Pt(28.95), # 固定值 28-29 磅
'line_rule': 'EXACTLY', # 固定值
'space_before': Pt(0), # 段前间距 0
'space_after': Pt(0), # 段后间距 0
'alignment': 'JUSTIFY', # 两端对齐
'first_line_indent': Pt(32), # 首行缩进 2 字符
}
# 字体设置
FONT_SETTINGS = {
# 标题:2号小标宋体
'title': {
'name': '方正小标宋简体',
'size': Pt(22), # 二号字
'bold': False,
'line_spacing': Pt(29), # 标题行距 28-29磅
},
# 正文:3号仿宋_GB2312
'body': {
'name': '仿宋_GB2312',
'size': Pt(16), # 三号字
'bold': False,
},
# 一级标题:3号黑体(一、二、三...)
'heading1': {
'name': '黑体',
'size': Pt(16), # 三号字
'bold': False,
},
# 二级标题:3号楷体_GB2312((一)(二)...)
'heading2': {
'name': '楷体_GB2312',
'size': Pt(16), # 三号字
'bold': False,
},
# 三级标题:3号仿宋_GB2312加粗(1. 2. 3. ...)
'heading3': {
'name': '仿宋_GB2312',
'size': Pt(16), # 三号字
'bold': True,
},
# 四级标题:3号仿宋_GB2312((1)(2)...)
'heading4': {
'name': '仿宋_GB2312',
'size': Pt(16), # 三号字
'bold': False,
},
# 西文字体
'western': {
'name': 'Times New Roman',
},
}
# 文种类型
DOCUMENT_TYPES = {
'请示': {'category': '上行文', 'has_issuer': True},
'报告': {'category': '上行文', 'has_issuer': True},
'通知': {'category': '下行文', 'has_issuer': False},
'函': {'category': '平行文', 'has_issuer': False},
'纪要': {'category': '平行文', 'has_issuer': False},
'批复': {'category': '下行文', 'has_issuer': False},
}
# 标题层级识别规则
HEADING_PATTERNS = {
'heading1': ['一、', '二、', '三、', '四、', '五、', '六、', '七、', '八、', '九、', '十、'],
'heading2': ['(一)', '(二)', '(三)', '(四)', '(五)', '(六)'],
'heading3': ['1.', '2.', '3.', '4.', '5.', '6.', '7.', '8.', '9.'],
'heading4': ['(1)', '(2)', '(3)', '(4)', '(5)', '(6)'],
}