Skip to content

Commit 6b4ad02

Browse files
committed
refactor(office): 重构 encrypt4pdf 函数并更新相关示例和测试
- 修改 encrypt4pdf 函数签名,使参数顺序更合理 - 更新函数调用示例,以匹配新的参数顺序 - 修改测试代码中的文件路径,以适应新结构 - 更新 readme 文件中的图片链接和群聊入口链接
1 parent 
5-
<img src="https://website-python-1300615378.cos.ap-nanjing.myqcloud.com/%E5%BC%95%E5%AF%BC%E8%B6%85%E9%93%BE%E6%8E%A5%2F%E6%8A%80%E6%9C%AF%E7%BE%A4.jpg" width="100%"/>
4+
<a target="_blank" href='https://mp.weixin.qq.com/s/dfdNNrlnxGCOsDHV4fq6iQ'>
5+
<img src="https://raw.gitcode.com/user-images/assets/5027920/326fcf6a-a93b-407b-b9b6-f8f3b0f9afe9/image.png" width="100%"/>
66
</a>
77
</p>
88

@@ -241,8 +241,8 @@
241241
## 交流群
242242

243243
<p align="center">
244-
<a target="_blank" href='https://mp.weixin.qq.com/s/0GrWWSQ8sKs-WA8WoN3Ztg?payreadticket=HOM_f1W8Dyy1cX9yLlSj9TUoJEXFC4p5UHj4IjbEYOGs2CdefJeSCX4kmmGM6iXpka9eo0c'>
245-
<img src="https://website-python-1300615378.cos.ap-nanjing.myqcloud.com/%E5%BC%95%E5%AF%BC%E8%B6%85%E9%93%BE%E6%8E%A5%2F%E6%8A%80%E6%9C%AF%E7%BE%A4.jpg" width="100%"/>
244+
<a target="_blank" href='https://mp.weixin.qq.com/s/dfdNNrlnxGCOsDHV4fq6iQ'>
245+
<img src="https://raw.gitcode.com/user-images/assets/5027920/326fcf6a-a93b-407b-b9b6-f8f3b0f9afe9/image.png" width="100%"/>
246246
</a>
247247
</p>
248248

@@ -262,8 +262,8 @@
262262

263263

264264
<p align="center" id='进群-banner'>
265-
<a target="_blank" href='https://mp.weixin.qq.com/s/0GrWWSQ8sKs-WA8WoN3Ztg?payreadticket=HOM_f1W8Dyy1cX9yLlSj9TUoJEXFC4p5UHj4IjbEYOGs2CdefJeSCX4kmmGM6iXpka9eo0c'>
266-
<img src="https://website-python-1300615378.cos.ap-nanjing.myqcloud.com/%E5%BC%95%E5%AF%BC%E8%B6%85%E9%93%BE%E6%8E%A5%2F%E6%8A%80%E6%9C%AF%E7%BE%A4.jpg" width="100%"/>
265+
<a target="_blank" href='https://mp.weixin.qq.com/s/dfdNNrlnxGCOsDHV4fq6iQ'>
266+
<img src="https://raw.gitcode.com/user-images/assets/5027920/326fcf6a-a93b-407b-b9b6-f8f3b0f9afe9/image.png" width="100%"/>
267267
</a>
268268
</p>
269269

‎office/api/pdf.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def encrypt4pdf(input_file, output_file, password):
4444
文档:http://www.python4office.cn/python-office/popdf/%E8%AF%BE%E7%A8%8B/5-encrypt4pdf/
4545
演示代码:
4646
"""
47-
popdf.encrypt4pdf(input_file, password, output_file)
47+
popdf.encrypt4pdf(input_file=input_file, output_file=output_file, password=password)
4848

4949

5050
def decrypt4pdf(input_file, password, output_file='decrypt.pdf'):

‎tests/test_code/test_pdf.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ def test_merge2pdf(self):
4646

4747
def test_encrypt4pdf(self):
4848
encrypt4pdf(
49-
path=r'D:\workplace\code\github\popdf\tests\test_files\pdf\32012356985422-watermark.popdf',
49+
input_file=r'../test_files/pdf/in.pdf',
50+
output_file=r'../test_files\pdf\encrypt.popdf',
5051
password='123456'
5152
)
5253

@@ -58,7 +59,7 @@ def test_decrypt4pdf(self):
5859

5960
def test_pdf2imgs(self):
6061
pdf2imgs(
61-
pdf_path =r'./test_files/popdf/in.popdf',
62+
pdf_path=r'./test_files/popdf/in.popdf',
6263
out_dir=r'./test_files/popdf'
6364
)
6465

‎tests/test_files/pdf/encrypt.pdf‎

-45.8 KB
Binary file not shown.

0 commit comments

Comments
 (0)