Skip to content

Commit d412a91

Browse files
committed
Auto-generated summary:
Commit Date: 20240319105703 File changes: LICENSE | 3 +- Pipfile | 1 + Pipfile.lock | 282 +++++++++++++++++++++++++++++++++++++++++++- README.md | 6 +- pdf_regenerator/__main__.py | 28 ----- pyproject.toml | 2 +- 6 files changed, 290 insertions(+), 32 deletions(-)
1 parent 67f29e7 commit d412a91

File tree

7 files changed

+290
-32
lines changed

7 files changed

+290
-32
lines changed

LICENSE

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2024 The Python Packaging Authority
1+
Copyright (c) 2024 Talbot3
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy
44
of this software and associated documentation files (the "Software"), to deal
@@ -10,6 +10,7 @@ furnished to do so, subject to the following conditions:
1010
The above copyright notice and this permission notice shall be included in all
1111
copies or substantial portions of the Software.
1212

13+
Contact Email: [email protected]
1314
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1415
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1516
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE

Pipfile

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ python-pptx = "*"
1313
comtypes = "*"
1414
install = "*"
1515
python-magic = "*"
16+
img2pdf = "*"
1617

1718
[dev-packages]
1819

Pipfile.lock

+281-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ PDF Regenerator可帮助您将PDF文档 转换为有辅助信息的PDF。
1212
它可以执行以下功能:
1313

1414
- **标记到索引单元**:将 PDF 文档中的标记转换为索引单元,以便于快速导航和搜索。
15-
- **PPT转PDF**: 将PPT转为PDF,方便学术研究者常常能够回顾知识
15+
16+
## 免费功能
17+
> 开发中
18+
- [ ] **PPT或PPTX转PDF**: 将PPT(X)转为PDF,方便学术研究者常常能够回顾知识
19+
> 由于纯Python实现需要有ppt渲染引擎支持,目前开源社区无有效的解决方案,除了商用的库有支持。
1620
1721
## 付费功能
1822
> 开发中

pdf_regenerator/__main__.py

-28
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,6 @@
55
from PyPDF2 import PdfReader, PdfWriter
66
import io
77
import click
8-
9-
from pptx import Presentation
10-
def ppt_to_pdf(input_ppt_file, output_pdf_file):
11-
prs = Presentation(input_ppt_file)
12-
pdf_canvas = canvas.Canvas(output_pdf_file)
13-
14-
for slide in prs.slides:
15-
pdf_canvas.drawString(100, 800, slide.title.text) # 示例:将PPT每页的标题绘制到PDF页面上
16-
17-
# 如果要将PPT页面内容精确转换为PDF页面内容,需要对slide.shapes进行遍历,根据需要重新排版
18-
19-
pdf_canvas.showPage()
20-
21-
pdf_canvas.save()
22-
23-
def ppt_dir_to_pdf(input_ppt_dir, output_pdf_dir):
24-
import os
25-
26-
if not os.path.exists(output_pdf_dir):
27-
os.makedirs(output_pdf_dir)
28-
29-
for filename in os.listdir(input_ppt_dir):
30-
if filename.endswith(".pptx"): # 确保只处理PPTX文件
31-
ppt_file = os.path.join(input_ppt_dir, filename)
32-
pdf_file = os.path.join(output_pdf_dir, filename.replace(".pptx", ".pdf"))
33-
ppt_to_pdf(ppt_file, pdf_file)
34-
35-
368
@click.command()
379
@click.argument('pdf_path', type=click.Path())
3810
@click.option('output_path', '-o', help='Output file path', type=click.Path(), default=lambda: os.path.join(os.getcwd()))

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "pdf_regenerator"
3-
version = "0.0.20240319084707"
3+
version = "0.0.20240319105703"
44
authors = [{name="Talbot3",email="[email protected]"}]
55
description = "PDF Regenerator是一款开源辅助阅读工具,可帮助重新生成 有辅助信息的PDF 文件。"
66
readme = "README.md"

tests/asset/RAID.pptx

2.66 MB
Binary file not shown.

0 commit comments

Comments
 (0)