-
Notifications
You must be signed in to change notification settings - Fork 271
Expand file tree
/
Copy pathtest_pdf.py
More file actions
94 lines (77 loc) · 3.03 KB
/
test_pdf.py
File metadata and controls
94 lines (77 loc) · 3.03 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
import unittest
from office.api.pdf import *
from tests.test_utils.test_input import stub_stdin
class TestPDF(unittest.TestCase):
def test_add_watermark(self):
stub_stdin(self, './test_files/popdf/in.popdf\npython-office\n') # 依次输入
add_watermark()
def test_add_watermark_by_parameters(self):
add_watermark_by_parameters(
pdf_file=r'./test_files/popdf/in.popdf',
mark_str='python-office',
output_file_name='参数-水印-测试.popdf')
def test_pdf2imgs(self):
pdf2imgs(
pdf_path=r'./test_files/popdf/in.popdf',
out_dir='./images')
def test_pdf2docx(self):
pdf2docx(
file_path=r'./test_files/popdf/in.popdf',
output_path=r'./test_files/popdf/'
)
# def test_file2pdf(self):
# file2pdf(
# file_type='txt',
# path=r'./test_files/popdf/in.popdf',
# )
def test_pdf2docx(self):
pdf2docx(
file_path=r'./test_files/popdf/in.popdf',
output_path=r'./test_files/popdf/'
)
def test_merge2pdf(self):
merge2pdf(
one_by_one=[r'./test_files/popdf/in.popdf', r'./test_files/popdf/add_img.popdf'],
output=r'./test_files/popdf/merge2pdf.popdf'
)
def test_single_encrypt4pdf(self):
"""
测试单个PDF文件加密功能
该函数测试encrypt4pdf函数对单个PDF文件进行加密的能力,
将指定的输入PDF文件加密后保存到指定输出路径
"""
encrypt4pdf(
input_file=r'../test_files\pdf\encrypt4pdf\in\程序员晚枫1.pdf',
output_file=r'../test_files\pdf\encrypt4pdf\out\a.pdf',
password='123456'
)
def test_batch_encrypt4pdf(self):
"""
测试批量PDF文件加密功能
该函数测试encrypt4pdf函数对多个PDF文件进行批量加密的能力,
将指定输入目录下的所有PDF文件加密后保存到指定输出目录
"""
encrypt4pdf(
input_path=r'../test_files\pdf\encrypt4pdf\in\o',
output_path=r'../test_files\pdf\encrypt4pdf\out',
password='123456'
)
def test_single_decrypt4pdf(self):
decrypt4pdf(
input_file=r'../test_files\pdf\encrypt4pdf\out\a.pdf',
output_file=r'../test_files\pdf\encrypt4pdf\in\a.pdf',
password='123456')
def test_batch_decrypt4pdf(self):
decrypt4pdf(
input_path=r'../test_files\pdf\encrypt4pdf\out',
output_path=r'../test_files\pdf\encrypt4pdf\in',
password='123456'
)
def test_pdf2imgs(self):
pdf2imgs(
pdf_path=r'./test_files/popdf/in.popdf',
out_dir=r'./test_files/popdf'
)
def test_add_img_water(self):
add_img_water(pdf_file_in='./test_files/popdf/add_img.popdf', pdf_file_mark='./test_files/popdf/in.popdf',
pdf_file_out='add_img_res.popdf')