py3office 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- py3office-0.1.0/.mailmap +1 -0
- py3office-0.1.0/AUTHORS.txt +6 -0
- py3office-0.1.0/CHANGELOG +8 -0
- py3office-0.1.0/LICENSE +21 -0
- py3office-0.1.0/MANIFEST.in +6 -0
- py3office-0.1.0/PKG-INFO +91 -0
- py3office-0.1.0/README.md +73 -0
- py3office-0.1.0/logo.jpeg +0 -0
- py3office-0.1.0/py3office/__init__.py +1 -0
- py3office-0.1.0/py3office/handler.py +15 -0
- py3office-0.1.0/py3office/pdf.py +45 -0
- py3office-0.1.0/py3office.egg-info/PKG-INFO +91 -0
- py3office-0.1.0/py3office.egg-info/SOURCES.txt +16 -0
- py3office-0.1.0/py3office.egg-info/dependency_links.txt +1 -0
- py3office-0.1.0/py3office.egg-info/requires.txt +1 -0
- py3office-0.1.0/py3office.egg-info/top_level.txt +1 -0
- py3office-0.1.0/setup.cfg +4 -0
- py3office-0.1.0/setup.py +35 -0
py3office-0.1.0/.mailmap
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
zxl20070701 <1904314465@qq.com>
|
py3office-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) zxl20070701 走一步,再走一步
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
py3office-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: py3office
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: 提供python3版本的自动化办公常用处理方法
|
|
5
|
+
Home-page: https://github.com/fragement-contrib/py3office
|
|
6
|
+
Author: zxl20070701
|
|
7
|
+
Author-email: 1904314465@qq.com
|
|
8
|
+
Maintainer: zxl20070701
|
|
9
|
+
Maintainer-email: 1904314465@qq.com
|
|
10
|
+
License: MIT
|
|
11
|
+
Keywords: pdf,office,python3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
License-File: AUTHORS.txt
|
|
18
|
+
|
|
19
|
+
<img src="./logo.jpeg" />
|
|
20
|
+
|
|
21
|
+
# py3office
|
|
22
|
+
提供python3版本的自动化办公常用处理方法
|
|
23
|
+
|
|
24
|
+
<p>
|
|
25
|
+
<a href="https://github.com/fragement-contrib/py3office" target='_blank'>
|
|
26
|
+
<img alt="GitHub repo stars" src="https://img.shields.io/github/stars/fragement-contrib/py3office?style=social">
|
|
27
|
+
</a>
|
|
28
|
+
</p>
|
|
29
|
+
|
|
30
|
+
<!-- pip3 install . -->
|
|
31
|
+
|
|
32
|
+
## 使用
|
|
33
|
+
|
|
34
|
+
首先需要进行安装:
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
pip3 install py3office
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
然后就可以使用了,下面列出所有可用内容:
|
|
41
|
+
|
|
42
|
+
### handler
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
from py3office import handler
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
#### listFile
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
handler.listFile(folder, callback)
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
callback有一个字典类型的参数fileInfo,格式如下:
|
|
55
|
+
|
|
56
|
+
```js
|
|
57
|
+
{
|
|
58
|
+
"path": <文件路径> ,
|
|
59
|
+
"folder": <当前文件所在文件夹>
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### pdf
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
from py3office import pdf
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
#### toImage
|
|
70
|
+
|
|
71
|
+
把pdf转成图片:
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
pdf.toImage(pdfUrl, targetFolder)
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
你还可以传递一个函数来自定义图片名称:
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
# 文件名、内容、页序号、页数
|
|
81
|
+
def getName(name, texts, index, total):
|
|
82
|
+
return <新的名称>
|
|
83
|
+
|
|
84
|
+
pdf.toImage(pdfUrl, targetFolder, getName)
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## 版权
|
|
88
|
+
|
|
89
|
+
MIT License
|
|
90
|
+
|
|
91
|
+
Copyright (c) [zxl20070701](https://zxl20070701.github.io/notebook/home.html) 走一步,再走一步
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
<img src="./logo.jpeg" />
|
|
2
|
+
|
|
3
|
+
# py3office
|
|
4
|
+
提供python3版本的自动化办公常用处理方法
|
|
5
|
+
|
|
6
|
+
<p>
|
|
7
|
+
<a href="https://github.com/fragement-contrib/py3office" target='_blank'>
|
|
8
|
+
<img alt="GitHub repo stars" src="https://img.shields.io/github/stars/fragement-contrib/py3office?style=social">
|
|
9
|
+
</a>
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
<!-- pip3 install . -->
|
|
13
|
+
|
|
14
|
+
## 使用
|
|
15
|
+
|
|
16
|
+
首先需要进行安装:
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
pip3 install py3office
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
然后就可以使用了,下面列出所有可用内容:
|
|
23
|
+
|
|
24
|
+
### handler
|
|
25
|
+
|
|
26
|
+
```python
|
|
27
|
+
from py3office import handler
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
#### listFile
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
handler.listFile(folder, callback)
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
callback有一个字典类型的参数fileInfo,格式如下:
|
|
37
|
+
|
|
38
|
+
```js
|
|
39
|
+
{
|
|
40
|
+
"path": <文件路径> ,
|
|
41
|
+
"folder": <当前文件所在文件夹>
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### pdf
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
from py3office import pdf
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
#### toImage
|
|
52
|
+
|
|
53
|
+
把pdf转成图片:
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
pdf.toImage(pdfUrl, targetFolder)
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
你还可以传递一个函数来自定义图片名称:
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
# 文件名、内容、页序号、页数
|
|
63
|
+
def getName(name, texts, index, total):
|
|
64
|
+
return <新的名称>
|
|
65
|
+
|
|
66
|
+
pdf.toImage(pdfUrl, targetFolder, getName)
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## 版权
|
|
70
|
+
|
|
71
|
+
MIT License
|
|
72
|
+
|
|
73
|
+
Copyright (c) [zxl20070701](https://zxl20070701.github.io/notebook/home.html) 走一步,再走一步
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/python3
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/python3
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
|
|
5
|
+
def listFile(folder, callback):
|
|
6
|
+
list = os.listdir(folder)
|
|
7
|
+
for name in list:
|
|
8
|
+
fullpath = os.path.join(folder, name)
|
|
9
|
+
if os.path.isdir(fullpath):
|
|
10
|
+
listFile(fullpath,callback)
|
|
11
|
+
else:
|
|
12
|
+
callback({
|
|
13
|
+
"path": fullpath,
|
|
14
|
+
"folder":folder
|
|
15
|
+
})
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#!/usr/bin/python3
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import fitz
|
|
5
|
+
import re
|
|
6
|
+
|
|
7
|
+
def toImage(file_path, png_path, getName=False):
|
|
8
|
+
|
|
9
|
+
# 打开pdf
|
|
10
|
+
doc = fitz.open(file_path)
|
|
11
|
+
|
|
12
|
+
# pdf文件名
|
|
13
|
+
name = re.sub(r'\.pdf$','',os.path.basename(file_path))
|
|
14
|
+
|
|
15
|
+
# 总页数
|
|
16
|
+
total = doc.page_count
|
|
17
|
+
|
|
18
|
+
for index in range(total):
|
|
19
|
+
|
|
20
|
+
# 读取内容
|
|
21
|
+
page = doc.load_page(index)
|
|
22
|
+
texts = page.get_text("text").split("\n")
|
|
23
|
+
|
|
24
|
+
zoom = 300 # 值越大,分辨率越高,文件越清晰
|
|
25
|
+
trans = fitz.Matrix(zoom / 100.0, zoom / 100.0).prerotate(0)
|
|
26
|
+
|
|
27
|
+
pm = page.get_pixmap(matrix=trans, alpha=False)
|
|
28
|
+
|
|
29
|
+
# 建立目标文件夹
|
|
30
|
+
if not os.path.exists(png_path):
|
|
31
|
+
os.mkdir(png_path)
|
|
32
|
+
|
|
33
|
+
# 图片名称
|
|
34
|
+
filename=name
|
|
35
|
+
if getName:
|
|
36
|
+
filename=getName(name, texts, index, total)
|
|
37
|
+
elif total>1:
|
|
38
|
+
filename=name+"_"+str(index)
|
|
39
|
+
|
|
40
|
+
# 保存
|
|
41
|
+
save = os.path.join(png_path, '%s.jpg' %filename)
|
|
42
|
+
pm.save(save)
|
|
43
|
+
|
|
44
|
+
# 关闭pdf
|
|
45
|
+
doc.close()
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: py3office
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: 提供python3版本的自动化办公常用处理方法
|
|
5
|
+
Home-page: https://github.com/fragement-contrib/py3office
|
|
6
|
+
Author: zxl20070701
|
|
7
|
+
Author-email: 1904314465@qq.com
|
|
8
|
+
Maintainer: zxl20070701
|
|
9
|
+
Maintainer-email: 1904314465@qq.com
|
|
10
|
+
License: MIT
|
|
11
|
+
Keywords: pdf,office,python3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
License-File: AUTHORS.txt
|
|
18
|
+
|
|
19
|
+
<img src="./logo.jpeg" />
|
|
20
|
+
|
|
21
|
+
# py3office
|
|
22
|
+
提供python3版本的自动化办公常用处理方法
|
|
23
|
+
|
|
24
|
+
<p>
|
|
25
|
+
<a href="https://github.com/fragement-contrib/py3office" target='_blank'>
|
|
26
|
+
<img alt="GitHub repo stars" src="https://img.shields.io/github/stars/fragement-contrib/py3office?style=social">
|
|
27
|
+
</a>
|
|
28
|
+
</p>
|
|
29
|
+
|
|
30
|
+
<!-- pip3 install . -->
|
|
31
|
+
|
|
32
|
+
## 使用
|
|
33
|
+
|
|
34
|
+
首先需要进行安装:
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
pip3 install py3office
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
然后就可以使用了,下面列出所有可用内容:
|
|
41
|
+
|
|
42
|
+
### handler
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
from py3office import handler
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
#### listFile
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
handler.listFile(folder, callback)
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
callback有一个字典类型的参数fileInfo,格式如下:
|
|
55
|
+
|
|
56
|
+
```js
|
|
57
|
+
{
|
|
58
|
+
"path": <文件路径> ,
|
|
59
|
+
"folder": <当前文件所在文件夹>
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### pdf
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
from py3office import pdf
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
#### toImage
|
|
70
|
+
|
|
71
|
+
把pdf转成图片:
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
pdf.toImage(pdfUrl, targetFolder)
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
你还可以传递一个函数来自定义图片名称:
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
# 文件名、内容、页序号、页数
|
|
81
|
+
def getName(name, texts, index, total):
|
|
82
|
+
return <新的名称>
|
|
83
|
+
|
|
84
|
+
pdf.toImage(pdfUrl, targetFolder, getName)
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## 版权
|
|
88
|
+
|
|
89
|
+
MIT License
|
|
90
|
+
|
|
91
|
+
Copyright (c) [zxl20070701](https://zxl20070701.github.io/notebook/home.html) 走一步,再走一步
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
.mailmap
|
|
2
|
+
AUTHORS.txt
|
|
3
|
+
CHANGELOG
|
|
4
|
+
LICENSE
|
|
5
|
+
MANIFEST.in
|
|
6
|
+
README.md
|
|
7
|
+
logo.jpeg
|
|
8
|
+
setup.py
|
|
9
|
+
py3office/__init__.py
|
|
10
|
+
py3office/handler.py
|
|
11
|
+
py3office/pdf.py
|
|
12
|
+
py3office.egg-info/PKG-INFO
|
|
13
|
+
py3office.egg-info/SOURCES.txt
|
|
14
|
+
py3office.egg-info/dependency_links.txt
|
|
15
|
+
py3office.egg-info/requires.txt
|
|
16
|
+
py3office.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
PyMuPDF>=1.23.8
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
py3office
|
py3office-0.1.0/setup.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/python3
|
|
2
|
+
|
|
3
|
+
from setuptools import setup
|
|
4
|
+
|
|
5
|
+
readmeFile = open("README.md", "r",encoding="utf-8")
|
|
6
|
+
long_description = readmeFile.read()
|
|
7
|
+
readmeFile.close()
|
|
8
|
+
|
|
9
|
+
# https://setuptools.pypa.io/en/latest/setuptools.html
|
|
10
|
+
|
|
11
|
+
setup(
|
|
12
|
+
name='py3office',
|
|
13
|
+
version='0.1.0',
|
|
14
|
+
description='提供python3版本的自动化办公常用处理方法',
|
|
15
|
+
long_description=long_description,
|
|
16
|
+
long_description_content_type="text/markdown",
|
|
17
|
+
author='zxl20070701',
|
|
18
|
+
author_email='1904314465@qq.com',
|
|
19
|
+
maintainer='zxl20070701',
|
|
20
|
+
maintainer_email='1904314465@qq.com',
|
|
21
|
+
packages=['py3office'],
|
|
22
|
+
url='https://github.com/fragement-contrib/py3office',
|
|
23
|
+
license='MIT',
|
|
24
|
+
keywords=[
|
|
25
|
+
"pdf","office","python3"
|
|
26
|
+
],
|
|
27
|
+
classifiers=[
|
|
28
|
+
"Programming Language :: Python :: 3",
|
|
29
|
+
"License :: OSI Approved :: MIT License",
|
|
30
|
+
"Operating System :: OS Independent"
|
|
31
|
+
],
|
|
32
|
+
install_requires=[
|
|
33
|
+
'PyMuPDF>=1.23.8'
|
|
34
|
+
]
|
|
35
|
+
)
|